Skip to content
Snippets Groups Projects
Commit 543b4fe6 authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

feat: adaptive pipeline rules

BREAKING CHANGE: change default workflow from Branch pipeline to MR pipeline
parent 714e066c
No related branches found
No related tags found
No related merge requests found
...@@ -16,11 +16,30 @@ ...@@ -16,11 +16,30 @@
# default workflow rules: Merge Request pipelines # default workflow rules: Merge Request pipelines
workflow: workflow:
rules: rules:
- if: '$CI_MERGE_REQUEST_ID' # prevent branch pipeline when an MR is open (prefer MR pipeline)
- if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS' - if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
when: never when: never
- when: always - when: always
# test job prototype: implement adaptive pipeline rules
.test-policy:
rules:
# on tag: auto & failing
- if: $CI_COMMIT_TAG
# on ADAPTIVE_PIPELINE_DISABLED: auto & failing
- if: '$ADAPTIVE_PIPELINE_DISABLED == "true"'
# on production or integration branch(es): auto & failing
- if: '$CI_COMMIT_REF_NAME =~ $PROD_REF || $CI_COMMIT_REF_NAME =~ $INTEG_REF'
# early stage (dev branch, no MR): manual & non-failing
- if: '$CI_MERGE_REQUEST_ID == null && $CI_OPEN_MERGE_REQUESTS == null'
when: manual
allow_failure: true
# Draft MR: auto & non-failing
- if: '$CI_MERGE_REQUEST_TITLE =~ /^Draft:.*/'
allow_failure: true
# else (Ready MR): auto & failing
- when: on_success
variables: variables:
# variabilized tracking image # variabilized tracking image
TBC_TRACKING_IMAGE: "$CI_REGISTRY/to-be-continuous/tools/tracking:master" TBC_TRACKING_IMAGE: "$CI_REGISTRY/to-be-continuous/tools/tracking:master"
...@@ -617,12 +636,7 @@ py-lint: ...@@ -617,12 +636,7 @@ py-lint:
# exclude if $PYLINT_ENABLED not set # exclude if $PYLINT_ENABLED not set
- if: '$PYLINT_ENABLED != "true"' - if: '$PYLINT_ENABLED != "true"'
when: never when: never
# on non-production, non-integration branches: manual & non-blocking - !reference [.test-policy, rules]
- if: '$CI_COMMIT_REF_NAME !~ $PROD_REF && $CI_COMMIT_REF_NAME !~ $INTEG_REF'
when: manual
allow_failure: true
# else: manual & non-blocking
- when: always
py-compile: py-compile:
extends: .python-base extends: .python-base
...@@ -631,8 +645,10 @@ py-compile: ...@@ -631,8 +645,10 @@ py-compile:
- install_requirements - install_requirements
- _python -m compileall $PYTHON_COMPILE_ARGS - _python -m compileall $PYTHON_COMPILE_ARGS
rules: rules:
# on any branch: only when none of supported unit test framework is enabled # skip when one of unit test framework is enabled
- if: '$UNITTEST_ENABLED != "true" && $PYTEST_ENABLED != "true" && $NOSETESTS_ENABLED != "true"' - if: '$UNITTEST_ENABLED == "true" || $PYTEST_ENABLED == "true" || $NOSETESTS_ENABLED == "true"'
when: never
- !reference [.test-policy, rules]
############################################################################################### ###############################################################################################
# test stage # # test stage #
...@@ -669,8 +685,10 @@ py-unittest: ...@@ -669,8 +685,10 @@ py-unittest:
paths: paths:
- $PYTHON_PROJECT_DIR/reports/ - $PYTHON_PROJECT_DIR/reports/
rules: rules:
# on any branch: when $UNITTEST_ENABLED is set # skip if $UNITTEST_ENABLED not set
- if: '$UNITTEST_ENABLED == "true"' - if: '$UNITTEST_ENABLED != "true"'
when: never
- !reference [.test-policy, rules]
py-pytest: py-pytest:
extends: .python-base extends: .python-base
...@@ -699,8 +717,10 @@ py-pytest: ...@@ -699,8 +717,10 @@ py-pytest:
paths: paths:
- $PYTHON_PROJECT_DIR/reports/ - $PYTHON_PROJECT_DIR/reports/
rules: rules:
# on any branch: when $PYTEST_ENABLED is set # skip if $PYTEST_ENABLED not set
- if: '$PYTEST_ENABLED == "true"' - if: '$PYTEST_ENABLED != "true"'
when: never
- !reference [.test-policy, rules]
py-nosetests: py-nosetests:
extends: .python-base extends: .python-base
...@@ -728,8 +748,10 @@ py-nosetests: ...@@ -728,8 +748,10 @@ py-nosetests:
paths: paths:
- $PYTHON_PROJECT_DIR/reports/ - $PYTHON_PROJECT_DIR/reports/
rules: rules:
# on any branch: when $NOSETESTS_ENABLED is set # skip if $NOSETESTS_ENABLED not set
- if: '$NOSETESTS_ENABLED == "true"' - if: '$NOSETESTS_ENABLED != "true"'
when: never
- !reference [.test-policy, rules]
# Bandit (SAST) # Bandit (SAST)
py-bandit: py-bandit:
...@@ -759,12 +781,7 @@ py-bandit: ...@@ -759,12 +781,7 @@ py-bandit:
# exclude if $BANDIT_ENABLED not set # exclude if $BANDIT_ENABLED not set
- if: '$BANDIT_ENABLED != "true"' - if: '$BANDIT_ENABLED != "true"'
when: never when: never
# on non-production, non-integration branches: manual & non-blocking - !reference [.test-policy, rules]
- if: '$CI_COMMIT_REF_NAME !~ $PROD_REF && $CI_COMMIT_REF_NAME !~ $INTEG_REF'
when: manual
allow_failure: true
# else: manual & non-blocking
- when: always
# Safety (dependency check) # Safety (dependency check)
py-safety: py-safety:
...@@ -795,12 +812,7 @@ py-safety: ...@@ -795,12 +812,7 @@ py-safety:
# exclude if $SAFETY_ENABLED not set # exclude if $SAFETY_ENABLED not set
- if: '$SAFETY_ENABLED != "true"' - if: '$SAFETY_ENABLED != "true"'
when: never when: never
# on non-production, non-integration branches: manual & non-blocking - !reference [.test-policy, rules]
- if: '$CI_COMMIT_REF_NAME !~ $PROD_REF && $CI_COMMIT_REF_NAME !~ $INTEG_REF'
when: manual
allow_failure: true
# else: manual & non-blocking
- when: always
# Trivy (dependency check) # Trivy (dependency check)
py-trivy: py-trivy:
...@@ -854,12 +866,7 @@ py-trivy: ...@@ -854,12 +866,7 @@ py-trivy:
# exclude if $PYTHON_TRIVY_ENABLED not set # exclude if $PYTHON_TRIVY_ENABLED not set
- if: '$PYTHON_TRIVY_ENABLED != "true"' - if: '$PYTHON_TRIVY_ENABLED != "true"'
when: never when: never
# on non-production, non-integration branches: manual & non-blocking - !reference [.test-policy, rules]
- if: '$CI_COMMIT_REF_NAME !~ $PROD_REF && $CI_COMMIT_REF_NAME !~ $INTEG_REF'
when: manual
allow_failure: true
# else: manual & non-blocking
- when: always
# (manual from master branch): triggers a release (tag creation) # (manual from master branch): triggers a release (tag creation)
py-release: py-release:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment