Consider using labels to trigger specific jobs to run
Currently, we're using the MR title to trigger specific jobs to run:
-
RUN ALL RSPEC
: https://docs.gitlab.com/ee/development/pipelines.html#test-jobs -
RUN AS-IF-FOSS
: https://docs.gitlab.com/ee/development/pipelines.html#as-if-foss-jobs -
UPDATE CACHE
: https://docs.gitlab.com/ee/development/pipelines.html#caching-strategy -
SKIP RSPEC FAIL-FAST
: https://docs.gitlab.com/ee/development/pipelines.html#fail-fast-pipeline-in-merge-requests
This is a problem now that the squashing feature uses the MR title as the squash commit by default, as this results in master
pipelines that run more jobs than needed in some cases, e.g. if the commit looks as follows:
commit 3aa9c4750473fb07b682d305de73a468d831fa1d
Author: Jiaan Louw <3468028-jiaan@users.noreply.gitlab.com>
Date: Tue May 11 11:08:27 2021 +0000
Add total group count to admin users table [RUN ALL RSPEC] [RUN AS-IF-FOSS]
Instead of using the MR title, we could use specific labels since those are exposed in the Predefined variables for MR pipelines as CI_MERGE_REQUEST_LABELS
.
Labels proposal
-
RUN ALL RSPEC
=> ~"ci:run-all-rspec" -
RUN AS-IF-FOSS
=> ~"ci:run-as-if-foss" -
UPDATE CACHE
=> ~"ci:update-cache" -
SKIP RSPEC FAIL-FAST
=> ~"ci:skip-rspec-fail-fast"
We'll need to implement a Danger check to correct titles that use the legacy tags and potentially add the labels instead and remove the tags from the title.
Scenarios
Title translation to labels scenarios
Scenario | Expected results |
---|---|
New MR created with RUN ALL RSPEC in the title |
First pipeline would behaviour in accordance with the title phrase |
Existing MR updated to include RUN ALL RSPEC in the title |
Subsequent pipelines would behaviour in accordance with the title flag |
Labels added scenarios
Scenario | Expected results |
---|---|
New MR created with pipeline:run-all-rspec label |
First pipeline would behaviour in accordance with the applied label |
Existing MR updated to have pipeline:run-all-rspec label applied |
Subsequent pipelines would behaviour in accordance with the applied label |
Edited by Mark Fletcher