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/1155>
This commit is contained in:
Jordan Petridis 2022-11-23 18:08:25 +02:00
parent 3da927a856
commit e87de384e1

View file

@ -60,6 +60,7 @@ variables:
0.18=0.18 0.18=0.18
stages: stages:
- "trigger"
- "container-base" - "container-base"
- "container-final" - "container-final"
- "lint" - "lint"
@ -67,8 +68,29 @@ stages:
- "extras" - "extras"
- "deploy" - "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: .debian:11:
needs: []
variables: variables:
FDO_DISTRIBUTION_VERSION: 'bullseye-slim' FDO_DISTRIBUTION_VERSION: 'bullseye-slim'
before_script: before_script:
@ -273,6 +295,8 @@ test msrv:
- '.cargo test' - '.cargo test'
- .img-msrv - .img-msrv
needs: needs:
- job: 'trigger'
artifacts: false
- job: 'build-msrv' - job: 'build-msrv'
artifacts: false artifacts: false
@ -281,6 +305,8 @@ test stable:
- '.cargo test' - '.cargo test'
- .img-stable - .img-stable
needs: needs:
- job: 'trigger'
artifacts: false
- job: 'build-stable' - job: 'build-stable'
artifacts: false artifacts: false
@ -292,6 +318,8 @@ test stable all-features:
- '.cargo test' - '.cargo test'
- .img-stable - .img-stable
needs: needs:
- job: 'trigger'
artifacts: false
- job: 'build-stable' - job: 'build-stable'
artifacts: false artifacts: false
@ -302,6 +330,8 @@ test nightly:
- '.cargo test' - '.cargo test'
- .img-nightly - .img-nightly
needs: needs:
- job: 'trigger'
artifacts: false
- job: 'build-nightly' - job: 'build-nightly'
artifacts: false artifacts: false
@ -315,6 +345,8 @@ test nightly all-features:
- '.cargo test' - '.cargo test'
- .img-nightly - .img-nightly
needs: needs:
- job: 'trigger'
artifacts: false
- job: 'build-nightly' - job: 'build-nightly'
artifacts: false artifacts: false
@ -374,6 +406,8 @@ test stable sys:
- '.cargo test sys' - '.cargo test sys'
- .img-stable - .img-stable
needs: needs:
- job: 'trigger'
artifacts: false
- job: 'build-stable' - job: 'build-stable'
artifacts: false artifacts: false
@ -382,6 +416,8 @@ test msrv sys:
- '.cargo test sys' - '.cargo test sys'
- .img-msrv - .img-msrv
needs: needs:
- job: 'trigger'
artifacts: false
- job: 'build-msrv' - job: 'build-msrv'
artifacts: false artifacts: false
@ -390,6 +426,8 @@ test nightly sys:
- '.cargo test sys' - '.cargo test sys'
- .img-nightly - .img-nightly
needs: needs:
- job: 'trigger'
artifacts: false
- job: 'build-nightly' - job: 'build-nightly'
artifacts: false artifacts: false
@ -418,6 +456,8 @@ clippy:
variables: variables:
CLIPPY_LINTS: -D warnings -W unknown-lints CLIPPY_LINTS: -D warnings -W unknown-lints
needs: needs:
- job: 'trigger'
artifacts: false
- job: 'build-stable' - job: 'build-stable'
artifacts: false artifacts: false
script: script:
@ -493,6 +533,8 @@ coverage:
- .img-stable - .img-stable
stage: 'extras' stage: 'extras'
needs: needs:
- job: 'trigger'
artifacts: false
- job: 'build-stable' - job: 'build-stable'
artifacts: false artifacts: false
variables: variables:
@ -596,6 +638,7 @@ pages:
.windows rust docker build: .windows rust docker build:
stage: 'container-final' stage: 'container-final'
needs: []
variables: variables:
# Unlike the buildah/linux jobs, this file # Unlike the buildah/linux jobs, this file
# needs to be relative to windows-docker/ subdir # needs to be relative to windows-docker/ subdir
@ -668,12 +711,16 @@ windows rust docker msrv:
test windows msrv: test windows msrv:
image: $WINDOWS_RUST_MINIMUM_IMAGE image: $WINDOWS_RUST_MINIMUM_IMAGE
needs: needs:
- job: 'trigger'
artifacts: false
- job: 'windows rust docker msrv' - job: 'windows rust docker msrv'
artifacts: false artifacts: false
extends: '.msvc2019 build' extends: '.msvc2019 build'
test windows stable: test windows stable:
needs: needs:
- job: 'trigger'
artifacts: false
- job: 'windows rust docker stable' - job: 'windows rust docker stable'
artifacts: false artifacts: false
image: "$WINDOWS_RUST_STABLE_IMAGE" image: "$WINDOWS_RUST_STABLE_IMAGE"