ci: Perform MR-checks only in MR-branches only

This avoids even starting some jobs that we don't require

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3024>
This commit is contained in:
Marco Trevisan (Treviño) 2023-05-29 11:27:38 +02:00
parent b0f35cca4d
commit 1d766dfbed

View File

@ -209,6 +209,13 @@ workflow:
- if: '$CI_COMMIT_BRANCH' - if: '$CI_COMMIT_BRANCH'
when: 'manual' when: 'manual'
.only-merge-requests:
rules:
- if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ /^$/'
when: never
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
when: always
check-commit-log: check-commit-log:
extends: extends:
- .fdo.ci-fairy - .fdo.ci-fairy
@ -216,12 +223,7 @@ check-commit-log:
variables: variables:
GIT_DEPTH: "100" GIT_DEPTH: "100"
script: script:
- if [[ x"$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" != "x" ]] ; ci-fairy check-commits --junit-xml=commit-message-junit-report.xml
then
ci-fairy check-commits --junit-xml=commit-message-junit-report.xml ;
else
echo "Not a merge request" ;
fi
artifacts: artifacts:
expire_in: 1 week expire_in: 1 week
paths: paths:
@ -229,7 +231,7 @@ check-commit-log:
reports: reports:
junit: commit-message-junit-report.xml junit: commit-message-junit-report.xml
rules: rules:
- !reference [.pipeline-guard, rules] - !reference [.only-merge-requests, rules]
check-merge-request: check-merge-request:
extends: extends:
@ -237,12 +239,7 @@ check-merge-request:
- .skip-git-clone - .skip-git-clone
stage: review stage: review
script: script:
- if [[ x"$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" != "x" ]] ; ci-fairy check-merge-request --require-allow-collaboration --junit-xml=check-merge-request-report.xml
then
ci-fairy check-merge-request --require-allow-collaboration --junit-xml=check-merge-request-report.xml ;
else
echo "Not a merge request" ;
fi
artifacts: artifacts:
expire_in: 1 week expire_in: 1 week
paths: paths:
@ -250,7 +247,7 @@ check-merge-request:
reports: reports:
junit: check-merge-request-report.xml junit: check-merge-request-report.xml
rules: rules:
- !reference [.pipeline-guard, rules] - !reference [.only-merge-requests, rules]
build-fedora-container@x86_64: build-fedora-container@x86_64:
extends: extends:
@ -258,9 +255,8 @@ build-fedora-container@x86_64:
- .mutter.fedora@x86_64 - .mutter.fedora@x86_64
- .mutter.skip-git-clone - .mutter.skip-git-clone
stage: prepare stage: prepare
needs: rules:
- check-commit-log - !reference [.pipeline-guard, rules]
- check-merge-request
build-fedora-container@aarch64: build-fedora-container@aarch64:
extends: extends:
@ -268,9 +264,8 @@ build-fedora-container@aarch64:
- .mutter.fedora@aarch64 - .mutter.fedora@aarch64
- .mutter.skip-git-clone - .mutter.skip-git-clone
stage: prepare stage: prepare
needs: rules:
- check-commit-log - !reference [.pipeline-guard, rules]
- check-merge-request
check-code-style: check-code-style:
extends: extends:
@ -282,16 +277,13 @@ check-code-style:
needs: needs:
- build-fedora-container@x86_64 - build-fedora-container@x86_64
script: script:
- if [[ x"$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" != "x" ]] ; git remote add target $CI_MERGE_REQUEST_PROJECT_URL.git ;
then git fetch target $CI_MERGE_REQUEST_TARGET_BRANCH_NAME ;
git remote add target $CI_MERGE_REQUEST_PROJECT_URL.git ; export common_parent_sha=$(diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent "target/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME") <(git rev-list --first-parent HEAD) | head -1) ;
git fetch target $CI_MERGE_REQUEST_TARGET_BRANCH_NAME ; python3 -u ./check-style.py --dry-run --sha $common_parent_sha ;
export common_parent_sha=$(diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent "target/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME") <(git rev-list --first-parent HEAD) | head -1) ;
python3 -u ./check-style.py --dry-run --sha $common_parent_sha ;
else
echo "Not a merge request" ;
fi
allow_failure: true allow_failure: true
rules:
- !reference [.only-merge-requests, rules]
.build-mutter-base: .build-mutter-base:
variables: variables: