mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 15:40:41 -05:00
gitlab-ci.yml: Add check for issue or MR URL
This adds a pipeline stage for merge requests that checks that the commit message contains an URL to either a issue or a merge request. This means that for merge requests without corresponding issues will always fail initially, as the merge request URL is not known until after it is created. This is still arguably better than accidentally merging merge requests without URLs. https://gitlab.gnome.org/GNOME/mutter/merge_requests/440
This commit is contained in:
parent
f3dd97e67b
commit
b70c0eb9a5
@ -1,9 +1,17 @@
|
|||||||
image: registry.gitlab.gnome.org/gnome/mutter/master:v1
|
image: registry.gitlab.gnome.org/gnome/mutter/master:v1
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
|
- review
|
||||||
- build
|
- build
|
||||||
- test
|
- test
|
||||||
|
|
||||||
|
check-commit-log:
|
||||||
|
stage: review
|
||||||
|
script:
|
||||||
|
- ./.gitlab-ci/check-commit-log.sh
|
||||||
|
only:
|
||||||
|
- merge_requests
|
||||||
|
|
||||||
build-mutter:
|
build-mutter:
|
||||||
stage: build
|
stage: build
|
||||||
script:
|
script:
|
||||||
@ -14,6 +22,9 @@ build-mutter:
|
|||||||
expire_in: 1 day
|
expire_in: 1 day
|
||||||
paths:
|
paths:
|
||||||
- build
|
- build
|
||||||
|
only:
|
||||||
|
- merge_requests
|
||||||
|
- /^.*$/
|
||||||
|
|
||||||
test-mutter:
|
test-mutter:
|
||||||
stage: test
|
stage: test
|
||||||
@ -28,3 +39,6 @@ test-mutter:
|
|||||||
- >
|
- >
|
||||||
dbus-run-session -- xvfb-run -s '+iglx -noreset'
|
dbus-run-session -- xvfb-run -s '+iglx -noreset'
|
||||||
meson test -C build --no-rebuild -t 10 --verbose --no-stdsplit --wrap catchsegv
|
meson test -C build --no-rebuild -t 10 --verbose --no-stdsplit --wrap catchsegv
|
||||||
|
only:
|
||||||
|
- merge_requests
|
||||||
|
- /^.*$/
|
||||||
|
31
.gitlab-ci/check-commit-log.sh
Executable file
31
.gitlab-ci/check-commit-log.sh
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if [ -z "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" ]; then
|
||||||
|
echo Cannot review non-merge request
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
git fetch $CI_MERGE_REQUEST_PROJECT_URL.git $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
|
||||||
|
|
||||||
|
branch_point=$(git merge-base HEAD FETCH_HEAD)
|
||||||
|
|
||||||
|
commits=$(git log --format='format:%H' $branch_point..$CI_COMMIT_SHA)
|
||||||
|
|
||||||
|
if [ -z "$commits" ]; then
|
||||||
|
echo Commit range empty
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
function commit_message_has_url() {
|
||||||
|
commit=$1
|
||||||
|
commit_message=$(git show -s --format='format:%b' $commit)
|
||||||
|
echo "$commit_message" | grep -qe "\($CI_MERGE_REQUEST_PROJECT_URL/\(issues\|merge_requests\)/[0-9]\+\|https://bugzilla.gnome.org/show_bug.cgi?id=[0-9]\+\)"
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
|
for commit in $commits; do
|
||||||
|
if ! commit_message_has_url $commit; then
|
||||||
|
echo "Missing merge request or issue URL on commit $(echo $commit | cut -c -8)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
Loading…
Reference in New Issue
Block a user