From d5724bfdefc5c4bf6a234d96f0ed02198c82c800 Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Sat, 12 Apr 2025 21:13:19 +0200 Subject: [PATCH] CI: Immediately fail if WIP commits pushed to a stable branch --- .gitlab-ci.yml | 16 +++++++++++++++- tools/git-check-commits | 19 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100755 tools/git-check-commits diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 807cfd14c..509dc0954 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -13,6 +13,7 @@ variables: STAYRTR_BINARY: /usr/bin/stayrtr stages: + - consistency - image - build - pkg @@ -20,10 +21,23 @@ stages: - release ## Common rules +# Ignore WIP commits .never_wip: &never_wip - # Ignore WIP commits if: $CI_COMMIT_MESSAGE =~ /^(fixup! )*WIP/ when: never +# Run for stable branches +.if_stable: &if_stable + if: $CI_COMMIT_BRANCH =~ /^(stable-.*|thread-next|master)$/ + when: always + +## Consistency checks for stable branches +commit-messages: + stage: consistency + script: + - tools/git-check-commits + rules: + - *if_stable + - when: never ## Docker Image Rules # diff --git a/tools/git-check-commits b/tools/git-check-commits new file mode 100755 index 000000000..65661e132 --- /dev/null +++ b/tools/git-check-commits @@ -0,0 +1,19 @@ +#!/bin/sh + +git log --oneline | awk \ + '{ + # Ignore two fixups deeply buried inside the history + if (index("a54f75f454b7ed8c8ff2c1787a506528f22cbae7", $1) == 1) + next; + if (index("bea582cbb53e30dd32a5b6829c7443e0e5558d11", $1) == 1) + next; + + # Complain about fixups and WIPs + if ((index($2, "fixup!") == 1) || (index($2, "WIP") == 1)) + { + if (!bad) print "Branch contains unfinished work!" + bad = 1 + print + } + } + END { if (bad) exit 1 }' -- 2.47.3