aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Smith <osmith@sysmocom.de>2022-02-11 10:22:49 +0100
committerOliver Smith <osmith@sysmocom.de>2022-02-11 15:44:16 +0100
commit41e218a3557d8028da6aee4ad5548ed546f1b5f6 (patch)
treeacac7320e95676f8792ad0cf64f664bb8022807a
parent2e88fa26635705e0b220e8a86f8e9efc2b767d4c (diff)
lint: catch missing --rm flag for 'docker run'
Not having the --rm flag causes docker containers to be stored forever, so make sure we always add it to the "docker run" commands that we run on jenkins via scripts in various repositories. Depends: docker-playground I48b01c43fedf379b8a565eaab0369806d7831bd8 Related: https://osmocom.org/projects/osmocom-servers/wiki/Docker_cache_clean_up Related: SYS#5827, OS#5099 Change-Id: I8ab9c291504475d670bdefc50c4524c5bdd4c880
-rwxr-xr-xlint/docker_run_rm.sh17
-rwxr-xr-xlint/lint_diff.sh25
2 files changed, 35 insertions, 7 deletions
diff --git a/lint/docker_run_rm.sh b/lint/docker_run_rm.sh
new file mode 100755
index 0000000..3d6648e
--- /dev/null
+++ b/lint/docker_run_rm.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+# Verify that "docker run" has a "--rm" in the same line or next line, so we
+# don't fill up space on jenkins nodes with never deleted containers:
+# https://osmocom.org/projects/osmocom-servers/wiki/Docker_cache_clean_up
+
+RET=0
+
+for i in $(git grep -l '^[^#]*docker run'); do
+ if [ -z "$(grep -A1 "docker run" "$i" | grep -- "--rm")" ]; then
+ echo "ERROR: missing --rm after 'docker run' (same line or next line):"
+ grep --color=always -H -n -A1 "docker run" "$i"
+ echo
+ RET=1
+ fi
+done
+
+exit $RET
diff --git a/lint/lint_diff.sh b/lint/lint_diff.sh
index f8daab7..0762f6b 100755
--- a/lint/lint_diff.sh
+++ b/lint/lint_diff.sh
@@ -19,20 +19,31 @@ if [ -z "$COMMIT" ]; then
fi
fi
+ERROR=0
+
+echo "Running docker_run_rm.sh on the whole tree..."
+echo
+if ! "$SCRIPT_DIR"/docker_run_rm.sh; then
+ ERROR=1
+fi
+
echo "Running checkpatch on 'git diff $COMMIT'..."
echo
-if git diff -U0 "$COMMIT" | "$SCRIPT_DIR/checkpatch/checkpatch_osmo.sh" - \
+if ! git diff -U0 "$COMMIT" | "$SCRIPT_DIR/checkpatch/checkpatch_osmo.sh" - \
--color=always \
--mailback \
--show-types \
--showfile \
--terse
then
- exit 0
+ ERROR=1
fi
-echo
-echo "Please fix the linting errors above. More information:"
-echo "https://osmocom.org/projects/cellular-infrastructure/wiki/Linting"
-echo
-exit 1
+
+if [ "$ERROR" = 1 ]; then
+ echo
+ echo "Please fix the linting errors above. More information:"
+ echo "https://osmocom.org/projects/cellular-infrastructure/wiki/Linting"
+ echo
+ exit 1
+fi