]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
CI: Immediately fail if WIP commits pushed to a stable branch
authorMaria Matejka <mq@ucw.cz>
Sat, 12 Apr 2025 19:13:19 +0000 (21:13 +0200)
committerMaria Matejka <mq@ucw.cz>
Tue, 29 Apr 2025 18:04:32 +0000 (20:04 +0200)
.gitlab-ci.yml
tools/git-check-commits [new file with mode: 0755]

index 807cfd14cbe32b12180ab04b8e25602218f37276..509dc0954e3d04f927b2c38570b60db7d614e674 100644 (file)
@@ -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 (executable)
index 0000000..65661e1
--- /dev/null
@@ -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 }'