]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add genmod and cvar spelling into CI/CD tests
authorDr. Jaska <drjaska83@gmail.com>
Wed, 15 Jan 2025 07:22:46 +0000 (07:22 +0000)
committerDr. Jaska <drjaska83@gmail.com>
Wed, 15 Jan 2025 07:22:46 +0000 (07:22 +0000)
.gitignore
.gitlab-ci.yml
Makefile
qcsrc/Makefile
qcsrc/tools/cvar-standardize.sh [changed mode: 0644->0755]
qcsrc/tools/scripts-diff-test-wrapper.sh [new file with mode: 0755]

index 83f1c3c65d7185f691d88a7508e99de66ea047db..d9c58546d731b50ecb12bcc797d57a900b9ef897 100644 (file)
@@ -6,7 +6,10 @@ cscope*
 .idea/
 Thumbs.db
 
-# sv_game hashtest local test re-use
+# CI/CD pipeline files
+gmqcc
+data/xonotic-data.pk3dir
+## sv_game hashtest local test re-use
 data/maps/
 data/maps/_init.bsp
 data/stormkeep.pk3
index 81a98fa726d027248dc8ab60980dab69db86e279..b45e9f27bed26ef1a8cbdabc9729d4b89c331d0c 100644 (file)
@@ -31,7 +31,16 @@ test_compilation_units:
       - qcsrc/**/*
   stage: test
   script:
-    - make test
+    - >
+      if ! make test-diff ; then
+        printf "\e[31m %s \e[0m\n" "Previous script in the pipeline produced a change."
+        printf "\e[31m %s \e[0m\n" "This is treated as a test failure."
+        printf "\e[31m %s \e[0m\n" "Please run 'make test-diff' locally"
+        printf "\e[31m %s \e[0m\n" "and address the changes somehow in a commit."
+        exit 1
+      fi
+
+    - make test-comp
 
 test_sv_game:
   stage: test
index f7bc68e49fdf26a0b667837f481f6300d3965ef8..4040d6d2a9c6c83308cfbe24e96e6b89c564f87b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -38,9 +38,8 @@ sv:
 pk3:
        $(MAKE) -C qcsrc pk3
 
+DIFFTESTS = test-genmod test-cvar-spelling
 COMPTESTS = test-server test-client test-menu
-.PHONY: test $(COMPTESTS)
-test:
-       $(MAKE) -C qcsrc test
-$(COMPTESTS):
+.PHONY: test test-diff $(DIFFTESTS) test-comp $(COMPTESTS)
+test test-diff $(DIFFTESTS) test-comp $(COMPTESTS):
        $(MAKE) -C qcsrc $@
index ae9a8e61c02d358780b3afcfe2cabbc99d4a3438..4994469c195f188a6200fc0f76b763f1da34bb08 100644 (file)
@@ -59,9 +59,21 @@ pk3: csprogs-$(VER).pk3
 
 
 
+DIFFTESTS = test-genmod test-cvar-spelling
 COMPTESTS = test-server test-client test-menu
-.PHONY: test $(COMPTESTS)
-test: $(COMPTESTS)
+.PHONY: test test-diff $(DIFFTESTS) test-comp $(COMPTESTS)
+
+test: $(DIFFTESTS) $(COMPTESTS)
+
+test-diff: test-genmod test-cvar-spelling
+test-genmod:
+       tools/scripts-diff-test-wrapper.sh genmod.sh
+test-cvar-spelling:
+       tools/scripts-diff-test-wrapper.sh cvar-standardize.sh
+
+.NOTPARALLEL: $(DIFFTESTS)
+
+test-comp: $(COMPTESTS)
 $(COMPTESTS):
        tools/compilationunits.sh $@
 
old mode 100644 (file)
new mode 100755 (executable)
index 78dedb1..e742070
@@ -122,3 +122,7 @@ function check() {
 
 check .
 
+if [ -n "$(git diff)" ]
+then
+       echo "$0: Changes produced, please commit or ignore with ' // script-ignore [reason]'"
+fi
diff --git a/qcsrc/tools/scripts-diff-test-wrapper.sh b/qcsrc/tools/scripts-diff-test-wrapper.sh
new file mode 100755 (executable)
index 0000000..934328f
--- /dev/null
@@ -0,0 +1,76 @@
+#!/bin/sh
+
+set -eu
+
+
+# This script is a wrapper for running other scripts to test whether
+# or not they produce a change, such as a file modification,
+# creation, or deletion.
+#
+# In order to test it accurately this # script should not be
+# ran with uncommitted changes.
+#
+# In the case that there are changes produced this wrapper script
+# mentions that there has been a change and exits with an error.
+#
+# Any of the potential changes are left in the git index so that
+# if this script is run in a developer setup they can easily see
+# the changes and commit them or address them without the need
+# to re-run any scripts.
+#
+# This script is also intended for GitLab CI/CD pipelines so that
+# we're able to have tests which track the output of certain scripts.
+
+
+# Check that we got an argument
+if [ -z "${1-}" ]
+then
+       echo
+       echo "$0: No argument provided"
+       echo
+       exit 1
+fi
+
+
+# Check that we do not already have changes
+if [ -n "$(git status --porcelain=v1)" ]
+then
+       echo
+       echo "$0: Do not run this script with changes in git index"
+       echo
+       echo
+       git status
+       echo
+       echo
+       exit 2
+fi
+
+
+# Run if argument is executable
+if [ -x "${0%/*}/$1" ]
+then
+       # Run the given script
+       "${0%/*}/$1" || {
+               echo
+               echo "$0: ${0%/*}/$1 ran into an error while executing"
+               echo
+               exit 3
+       }
+else
+       echo "$0: ${0%/*}/$1 is not an executable"
+       exit 4
+fi
+
+
+# Check that we did not produce changes
+if [ -n "$(git status --porcelain=v1)" ]
+then
+       echo
+       echo "$0: ${0%/*}/$1 produced a change in the repository:"
+       echo
+       echo
+       git status
+       echo
+       echo
+       exit 5
+fi