diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b7399e7..7dcaf8f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -114,11 +114,8 @@ PyLint: gilab-ci.yml Lint (python 3.11): - variables: - YAML_LINT_PATH: ".gitlab-ci* ./**/*gitlab-ci*" - YAML_LINT_EXTRA_ARGS: "{ extends: lint/.yamllint.yaml, ignore: [website-template/*] }" extends: - - .yaml_lint_defaults + - .Gitlab_CI.Lint.YAML image: python:3.11-slim diff --git a/automation/.gitlab-ci-ansible.yaml b/automation/.gitlab-ci-ansible.yaml index 7c48d87..d686ad3 100644 --- a/automation/.gitlab-ci-ansible.yaml +++ b/automation/.gitlab-ci-ansible.yaml @@ -25,15 +25,20 @@ include: rules: - if: '$NFC_AUTO_JOBS == "false"' when: never + - if: '$CI_PIPELINE_SOURCE == "schedule" && $PIPELINE_RUN_SCHEDULE == "true"' exists: - ".nfc_automation.yaml" when: always + - if: '$CI_PIPELINE_SOURCE == "pipeline" && $PIPELINE_RUN_TRIGGER == "true"' exists: - ".nfc_automation.yaml" when: always - - if: "$CI_COMMIT_BRANCH == 'development'" # on push to dev run to chek for update + + - if: # condition_dev_branch_push + $CI_COMMIT_BRANCH == "development" && + $CI_PIPELINE_SOURCE == "push" exists: - ".nfc_automation.yaml" when: always @@ -58,6 +63,13 @@ include: rules: - if: $CI_COMMIT_TAG when: never - - if: '$CI_COMMIT_BRANCH == "development" && $CI_PIPELINE_SOURCE == "push"' + + - if: # condition_master_or_dev_push + ( + $CI_COMMIT_BRANCH == "master" || + $CI_COMMIT_BRANCH == "development" + )&& + $CI_PIPELINE_SOURCE == "push" when: on_success + - when: never \ No newline at end of file diff --git a/conventional_commits/.gitlab-ci.yml b/conventional_commits/.gitlab-ci.yml index e1b6a98..8d8b838 100644 --- a/conventional_commits/.gitlab-ci.yml +++ b/conventional_commits/.gitlab-ci.yml @@ -46,22 +46,15 @@ rules: - if: '$JOB_STOP_CONVENTIONAL_COMMITS' when: never - - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - when: never - - if: '$CI_COMMIT_TAG' - when: never - - if: "$CI_COMMIT_AUTHOR =='nfc_bot '" - when: never - - if: '$CI_COMMIT_BRANCH == "master" && - ( $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "pipeline")' - exists: - - .cz.yaml - when: always - - if: '$CI_COMMIT_BRANCH && - ( $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "pipeline")' + + - if: # condition_any_branch_push + $CI_COMMIT_BRANCH != null && + $CI_COMMIT_TAG == null && + $CI_PIPELINE_SOURCE == "push" exists: - .cz.yaml when: always + - when: never diff --git a/docker/build.gitlab-ci.yaml b/docker/build.gitlab-ci.yaml index de69694..19b4c9e 100644 --- a/docker/build.gitlab-ci.yaml +++ b/docker/build.gitlab-ci.yaml @@ -96,24 +96,35 @@ variables: fi rules: - - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - when: never - - if: $CI_COMMIT_TAG - exists: - - dockerfile - - dockerfile.j2 - when: on_success - - if: '$CI_COMMIT_BRANCH == "development" && - ( $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "pipeline")' - exists: - - dockerfile - - dockerfile.j2 - when: on_success - - if: '$CI_COMMIT_BRANCH != "master" && - ( $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "pipeline")' - exists: - - dockerfile - - dockerfile.j2 - when: always - - when: never + - if: # condition_master_branch_push + $CI_COMMIT_BRANCH == "master" && + $CI_PIPELINE_SOURCE == "push" + exists: + - '{dockerfile, dockerfile.j2}' + when: always + + - if: # condition_dev_branch_push + $CI_COMMIT_BRANCH == "development" && + $CI_PIPELINE_SOURCE == "push" + exists: + - '{dockerfile, dockerfile.j2}' + changes: + paths: + - '{dockerfile, dockerfile.j2, includes**/**}' + compare_to: 'master' + when: always + + - if: # condition_not_master_or_dev_push + $CI_COMMIT_BRANCH != "master" && + $CI_COMMIT_BRANCH != "development" && + $CI_PIPELINE_SOURCE == "push" + exists: + - '{dockerfile, dockerfile.j2}' + changes: + paths: + - '{dockerfile, dockerfile.j2, includes**/**}' + compare_to: 'devlopment' + when: always + + - when: never diff --git a/docker/publish.gitlab-ci.yaml b/docker/publish.gitlab-ci.yaml index f5300a5..986e1b4 100644 --- a/docker/publish.gitlab-ci.yaml +++ b/docker/publish.gitlab-ci.yaml @@ -94,24 +94,31 @@ name: DockerHub url: $DOCKER_IMAGE_PUBLISH_URL rules: - - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - when: never - - if: $CI_COMMIT_TAG + + - if: # condition_git_tag + $CI_COMMIT_TAG != null && + $CI_COMMIT_BRANCH == null exists: - - dockerfile - - dockerfile.j2 + - '{dockerfile, dockerfile.j2}' when: on_success - - if: '$CI_COMMIT_BRANCH == "development" && - ( $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "pipeline")' + + - if: # condition_master_branch_push + $CI_COMMIT_BRANCH == "master" && + $CI_PIPELINE_SOURCE == "push" exists: - - dockerfile - - dockerfile.j2 - when: on_success - - if: '$CI_COMMIT_BRANCH != "master" && - ( $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "pipeline")' + - '{dockerfile, dockerfile.j2}' + when: always + + - if: # condition_dev_branch_push + $CI_COMMIT_BRANCH == "development" && + $CI_PIPELINE_SOURCE == "push" exists: - - dockerfile - - dockerfile.j2 + - '{dockerfile, dockerfile.j2}' + changes: + paths: + - '{dockerfile, dockerfile.j2, includes**/**}' + compare_to: 'master' allow_failure: true when: manual + - when: never diff --git a/docs/projects/gitlab-ci/index.md b/docs/projects/gitlab-ci/index.md index ce47a0a..726998b 100644 --- a/docs/projects/gitlab-ci/index.md +++ b/docs/projects/gitlab-ci/index.md @@ -16,6 +16,7 @@ about: https://gitlab.com/nofusscomputing/projects/gitlab-ci - other sub folders are for `` which **DO NOT** automagically create jobs, but are pure definitions only. +- notate how each of the stages run and under what circumstance. *i.e. gitlab-ci.yml rules.exist/rules.changes* ## CI Stages diff --git a/git_push_mirror/.gitlab-ci.yml b/git_push_mirror/.gitlab-ci.yml index 3af788d..172f9bd 100644 --- a/git_push_mirror/.gitlab-ci.yml +++ b/git_push_mirror/.gitlab-ci.yml @@ -17,12 +17,16 @@ rules: - if: '$JOB_STOP_GIT_PUSH_MIRROR' when: never - - if: '$CI_COMMIT_TAG && $GIT_SYNC_URL != null' - when: always - - if: '$CI_COMMIT_BRANCH == "master" && $GIT_SYNC_URL != null && - ( $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "pipeline")' - - if: '$CI_COMMIT_BRANCH == "development" && $GIT_SYNC_URL != null && - ( $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "pipeline")' - when: always - - when: never + - if: $GIT_SYNC_URL == null + when: never + + - if: # condition_master_or_dev_push + ( + $CI_COMMIT_BRANCH == "master" || + $CI_COMMIT_BRANCH == "development" + ) && + $CI_PIPELINE_SOURCE == "push" + when: always + + - when: never diff --git a/gitlab_release/.gitlab-ci.yml b/gitlab_release/.gitlab-ci.yml index 981222d..de576a8 100644 --- a/gitlab_release/.gitlab-ci.yml +++ b/gitlab_release/.gitlab-ci.yml @@ -46,20 +46,22 @@ rules: - if: '$JOB_STOP_GITLAB_RELEASE' when: never - - if: '$CI_COMMIT_TAG' - when: never - - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - when: never + - if: "$CI_COMMIT_AUTHOR =='nfc_bot '" when: never - - if: '$CI_COMMIT_BRANCH == "master" && - ( $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "pipeline")' - when: on_success + + - if: # condition_master_branch_push + $CI_COMMIT_BRANCH == "master" && + $CI_PIPELINE_SOURCE == "push" allow_failure: false - - if: '$CI_COMMIT_BRANCH == "development" && - ( $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "pipeline")' + when: on_success + + - if: # condition_dev_branch_push + $CI_COMMIT_BRANCH == "development" && + $CI_PIPELINE_SOURCE == "push" when: manual allow_failure: true + # for testing # - if: '$CI_COMMIT_BRANCH != "master"' # when: always @@ -100,12 +102,19 @@ commit footer refs: rules: - if: '$JOB_STOP_CONVENTIONAL_COMMITS' when: never - - if: '$CI_COMMIT_BRANCH == "development" || $CI_COMMIT_BRANCH == "master"' + + - if: $CHANGELOG_FOOTER_REFERENCES == "False" when: never - - if: '$CI_COMMIT_BRANCH && $CHANGELOG_FOOTER_REFERENCES != "False" && - ( $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "pipeline")' + + # - if: '$CI_COMMIT_BRANCH == "development" || $CI_COMMIT_BRANCH == "master"' + # when: never + + - if: # condition_any_branch_push + $CI_COMMIT_BRANCH != null && + $CI_COMMIT_TAG == null && + $CI_PIPELINE_SOURCE == "push" exists: - .cz.yaml when: always - - when: never + - when: never diff --git a/lint/ansible.gitlab-ci.yaml b/lint/ansible.gitlab-ci.yaml index 1cde669..a9f5554 100644 --- a/lint/ansible.gitlab-ci.yaml +++ b/lint/ansible.gitlab-ci.yaml @@ -33,23 +33,38 @@ junit: - "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/*.junit.xml" rules: + - if: '$JOB_STOP_ANSIBLE_LINT' when: never - - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - when: never - - if: '$CI_COMMIT_BRANCH == "master" && - ( $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "pipeline")' - exists: - - 'tasks/main.yaml' - when: always - - if: '$CI_COMMIT_TAG' - exists: - - 'tasks/main.yaml' - when: always - - if: '$CI_COMMIT_BRANCH && - ( $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "pipeline")' - exists: - - 'tasks/main.yaml' - when: always - - when: never + - if: # condition_master_branch_push + $CI_COMMIT_BRANCH == "master" && + $CI_PIPELINE_SOURCE == "push" + exists: + - '{defaults/**,handlers/**,meta/**,tasks/**}/*.yaml' + when: always + + - if: # condition_dev_branch_push + $CI_COMMIT_BRANCH == "development" && + $CI_PIPELINE_SOURCE == "push" + exists: + - '{defaults/**,handlers/**,meta/**,tasks/**}/*.yaml' + changes: + paths: + - '{defaults/**,handlers/**,meta/**,tasks/**}/*.yaml' + compare_to: 'master' + when: always + + - if: # condition_not_master_or_dev_push + $CI_COMMIT_BRANCH != "master" && + $CI_COMMIT_BRANCH != "development" && + $CI_PIPELINE_SOURCE == "push" + exists: + - '{defaults/**,handlers/**,meta/**,tasks/**}/*.yaml' + changes: + paths: + - '{defaults/**,handlers/**,meta/**,tasks/**}/*.yaml' + compare_to: 'development' + when: always + + - when: never diff --git a/lint/markdown.gitlab-ci.yaml b/lint/markdown.gitlab-ci.yaml index 3c26f93..8778f93 100644 --- a/lint/markdown.gitlab-ci.yaml +++ b/lint/markdown.gitlab-ci.yaml @@ -29,11 +29,18 @@ junit: - "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/lint_markdown/*.junit.xml" rules: - - if: '$CI_COMMIT_BRANCH && - ( $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "pipeline")' + - if: '$JOB_STOP_LINT_MARKDOWN' + when: never + + - if: # condition_any_branch_push + $CI_COMMIT_BRANCH != null && + $CI_COMMIT_TAG == null && + $CI_PIPELINE_SOURCE == "push" exists: - - "**.md" - - "**/**.md" + # - "**.md" + # - "**/**.md" + - '{!docs/**,!pages/**,!gitlab-ci/**, !website-template/**, **}/*.md' + when: always - when: never @@ -43,17 +50,38 @@ MD_LINT_CONFIG_PATH: "$CI_PROJECT_DIR/website-template" extends: .Lint_Markdown rules: - - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' + - if: '$JOB_STOP_LINT_MARKDOWN_DOCS' when: never - - if: '$CI_COMMIT_TAG' + + - if: # condition_master_branch_push + $CI_COMMIT_BRANCH == "master" && + $CI_PIPELINE_SOURCE == "push" exists: - - "docs/index.md" - - "pages/index.md" + - '{docs/**,pages/**}/*.md' when: always - - if: '$CI_COMMIT_BRANCH && - ( $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "pipeline")' + + - if: # condition_dev_branch_push + $CI_COMMIT_BRANCH == "development" && + $CI_PIPELINE_SOURCE == "push" exists: - - "docs/index.md" - - "pages/index.md" + - '{docs/**,pages/**}/*.md' + changes: + paths: + - '{docs/**,pages/**}/*.md' + compare_to: 'master' when: always - - when: never \ No newline at end of file + + - if: # condition_not_master_or_dev_push + $CI_COMMIT_BRANCH != "master" && + $CI_COMMIT_BRANCH != "development" && + $CI_PIPELINE_SOURCE == "push" + exists: + - '{docs/**,pages/**}/*.md' # works + changes: + paths: + #- '{docs/*,pages/*}*.md' + - '{docs/**,pages/**}/*.md' + compare_to: 'development' + when: always + + - when: never diff --git a/lint/yaml.gitlab-ci.yaml b/lint/yaml.gitlab-ci.yaml index 8e262f5..4d99496 100644 --- a/lint/yaml.gitlab-ci.yaml +++ b/lint/yaml.gitlab-ci.yaml @@ -1,49 +1,108 @@ .yaml_lint_defaults: - variables: - YAML_LINT_PATH: "." - YAML_LINT_EXTRA_ARGS: "{ extends: $ROOT_DIR/lint/.yamllint.yaml, ignore: [gitlab-ci/*] }" - stage: validation - before_script: - - if [ "0$JOB_ROOT_DIR" == "0" ]; then ROOT_DIR=gitlab-ci; else ROOT_DIR=$JOB_ROOT_DIR ; fi - - echo "[DEBUG] ROOT_DIR[$ROOT_DIR]" - - mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME" - - mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests" - - export PYTHON_VERSION=`python -c 'import sys; version=sys.version_info[:3]; print("{0}.{1}.{2}".format(*version))'` - - apt update - - apt install --no-install-recommends -y git - - python3 -m venv env - - . env/bin/activate - - pip install --upgrade pip - - pip install -r $ROOT_DIR/lint/requirements.txt - - mkdir $PYTHON_VERSION - script: - - echo "[DEBUG] YAML_LINT_PATH[$YAML_LINT_PATH]" - - echo "[DEBUG] YAML_LINT_CONFIG[$YAML_LINT_CONFIG]" - - yamllint $YAML_LINT_PATH -f parsable -d "$(echo $YAML_LINT_EXTRA_ARGS)" > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/$PYTHON_VERSION-yaml-lint.log" 1>&1 || YAML_LINT=$? - - cat "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/$PYTHON_VERSION-yaml-lint.log" | ansible-lint-to-junit-xml > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/$PYTHON_VERSION-yaml-lint.junit.xml" - - if [ $YAML_LINT > 0 ]; then echo "YAML lint failed with $YAML_LINT"; exit $YAML_LINT; fi - after_script: - - echo deactivate - artifacts: - expire_in: 3 days - when: always + variables: + YAML_LINT_PATH: "." + YAML_LINT_EXTRA_ARGS: "{ extends: $ROOT_DIR/lint/.yamllint.yaml, ignore: [gitlab-ci/*, website-template/*] }" + stage: validation + before_script: + - if [ "0$JOB_ROOT_DIR" == "0" ]; then ROOT_DIR=gitlab-ci; else ROOT_DIR=$JOB_ROOT_DIR ; fi + - echo "[DEBUG] ROOT_DIR[$ROOT_DIR]" + - mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME" + - mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests" + - export PYTHON_VERSION=`python -c 'import sys; version=sys.version_info[:3]; print("{0}.{1}.{2}".format(*version))'` + - apt update + - apt install --no-install-recommends -y git + - python3 -m venv env + - . env/bin/activate + - pip install --upgrade pip + - pip install -r $ROOT_DIR/lint/requirements.txt + - mkdir $PYTHON_VERSION + script: + - echo "[DEBUG] YAML_LINT_PATH[$YAML_LINT_PATH]" + - echo "[DEBUG] YAML_LINT_CONFIG[$YAML_LINT_CONFIG]" + - yamllint $YAML_LINT_PATH -f parsable -d "$(echo $YAML_LINT_EXTRA_ARGS)" > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/$PYTHON_VERSION-yaml-lint.log" 1>&1 || YAML_LINT=$? + - cat "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/$PYTHON_VERSION-yaml-lint.log" | ansible-lint-to-junit-xml > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/$PYTHON_VERSION-yaml-lint.junit.xml" + - if [ $YAML_LINT > 0 ]; then echo "YAML lint failed with $YAML_LINT"; exit $YAML_LINT; fi + after_script: + - echo deactivate + artifacts: + expire_in: 3 days + when: always + paths: + - "artifacts/*" + reports: + junit: + - "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/*.junit.xml" + rules: + - if: '$JOB_STOP_YAML_LINT' + when: never + + - if: '$CI_COMMIT_BRANCH == "master" && + ( $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "pipeline")' + when: always + + - if: '$CI_COMMIT_BRANCH && + ( $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "pipeline")' + exists: + - '{!gitlab-ci/**/*, !website-template/**/*, !.gitlab-ci, !*gitlab-ci*, **/*, **}.{yml, yaml}' + # - ".gitlab-ci*" + # - "**/*gitlab-ci*" + changes: paths: - - "artifacts/*" - reports: - junit: - - "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/*.junit.xml" - rules: - - if: '$JOB_STOP_YAML_LINT' - when: never - - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - when: never - - if: '$CI_COMMIT_TAG' - when: always - - if: '$CI_COMMIT_BRANCH == "master" && - ( $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "pipeline")' - when: always - - if: '$CI_COMMIT_BRANCH && - ( $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "pipeline")' - when: always - - when: never + - '{!gitlab-ci/**/*, !website-template/**/*, !.gitlab-ci, !*gitlab-ci*, **/*, **}.{yml, yaml}' + compare_to: 'master' + when: always + + - when: never + + +.Gitlab_CI.Lint.YAML: + variables: + YAML_LINT_PATH: ".gitlab-ci* ./**/*gitlab-ci*" + YAML_LINT_EXTRA_ARGS: "{ extends: lint/.yamllint.yaml, ignore: [gitlab-ci/*, website-template/*] }" + extends: + - .yaml_lint_defaults + rules: + + - if: # condition_master_branch_push + $CI_COMMIT_BRANCH == "master" && + $CI_PIPELINE_SOURCE == "push" + exists: + #- '{!gitlab-ci/**, !website-template/**, **}/*gitlab-ci*' + - '{*, **/}*gitlab-ci*' + # - ".gitlab-ci*" + # - "**/*gitlab-ci*" + when: always + + - if: # condition_dev_branch_push + $CI_COMMIT_BRANCH == "development" && + $CI_PIPELINE_SOURCE == "push" + exists: + #- '{!gitlab-ci/**, !website-template/**, **}/*gitlab-ci*' + - '{*, **/}*gitlab-ci*' + changes: + paths: + #- '{!gitlab-ci/**, !website-template/**, **}/*gitlab-ci*' + - '{*, **/}*gitlab-ci*' + compare_to: 'master' + when: always + + - if: # condition_not_master_or_dev_push + $CI_COMMIT_BRANCH != "master" && + $CI_COMMIT_BRANCH != "development" && + $CI_PIPELINE_SOURCE == "push" + exists: + #- '{!gitlab-ci/**, !website-template/**, **}/*gitlab-ci*yml' + #- '{*, a}/*gitlab-ci*yml' # worked + #- '{!website-template/**, *, **, **/**}gitlab-ci*' + #- '{*, **, **/**, !website-template/**}/*gitlab-c*' worked + - '{*, **/}*gitlab-ci*' + changes: + paths: + - '{*, **/}*gitlab-ci*' + # - ".gitlab-ci*" + # - "**/*gitlab-ci*" + compare_to: 'development' + when: always + + - when: never diff --git a/mkdocs/.gitlab-ci.yml b/mkdocs/.gitlab-ci.yml index f7b40a5..3187fa1 100644 --- a/mkdocs/.gitlab-ci.yml +++ b/mkdocs/.gitlab-ci.yml @@ -23,21 +23,18 @@ paths: - "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME" rules: + - if: '$JOB_STOP_MKDOCS_BUILD' when: never - - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - when: never - - if: $CI_COMMIT_TAG + + - if: # condition_any_branch_push + $CI_COMMIT_BRANCH != null && + $CI_COMMIT_TAG == null && + $CI_PIPELINE_SOURCE == "push" exists: - - "mkdocs.yaml" - - "mkdocs.yml" - when: always - - if: '$CI_COMMIT_BRANCH && - ( $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "pipeline")' - exists: - - "mkdocs.yaml" - - "mkdocs.yml" + - 'mkdocs.{yaml,yml}' when: always + - when: never @@ -48,15 +45,36 @@ rules: - if: '$JOB_STOP_MKDOCS_BUILD' when: never - - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - when: never - - if: $CI_COMMIT_TAG + + - if: # condition_master_branch_push + $CI_COMMIT_BRANCH == "master" && + $CI_PIPELINE_SOURCE == "push" exists: - - "docs/index.md" + - '{docs/**,pages/**}/*.md' when: always - - if: '$CI_COMMIT_BRANCH && - ( $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "pipeline")' + + - if: # condition_dev_branch_push + $CI_COMMIT_BRANCH == "development" && + $CI_PIPELINE_SOURCE == "push" exists: - - "docs/index.md" + - '{docs/**,pages/**}/*.md' + changes: + paths: + - '{docs/**,pages/**}/*.md' + compare_to: 'master' when: always - - when: never \ No newline at end of file + + - if: # condition_not_master_or_dev_push + $CI_COMMIT_BRANCH != "master" && + $CI_COMMIT_BRANCH != "development" && + $CI_PIPELINE_SOURCE == "push" + exists: + - '{docs/**,pages/**}/*.md' + changes: + paths: + - '{docs/**,pages/**}/*.md' + compare_to: 'development' + when: always + + - when: never + \ No newline at end of file diff --git a/python/.gitlab-ci.yml b/python/.gitlab-ci.yml index c1ecbf3..f820403 100644 --- a/python/.gitlab-ci.yml +++ b/python/.gitlab-ci.yml @@ -5,49 +5,81 @@ }" > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/badge_pylint.json" .PyLint: - variables: - PYLINT_PATH: "/*/python-module/*/*.py" - PYLINT_RC_PATH: "/python/.pylintrc" - stage: validation - before_script: - - if [ "0$JOB_ROOT_DIR" == "0" ]; then ROOT_DIR=gitlab-ci; else ROOT_DIR=$JOB_ROOT_DIR ; fi - - echo "[DEBUG] ROOT_DIR[$ROOT_DIR]" - - mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME" - - mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests" - - export PYTHON_VERSION=`python -c 'import sys; version=sys.version_info[:3]; print("{0}.{1}.{2}".format(*version))'` - - apt update - - apt install --no-install-recommends -y git - - python3 -m venv env - - . env/bin/activate - - pip install --upgrade pip - - pip install -r $ROOT_DIR/python/requirements.txt - - mkdir $PYTHON_VERSION - script: - - PYLINT_PATH=$ROOT_DIR$PYLINT_PATH - - echo "[DEBUG] PYLINT_PATH[$PYLINT_PATH]" - - PYLINT_RC_PATH=$ROOT_DIR$PYLINT_RC_PATH - - echo "[DEBUG] PYLINT_RC_PATH[$PYLINT_RC_PATH]" - - python3 -m pylint --rcfile $PYLINT_RC_PATH --exit-zero --output-format=pylint_gitlab.GitlabCodeClimateReporter $PYLINT_PATH > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/gl-code-quality-report.json" + variables: + PYLINT_PATH: "/*/python-module/*/*.py" + PYLINT_RC_PATH: "/python/.pylintrc" + stage: validation + before_script: + - if [ "0$JOB_ROOT_DIR" == "0" ]; then ROOT_DIR=gitlab-ci; else ROOT_DIR=$JOB_ROOT_DIR ; fi + - echo "[DEBUG] ROOT_DIR[$ROOT_DIR]" + - mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME" + - mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests" + - export PYTHON_VERSION=`python -c 'import sys; version=sys.version_info[:3]; print("{0}.{1}.{2}".format(*version))'` + - apt update + - apt install --no-install-recommends -y git + - python3 -m venv env + - . env/bin/activate + - pip install --upgrade pip + - pip install -r $ROOT_DIR/python/requirements.txt + - mkdir $PYTHON_VERSION + script: + - PYLINT_PATH=$ROOT_DIR$PYLINT_PATH + - echo "[DEBUG] PYLINT_PATH[$PYLINT_PATH]" + - PYLINT_RC_PATH=$ROOT_DIR$PYLINT_RC_PATH + - echo "[DEBUG] PYLINT_RC_PATH[$PYLINT_RC_PATH]" + - python3 -m pylint --rcfile $PYLINT_RC_PATH --exit-zero --output-format=pylint_gitlab.GitlabCodeClimateReporter $PYLINT_PATH > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/gl-code-quality-report.json" - - python3 -m pylint --rcfile $PYLINT_RC_PATH --exit-zero --output-format=pylint_gitlab.GitlabPagesHtmlReporter $PYLINT_PATH > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/gl-code-quality-report.html" + - python3 -m pylint --rcfile $PYLINT_RC_PATH --exit-zero --output-format=pylint_gitlab.GitlabPagesHtmlReporter $PYLINT_PATH > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/gl-code-quality-report.html" - - PyPIScore=$(python3 -m pylint --rcfile $PYLINT_RC_PATH --exit-zero $PYLINT_PATH | sed -n 's/^Your code has been rated at \([-0-9./]*\).*/\1/p') + - PyPIScore=$(python3 -m pylint --rcfile $PYLINT_RC_PATH --exit-zero $PYLINT_PATH | sed -n 's/^Your code has been rated at \([-0-9./]*\).*/\1/p') - - *pylint_badge + - *pylint_badge + after_script: + - echo deactivate + artifacts: + expire_in: 1 days + when: always + paths: + - "artifacts/*" + reports: + codequality: "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/gl-code-quality-report.json" + rules: + + - if: # condition_master_branch_push + $CI_COMMIT_BRANCH == "master" && + $CI_PIPELINE_SOURCE == "push" + exists: + #- '{**/,*,!gitlab-ci/**,!website-template/**}*.py' + - '{**/,*}*.py' + when: always - after_script: - - echo deactivate - artifacts: - expire_in: 1 days - when: always + - if: # condition_development_branch_push + $CI_COMMIT_BRANCH == "development" && + $CI_PIPELINE_SOURCE == "push" + exists: + #- '{**/,*,!gitlab-ci/**,!website-template/**}*.py' + - '{**/,*}*.py' + changes: paths: - - "artifacts/*" - reports: - codequality: "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/gl-code-quality-report.json" - rules: - - if: '$CI_COMMIT_BRANCH && - ( $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "pipeline")' - when: always - - when: never + #- '{**/,*,!gitlab-ci/**,!website-template/**}*.py' + - '{**/,*}*.py' + compare_to: 'master' + when: always + + - if: # condition_not_master_or_dev_push + $CI_COMMIT_BRANCH != "master" && + $CI_COMMIT_BRANCH != "development" && + $CI_PIPELINE_SOURCE == "push" + exists: + #- '{**/,*,!gitlab-ci/**,!website-template/**}*.py' + - '{**/,*}*.py' + changes: + paths: + #- '{**/,*,!gitlab-ci/**,!website-template/**}*.py' + - '{**/,*}*.py' + compare_to: 'development' + when: always + + - when: never diff --git a/template/docker-image.gitlab-ci.yaml b/template/docker-image.gitlab-ci.yaml index ea7c575..98afc62 100644 --- a/template/docker-image.gitlab-ci.yaml +++ b/template/docker-image.gitlab-ci.yaml @@ -30,10 +30,47 @@ Docker Container: extends: .build_docker_container -Docker Hub: +Docker.Hub.Branch.Publish: extends: .publish-docker-hub needs: [ "Docker Container" ] + rules: # rules manually synced from docker/publish.gitlab-ci.yaml removing git tag + + - if: # condition_master_branch_push + $CI_COMMIT_BRANCH == "master" && + $CI_PIPELINE_SOURCE == "push" + exists: + - '{dockerfile, dockerfile.j2}' + when: always + + - if: # condition_dev_branch_push + $CI_COMMIT_BRANCH == "development" && + $CI_PIPELINE_SOURCE == "push" + exists: + - '{dockerfile, dockerfile.j2}' + changes: + paths: + - '{dockerfile, dockerfile.j2, includes**/**}' + compare_to: 'master' + allow_failure: true + when: manual + + - when: never + + +Docker.Hub.Tag.Publish: + extends: .publish-docker-hub + rules: # rules manually synced from docker/publish.gitlab-ci.yaml only keeping git tag + + - if: # condition_git_tag + $CI_COMMIT_TAG != null && + $CI_COMMIT_BRANCH == null + exists: + - '{dockerfile, dockerfile.j2}' + when: always + + - when: never + Gitlab Release: extends: diff --git a/template/mkdocs-documentation.gitlab-ci.yaml b/template/mkdocs-documentation.gitlab-ci.yaml index 801e36c..01ec5b7 100644 --- a/template/mkdocs-documentation.gitlab-ci.yaml +++ b/template/mkdocs-documentation.gitlab-ci.yaml @@ -15,7 +15,7 @@ Documentation.Build: extends: .MKDocs_Build_Docs needs: [ 'Documentation.Lint' ] - +# this name must always be called 'pages' so that gitlab pages work pages: stage: deploy variables: @@ -32,21 +32,29 @@ pages: rules: - if: '$JOB_STOP_GITLAB_PAGES' when: never - - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - when: never - - if: $CI_COMMIT_TAG - when: never - - if: '$CI_COMMIT_BRANCH == "development" && - ( $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "pipeline")' + + - if: # condition_dev_branch_push + $CI_COMMIT_BRANCH == "development" && + $CI_PIPELINE_SOURCE == "push" exists: - - "mkdocs.yaml" - - "mkdocs.yml" + - '{docs/**,pages/**}/*.md' + changes: + paths: + - '{docs/**,pages/**}/*.md' + compare_to: 'master' when: always - - if: '$CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != "master" && - ( $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "pipeline")' + + - if: # condition_not_master_or_dev_push + $CI_COMMIT_BRANCH != "master" && + $CI_COMMIT_BRANCH != "development" && + $CI_PIPELINE_SOURCE == "push" exists: - - "mkdocs.yaml" - - "mkdocs.yml" - when: manual + - '{docs/**,pages/**}/*.md' + changes: + paths: + - '{docs/**,pages/**}/*.md' + compare_to: 'development' allow_failure: true - - when: never \ No newline at end of file + when: manual + + - when: never