From e437f12eed41aa391186c6b005388a2063c33a33 Mon Sep 17 00:00:00 2001 From: Grische <2787581+grische@users.noreply.github.com> Date: Thu, 13 Mar 2025 18:04:22 +0100 Subject: [PATCH] adding a workflow to check files not ending in .sh --- GitLab-CI.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/GitLab-CI.md b/GitLab-CI.md index 2450470..f5df212 100644 --- a/GitLab-CI.md +++ b/GitLab-CI.md @@ -21,4 +21,17 @@ test: - git ls-files --exclude='*.sh' --ignored -c -z | xargs -0r shellcheck ``` +If you want to lint *all* shell scripts (i.e. with a shebang), even those not ending on `.sh`: + +```yaml +test: + image: koalaman/shellcheck-alpine:latest + stage: test + before_script: + - apk update + - apk add git + script: + - git ls-files -c -z | xargs -0 awk -vORS='\0' 'FNR==1 && /^#!.*sh/ { print FILENAME }') | xargs -0r shellcheck +``` + If you want to create a JUnit XML report to see in the GitLab's UI, check the instructions [here](JUnit), additionally checkstyle can also be [transformed](checkstyle2text) back into text again for logging purposes. \ No newline at end of file