gitlab-ci: Run merge request pipelines automatically only for Marge Bot

MR pipelines not triggered by Marge Bot can still be triggered manually.

Motivation: The main & forked Mesa project CI pipelines combined are
currently generating over 1 TB of egress traffic per week. ~80% of this
is from pre-merge pipelines. Assuming this corresponds to 4 pre-merge
and one post-merge pipeline per MR on average, this change could
potentially eliminate up to ~60% of the overall traffic (by preventing
3 of the 4 pre-merge pipelines from running automatically).

(Of course, this could be subverted if all jobs of the other pipelines
were triggered manually anyway... In most cases, manually triggering
just a few jobs should suffice)

v2:
* $GITLAB_USER_NAME was the wrong variable, $GITLAB_USER_LOGIN should
  do the trick.

Suggested-by: Marek Olšák <maraeo@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4432>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4432>
This commit is contained in:
Michel Dänzer 2020-04-03 11:46:12 +02:00 committed by Marge Bot
parent 42fe600c0c
commit 4176dfa880

View File

@ -100,9 +100,9 @@ success:
extends:
- .ci-run-policy
rules:
# Run pipeline by default if it is for a merge request and any files
# affecting it were changed
- if: '$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == $CI_COMMIT_REF_NAME'
# Run pipeline by default if it was triggered by Marge Bot, is for a
# merge request, and any files affecting it were changed
- if: '$GITLAB_USER_LOGIN == "marge-bot" && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == $CI_COMMIT_REF_NAME'
changes:
*all_paths
when: on_success
@ -112,9 +112,9 @@ success:
changes:
*all_paths
when: on_success
# Allow triggering jobs manually for branches of forked projects
- if: '$CI_PROJECT_PATH != "mesa/mesa" && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME != $CI_COMMIT_REF_NAME'
changes:
# Allow triggering jobs manually for MRs or branches of forked projects if
# any files affecting the pipeline were changed
- changes:
*all_paths
when: manual
# Otherwise, container jobs won't run