diff options
author | Daniel P. Berrangé <berrange@redhat.com> | 2024-03-21 09:43:33 +0000 |
---|---|---|
committer | Daniel P. Berrangé <berrange@redhat.com> | 2024-03-22 09:41:26 +0000 |
commit | bcc5534d0cc186d804137a0fb1eebedda26e722a (patch) | |
tree | be55e5a8e101128dde61bd97b9c728151adffd58 | |
parent | 7a9396a0a74b2df3b6d980011a0055369bfc6001 (diff) | |
download | libvirt-ci-bcc5534d0cc186d804137a0fb1eebedda26e722a.zip libvirt-ci-bcc5534d0cc186d804137a0fb1eebedda26e722a.tar.gz libvirt-ci-bcc5534d0cc186d804137a0fb1eebedda26e722a.tar.bz2 |
lcitool: fix running jobs when there are CI changes present
If using a 'when: never' clause, evaluation of any following rules is
skipped. We attempted to use 'when: never' to skip running merge
request pipelines with pre-built containers, when there are CI changes
present. Unfortunately evaluation will not carry on and catch the rule
that runs CI with one-off built containers.
There is no way to invert the meaning of a 'changes:' clause, so the
only way to achieve what we want is to re-arrange the rules, so that
we can avoid use of 'when: never'.
The current grouping of rules is based on use of pre-built containers
vs one-off built containers. This is proving hard to analyse as the
rules for 'push' events are far apart from each other.
This changes the grouping to be based on the event type, so everything
that is conceptually related to the same event as in one place. With
this grouping, we simply put rules with filename matches first, and
get the desired ordering semantics.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
-rw-r--r-- | lcitool/gitlab.py | 81 | ||||
-rw-r--r-- | tests/data/manifest/out/ci/gitlab/build-templates.yml | 162 |
2 files changed, 120 insertions, 123 deletions
diff --git a/lcitool/gitlab.py b/lcitool/gitlab.py index d055801..277ac12 100644 --- a/lcitool/gitlab.py +++ b/lcitool/gitlab.py @@ -211,7 +211,7 @@ def _build_template(template, envid, project, cidir): variables: IMAGE: $CI_REGISTRY/$RUN_UPSTREAM_NAMESPACE/{project}/ci-{envid}:latest rules: - ### Rules where we expect to use pre-built container images + ### PUSH events # upstream: pushes to the default branch - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' @@ -227,90 +227,89 @@ def _build_template(template, envid, project, cidir): - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $RUN_PIPELINE_UPSTREAM_ENV' when: on_success - # upstream: other web/api/scheduled pipelines targeting the default branch - - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' + # forks: pushes to branches with pipeline requested + - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $RUN_PIPELINE && $JOB_OPTIONAL' when: manual allow_failure: true - - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH' + variables: + IMAGE: $TARGET_BASE_IMAGE + - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $RUN_PIPELINE' when: on_success + variables: + IMAGE: $TARGET_BASE_IMAGE - # upstream+forks: merge requests targeting the default branch, without CI changes - - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH' + + ### MERGE REQUEST events + + # upstream+forks: merge requests targeting the default branch, with CI changes + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' changes: - {cidir}/gitlab/container-templates.yml - {cidir}/containers/{envid}.Dockerfile - when: never - - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' when: manual allow_failure: true + variables: + IMAGE: $TARGET_BASE_IMAGE - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH' + changes: + - {cidir}/gitlab/container-templates.yml + - {cidir}/containers/{envid}.Dockerfile when: on_success + variables: + IMAGE: $TARGET_BASE_IMAGE - - ### Rules where we need to use the target base container image - - # forks: pushes to branches with pipeline requested - - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $RUN_PIPELINE && $JOB_OPTIONAL' + # upstream+forks: merge requests targeting the default branch + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' when: manual allow_failure: true - variables: - IMAGE: $TARGET_BASE_IMAGE - - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $RUN_PIPELINE' + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH' when: on_success - variables: - IMAGE: $TARGET_BASE_IMAGE - # upstream: other web/api/scheduled pipelines targeting non-default branches - - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' + # upstream+forks: merge requests targeting non-default branches + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' when: manual allow_failure: true variables: IMAGE: $TARGET_BASE_IMAGE - - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH' + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != $CI_DEFAULT_BRANCH' when: on_success variables: IMAGE: $TARGET_BASE_IMAGE - # forks: other web/api/scheduled pipelines - - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $JOB_OPTIONAL' + + ### WEB / API / SCHEDULED events + + # upstream: other web/api/scheduled pipelines targeting the default branch + - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' when: manual allow_failure: true - variables: - IMAGE: $TARGET_BASE_IMAGE - - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/' + - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH' when: on_success - variables: - IMAGE: $TARGET_BASE_IMAGE - # upstream+forks: merge requests targeting the default branch, with CI changes - - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' - changes: - - {cidir}/gitlab/container-templates.yml - - {cidir}/containers/{envid}.Dockerfile + # upstream: other web/api/scheduled pipelines targeting non-default branches + - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' when: manual allow_failure: true variables: IMAGE: $TARGET_BASE_IMAGE - - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH' - changes: - - {cidir}/gitlab/container-templates.yml - - {cidir}/containers/{envid}.Dockerfile + - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH' when: on_success variables: IMAGE: $TARGET_BASE_IMAGE - # upstream+forks: merge requests targeting non-default branches - - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' + # forks: other web/api/scheduled pipelines on any branches + - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $JOB_OPTIONAL' when: manual allow_failure: true variables: IMAGE: $TARGET_BASE_IMAGE - - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != $CI_DEFAULT_BRANCH' + - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/' when: on_success variables: IMAGE: $TARGET_BASE_IMAGE - ### Neither prebuilt or local container images + + ### Catch all unhandled events # upstream+forks: that's all folks - when: never diff --git a/tests/data/manifest/out/ci/gitlab/build-templates.yml b/tests/data/manifest/out/ci/gitlab/build-templates.yml index 6505348..0b3eeb4 100644 --- a/tests/data/manifest/out/ci/gitlab/build-templates.yml +++ b/tests/data/manifest/out/ci/gitlab/build-templates.yml @@ -30,7 +30,7 @@ variables: IMAGE: $CI_REGISTRY/$RUN_UPSTREAM_NAMESPACE/libvirt-go-xml-module/ci-$NAME:latest rules: - ### Rules where we expect to use pre-built container images + ### PUSH events # upstream: pushes to the default branch - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' @@ -46,90 +46,89 @@ - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $RUN_PIPELINE_UPSTREAM_ENV' when: on_success - # upstream: other web/api/scheduled pipelines targeting the default branch - - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' + # forks: pushes to branches with pipeline requested + - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $RUN_PIPELINE && $JOB_OPTIONAL' when: manual allow_failure: true - - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH' + variables: + IMAGE: $TARGET_BASE_IMAGE + - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $RUN_PIPELINE' when: on_success + variables: + IMAGE: $TARGET_BASE_IMAGE - # upstream+forks: merge requests targeting the default branch, without CI changes - - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH' + + ### MERGE REQUEST events + + # upstream+forks: merge requests targeting the default branch, with CI changes + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' changes: - ci/gitlab/container-templates.yml - ci/containers/$NAME.Dockerfile - when: never - - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' when: manual allow_failure: true + variables: + IMAGE: $TARGET_BASE_IMAGE - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH' + changes: + - ci/gitlab/container-templates.yml + - ci/containers/$NAME.Dockerfile when: on_success + variables: + IMAGE: $TARGET_BASE_IMAGE - - ### Rules where we need to use the target base container image - - # forks: pushes to branches with pipeline requested - - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $RUN_PIPELINE && $JOB_OPTIONAL' + # upstream+forks: merge requests targeting the default branch + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' when: manual allow_failure: true - variables: - IMAGE: $TARGET_BASE_IMAGE - - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $RUN_PIPELINE' + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH' when: on_success - variables: - IMAGE: $TARGET_BASE_IMAGE - # upstream: other web/api/scheduled pipelines targeting non-default branches - - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' + # upstream+forks: merge requests targeting non-default branches + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' when: manual allow_failure: true variables: IMAGE: $TARGET_BASE_IMAGE - - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH' + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != $CI_DEFAULT_BRANCH' when: on_success variables: IMAGE: $TARGET_BASE_IMAGE - # forks: other web/api/scheduled pipelines - - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $JOB_OPTIONAL' + + ### WEB / API / SCHEDULED events + + # upstream: other web/api/scheduled pipelines targeting the default branch + - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' when: manual allow_failure: true - variables: - IMAGE: $TARGET_BASE_IMAGE - - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/' + - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH' when: on_success - variables: - IMAGE: $TARGET_BASE_IMAGE - # upstream+forks: merge requests targeting the default branch, with CI changes - - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' - changes: - - ci/gitlab/container-templates.yml - - ci/containers/$NAME.Dockerfile + # upstream: other web/api/scheduled pipelines targeting non-default branches + - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' when: manual allow_failure: true variables: IMAGE: $TARGET_BASE_IMAGE - - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH' - changes: - - ci/gitlab/container-templates.yml - - ci/containers/$NAME.Dockerfile + - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH' when: on_success variables: IMAGE: $TARGET_BASE_IMAGE - # upstream+forks: merge requests targeting non-default branches - - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' + # forks: other web/api/scheduled pipelines on any branches + - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $JOB_OPTIONAL' when: manual allow_failure: true variables: IMAGE: $TARGET_BASE_IMAGE - - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != $CI_DEFAULT_BRANCH' + - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/' when: on_success variables: IMAGE: $TARGET_BASE_IMAGE - ### Neither prebuilt or local container images + + ### Catch all unhandled events # upstream+forks: that's all folks - when: never @@ -167,7 +166,7 @@ variables: IMAGE: $CI_REGISTRY/$RUN_UPSTREAM_NAMESPACE/libvirt-go-xml-module/ci-$NAME-cross-$CROSS:latest rules: - ### Rules where we expect to use pre-built container images + ### PUSH events # upstream: pushes to the default branch - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' @@ -183,90 +182,89 @@ - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $RUN_PIPELINE_UPSTREAM_ENV' when: on_success - # upstream: other web/api/scheduled pipelines targeting the default branch - - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' + # forks: pushes to branches with pipeline requested + - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $RUN_PIPELINE && $JOB_OPTIONAL' when: manual allow_failure: true - - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH' + variables: + IMAGE: $TARGET_BASE_IMAGE + - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $RUN_PIPELINE' when: on_success + variables: + IMAGE: $TARGET_BASE_IMAGE - # upstream+forks: merge requests targeting the default branch, without CI changes - - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH' + + ### MERGE REQUEST events + + # upstream+forks: merge requests targeting the default branch, with CI changes + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' changes: - ci/gitlab/container-templates.yml - ci/containers/$NAME-cross-$CROSS.Dockerfile - when: never - - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' when: manual allow_failure: true + variables: + IMAGE: $TARGET_BASE_IMAGE - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH' + changes: + - ci/gitlab/container-templates.yml + - ci/containers/$NAME-cross-$CROSS.Dockerfile when: on_success + variables: + IMAGE: $TARGET_BASE_IMAGE - - ### Rules where we need to use the target base container image - - # forks: pushes to branches with pipeline requested - - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $RUN_PIPELINE && $JOB_OPTIONAL' + # upstream+forks: merge requests targeting the default branch + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' when: manual allow_failure: true - variables: - IMAGE: $TARGET_BASE_IMAGE - - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $RUN_PIPELINE' + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH' when: on_success - variables: - IMAGE: $TARGET_BASE_IMAGE - # upstream: other web/api/scheduled pipelines targeting non-default branches - - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' + # upstream+forks: merge requests targeting non-default branches + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' when: manual allow_failure: true variables: IMAGE: $TARGET_BASE_IMAGE - - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH' + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != $CI_DEFAULT_BRANCH' when: on_success variables: IMAGE: $TARGET_BASE_IMAGE - # forks: other web/api/scheduled pipelines - - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $JOB_OPTIONAL' + + ### WEB / API / SCHEDULED events + + # upstream: other web/api/scheduled pipelines targeting the default branch + - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' when: manual allow_failure: true - variables: - IMAGE: $TARGET_BASE_IMAGE - - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/' + - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH' when: on_success - variables: - IMAGE: $TARGET_BASE_IMAGE - # upstream+forks: merge requests targeting the default branch, with CI changes - - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' - changes: - - ci/gitlab/container-templates.yml - - ci/containers/$NAME-cross-$CROSS.Dockerfile + # upstream: other web/api/scheduled pipelines targeting non-default branches + - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' when: manual allow_failure: true variables: IMAGE: $TARGET_BASE_IMAGE - - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH' - changes: - - ci/gitlab/container-templates.yml - - ci/containers/$NAME-cross-$CROSS.Dockerfile + - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH' when: on_success variables: IMAGE: $TARGET_BASE_IMAGE - # upstream+forks: merge requests targeting non-default branches - - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != $CI_DEFAULT_BRANCH && $JOB_OPTIONAL' + # forks: other web/api/scheduled pipelines on any branches + - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $JOB_OPTIONAL' when: manual allow_failure: true variables: IMAGE: $TARGET_BASE_IMAGE - - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != $CI_DEFAULT_BRANCH' + - if: '$CI_PROJECT_NAMESPACE != $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/' when: on_success variables: IMAGE: $TARGET_BASE_IMAGE - ### Neither prebuilt or local container images + + ### Catch all unhandled events # upstream+forks: that's all folks - when: never |