ci: Run style checks on merge requests

This commit is contained in:
Guido Günther
2023-11-14 17:26:07 +01:00
parent ba4576d490
commit 8020ccc65c
+38
View File
@@ -5,8 +5,18 @@ include:
stages:
- build
- test
- style-checks
- package
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
# Don't trigger a branch pipeline if there is an open MR
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH
.before_script: &before_script
before_script:
- export DEBIAN_FRONTEND=noninteractive
@@ -65,6 +75,34 @@ test:native-debian-trixie:
variables:
- $PKG_ONLY == "1"
format-check:
<<: *tags
<<: *image
before_script:
- export DEBIAN_FRONTEND=noninteractive
- apt-get -y update
- apt-get -y install uncrustify git python3
stage: style-checks
needs: []
script:
- |
if [ -n "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" ]; then
git remote add target $CI_MERGE_REQUEST_PROJECT_URL.git
echo "Fetching MR target branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME from $CI_MERGE_REQUEST_PROJECT_URL"
git fetch target "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"
git fetch --deepen=100 origin HEAD
merge_base=$(git merge-base "target/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" HEAD)
if [ -z "$merge_base" ]; then
echo "Could't determine merge base"
exit 1
fi
echo "Merge base: $merge_base"
./.gitlab-ci/check-style.py --dry-run --sha $merge_base
else
echo "Not a merge request"
fi
allow_failure: true
package:deb-debian-trixie:arm64:
variables:
L5_DOCKER_IMAGE: debian:trixie