[Git][NTPsec/ntpsec][master] ci: add a shellcheck code quality job
Gary E. Miller (@garyedmundsmiller)
gitlab at mg.gitlab.com
Wed Nov 4 04:02:19 UTC 2026
Gary E. Miller pushed to branch master at NTPsec / ntpsec
Commits:
67548b43 by Matt Selsky at 2026-11-03T19:55:03-08:00
ci: add a shellcheck code quality job
Run shellcheck on every file whose first line is an sh-family shebang,
since most of the shell scripts have no .sh extension, and convert its
json1 output to a GitLab Code Quality report with jq. Like the ruff
job, findings don't fail the job; they show in the merge request's
Code Quality widget. The job does fail if shellcheck produces no
report at all.
Only warnings and errors are reported (-S warning). The fingerprint
includes the line, so moving a finding shows it as fixed and new.
- - - - -
1 changed file:
- .gitlab-ci.yml
Changes:
=====================================
.gitlab-ci.yml
=====================================
@@ -456,3 +456,25 @@ code-quality-python:
artifacts:
reports:
codequality: gl-code-quality-python.json
+
+code-quality-shell:
+ <<: *job_definition
+ stage: test
+ image: $IMAGE_REGISTRY/quality-checks
+ script:
+ # shell scripts are the files whose first line is an sh-family shebang
+ - |
+ find . -path ./.git -prune -o -type f -print0 |
+ xargs -0 awk 'FNR==1 && /^#! ?\/(usr\/)?bin\/(env +)?(ba|da|k)?sh( |$)/ {print substr(FILENAME, 3)} {nextfile}' |
+ xargs shellcheck -S warning -f json1 > shellcheck.json || true
+ - |
+ jq -e '[.comments[] | {
+ description: .message,
+ check_name: "SC\(.code)",
+ fingerprint: "\(.file):\(.line):\(.column):SC\(.code)",
+ severity: ({error: "major", warning: "minor"}[.level]),
+ location: {path: .file, lines: {begin: .line, end: .endLine}}
+ }]' shellcheck.json > gl-code-quality-shell.json
+ artifacts:
+ reports:
+ codequality: gl-code-quality-shell.json
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/67548b43664eb917c5cdb08708fc1a2d1c8a2268
--
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/67548b43664eb917c5cdb08708fc1a2d1c8a2268
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20261104/b0c1ddca/attachment-0001.htm>
More information about the vc
mailing list