ci: avoid always running build/test jobs

Introduce a trigger job with rules that will allow it to always
run when the MR is assigned to Marge and the final tests will be
run before being merge.

This means that Post-merge pipelines and MR pipelines that are
not assigned to Marge, will require a manual run of the trigger
job before the build/test will execute.

This should help easy the load on the gitlab runners.

Related to gstreamer/gstreamer-rs#417

Close gstreamer/gstreamer-rs#401

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1158>
This commit is contained in:
Jordan Petridis 2022-11-23 18:08:25 +02:00 committed by Sebastian Dröge
parent 40143109da
commit ae5f5b7b02

View file

@ -61,6 +61,7 @@ variables:
0.16=0.16
stages:
- "trigger"
- "container-base"
- "container-final"
- "lint"
@ -68,8 +69,29 @@ stages:
- "extras"
- "deploy"
# This is an empty job that is used to trigger the pipeline.
trigger:
image: alpine:latest
stage: 'trigger'
variables:
GIT_STRATEGY: none
script:
- echo "Trigger job done, now running the pipeline."
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
# If the MR is assigned to the Merge bot, trigger the pipeline automatically
- if: '$CI_MERGE_REQUEST_ASSIGNEES == "gstreamer-merge-bot"'
# Require explicit action to trigger tests post merge
- if: '$CI_PROJECT_NAMESPACE == "gstreamer" && $CI_COMMIT_BRANCH == "main"'
when: 'manual'
# When the assignee isn't the merge bot, require an explicit action to trigger the pipeline
# to avoid wasting CI resources
- if: '$CI_MERGE_REQUEST_ASSIGNEES != "gstreamer-merge-bot"'
when: 'manual'
allow_failure: false
.debian:11:
needs: []
variables:
FDO_DISTRIBUTION_VERSION: 'bullseye-slim'
before_script:
@ -267,6 +289,8 @@ test msrv:
- '.cargo test'
- .img-msrv
needs:
- job: 'trigger'
artifacts: false
- job: 'build-msrv'
artifacts: false
@ -275,6 +299,8 @@ test stable:
- '.cargo test'
- .img-stable
needs:
- job: 'trigger'
artifacts: false
- job: 'build-stable'
artifacts: false
@ -286,6 +312,8 @@ test stable all-features:
- '.cargo test'
- .img-stable
needs:
- job: 'trigger'
artifacts: false
- job: 'build-stable'
artifacts: false
@ -296,6 +324,8 @@ test nightly:
- '.cargo test'
- .img-nightly
needs:
- job: 'trigger'
artifacts: false
- job: 'build-nightly'
artifacts: false
@ -309,6 +339,8 @@ test nightly all-features:
- '.cargo test'
- .img-nightly
needs:
- job: 'trigger'
artifacts: false
- job: 'build-nightly'
artifacts: false
@ -368,6 +400,8 @@ test stable sys:
- '.cargo test sys'
- .img-stable
needs:
- job: 'trigger'
artifacts: false
- job: 'build-stable'
artifacts: false
@ -376,6 +410,8 @@ test msrv sys:
- '.cargo test sys'
- .img-msrv
needs:
- job: 'trigger'
artifacts: false
- job: 'build-msrv'
artifacts: false
@ -384,6 +420,8 @@ test nightly sys:
- '.cargo test sys'
- .img-nightly
needs:
- job: 'trigger'
artifacts: false
- job: 'build-nightly'
artifacts: false
@ -412,6 +450,8 @@ clippy:
variables:
CLIPPY_LINTS: -D warnings
needs:
- job: 'trigger'
artifacts: false
- job: 'build-stable'
artifacts: false
script:
@ -487,6 +527,8 @@ coverage:
- .img-stable
stage: 'extras'
needs:
- job: 'trigger'
artifacts: false
- job: 'build-stable'
artifacts: false
variables:
@ -590,6 +632,7 @@ pages:
.windows rust docker build:
stage: 'container-final'
needs: []
variables:
# Unlike the buildah/linux jobs, this file
# needs to be relative to windows-docker/ subdir
@ -662,12 +705,16 @@ windows rust docker msrv:
test windows msrv:
image: $WINDOWS_RUST_MINIMUM_IMAGE
needs:
- job: 'trigger'
artifacts: false
- job: 'windows rust docker msrv'
artifacts: false
extends: '.msvc2019 build'
test windows stable:
needs:
- job: 'trigger'
artifacts: false
- job: 'windows rust docker stable'
artifacts: false
image: "$WINDOWS_RUST_STABLE_IMAGE"