diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..be38de5d49d4c05657b23c488387186f3a8a1c95 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,193 @@ +--- +# GLOBAL CONFIGURATION +# ============================================================================= +# YAML Anchors +# ----------------------------------------------------------------------------- +# This CI file haevily make use of YAML anchors for multiple reasons: +# - Avoid writing twice the same block of codes +# - Resuse block of codes +# - Make the CI more generic and easily extensible or modifiable +# See https://docs.gitlab.com/ee/ci/yaml/README.html#anchors + +# Define base workflow +# https://docs.gitlab.com/ee/ci/yaml/README.html#workflow +workflow: + rules: + # Do not run CI when commit title have + # WIP, NO-CI or 🚧 (gitmoji for "work in progress", aka :construction:) + - if: | + $CI_COMMIT_TITLE =~ /.*WIP.*/ || + $CI_COMMIT_TITLE =~ /.*NO-CI.*/ || + $CI_COMMIT_TITLE =~ /.*🚧.*/ + when: never + # Run the CI otherwise (depending on `only/except` key per jobs) + - when: always + +### BEGIN MKDOCS TEMPLATE ### +### WARNING, DO NOT UPDATE CONTENT BETWEEN MKDOCS TEMPLATE TAG ! ### +### Modified content will be overwritten when updating. ### + +# Include other gitlab-ci.yml files +include: + - local: docs/.gitlab-ci.yml + +### END MKDOCS TEMPLATE ### + +# Stages jobs will pass through with anchors to avoid updating stage in multiple +# place within this file. Now renaming a stage can be done directly after the +# anchor name below. +# https://docs.gitlab.com/ee/ci/yaml/README.html#stage +stages: + - &pre_test pre_test + - &test test + - &build build + - &deploy deploy + - &post_deploy post_deploy + +# Global variables shared for all jobs +# https://docs.gitlab.com/ee/ci/yaml/README.html#variables +variables: + PIP_CACHE_DIR: "${CI_PROJECT_DIR}/.cache/pip" + +# Images anchors +# ----------------------------------------------------------------------------- +# https://docs.gitlab.com/ee/ci/yaml/README.html#image +# Basic docker image -> docker:latest image +.image_docker: &image_docker + image: docker:latest + +# Before scripts anchors +# ----------------------------------------------------------------------------- +# https://docs.gitlab.com/ee/ci/yaml/README.html#before_script +.before_script_python_dependencies: &before_script_python_dependencies + before_script: + # Add python dependencies + - apk update + # Install base package required for mkdocs builds + - apk add --no-cache --update-cache + build-base + python3-dev + py3-pip + py3-virtualenv + bash + git + gcc + # Create virtual environment + - virtualenv .venv + # Activate virtual environment + - source .venv/bin/activate + +# Only anchors +# ----------------------------------------------------------------------------- +# https://docs.gitlab.com/ee/ci/yaml/README.html#only +# List all names of refs that can be used with key (only|except):refs using +# anchors to avoid having to modify multiple times. Refs are: +# - Branches names based on git flow: https://danielkummer.github.io/git-flow-cheatsheet/ +# - merge_requests (https://docs.gitlab.com/ee/ci/yaml/README.html#onlyexcept-basic) +# - tags (https://docs.gitlab.com/ee/ci/yaml/README.html#onlyexcept-basic) +.refs_names: + - &ref_release /release-*/ + - &ref_feature /feature-*/ + - &ref_hotfix /hotfix-*/ + - &ref_bugfix /bugfix-*/ + - &ref_develop develop + - &ref_master master + - &ref_merge_requests merge_requests + - &ref_tags tags + +# Specify on which branch, tags or on merge_requests CI should be done. +# Jobs under only_dev anchor will be run if branch name are compliant with git +# flow branch which are not `develop` neither `master` and will be run on +# merge_request +.only_dev: &only_dev + only: + refs: + - *ref_release + - *ref_feature + - *ref_hotfix + - *ref_bugfix + - *ref_merge_requests + +# Jobs under only_pre_prod anchor will be run on `develop` (i.e. pre-release) +# and `master` (release) branch. +.only_pre_prod: &only_pre_prod + only: + refs: + - *ref_develop + - *ref_master + +# Jobs under only_prod anchor will be run on tagged commit. +.only_prod: &only_prod + only: + refs: + - *ref_tags + +# Jobs under only_trigger anchor will be run on `develop` (i.e. pre-release) +# `master` (release) branch and tagged commit. +.only_trigger: &only_trigger + only: + refs: + - *ref_develop + - *ref_master + - *ref_tags + +# Tag anchors +# ----------------------------------------------------------------------------- +# https://docs.gitlab.com/ee/ci/yaml/README.html#tag +# Run jobs in regular docker +.tag_docker: &tag_docker + tags: + - docker + +# Stages anchors +# ----------------------------------------------------------------------------- +# https://docs.gitlab.com/ee/ci/yaml/README.html#stage +# This can be seen as overbloated while overuse of YAML anchors, but the +# advantage is that if we rename a stage, we will just need to rename it at the +# start of this CI. +.stage_pre_test: &stage_pre_test + stage: *pre_test + +.stage_test: &stage_test + stage: *test + +.stage_build: &stage_build + stage: *build + +.stage_deploy: &stage_deploy + stage: *deploy + +.stage_post_deploy: &stage_post_deploy + stage: *post_deploy + +# ============================================================================= +# CI JOBS +# ============================================================================= +# Jobs in test stage +# ----------------------------------------------------------------------------- +test_tox_format_python: + <<: *tag_docker + <<: *image_docker + <<: *stage_test + <<: *before_script_python_dependencies + script: + # Install python tox + - pip3 install tox + # Run tox + - tox -e format_python + +test_tox_format_shell: + <<: *tag_docker + <<: *image_docker + <<: *stage_test + <<: *before_script_python_dependencies + script: + # Install python tox + - pip3 install tox + # Run tox + - tox -e format_shell + +# ***************************************************************************** +# VIM MODELINE +# vim: fdm=indent +# *****************************************************************************