Repository navigation
refactor(lint): move lint.yml run scripts into scripts/lint - #543
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the refactor that consolidates inline lint logic into shared, testable scripts.
No open issues 🎉
What changed in this PR
Moves the reusable lint workflow’s inline scripts into shared, testable files, advancing #537’s effort to remove inline workflow code after #541 introduced the checker.
Changes:
- Replaces duplicated script bodies with 16 lint scripts and a shared mise-tool check used by both scheduling modes.
- Fetches scripts from the workflow’s pinned commit and moves them outside the caller’s workspace.
- Adds script tests, strengthens workflow contracts, enforces inline-script checks for
lint.yml, and updates documentation.
Validation was limited to static inspection; tests, builds, and linters were not run.
| File | Description |
|---|---|
tests/lint-scripts.sh |
Adds isolated coverage for extracted script behavior. |
tests/lint-job-modes-contract.sh |
Checks shared invocations, checkout ordering, and script availability. |
tests/lint-inline-scripts.py |
Requires lint.yml to pass blocking inline-script checks. |
tests/lint-gitleaks-report.sh |
Runs extracted gitleaks scripts directly. |
scripts/lint/zizmor.sh |
Extracts workflow security scanning. |
scripts/lint/yamllint.sh |
Extracts YAML linting and config selection. |
scripts/lint/yamlfmt.sh |
Extracts YAML formatting checks. |
scripts/lint/trivy.sh |
Extracts filesystem scanning and SARIF handling. |
scripts/lint/shfmt.sh |
Extracts shell formatting checks and exclusions. |
scripts/lint/shellcheck.sh |
Extracts shell linting and configuration handling. |
scripts/lint/require-mise-tool.sh |
Centralizes the required mise-tool check. |
scripts/lint/report-results.sh |
Extracts single-job summaries and failure reporting. |
scripts/lint/lint-job-mode.sh |
Extracts scheduling-mode validation. |
scripts/lint/golangci-lint-version.sh |
Extracts the missing Go linter-version error. |
scripts/lint/go-version-file.sh |
Extracts Go version-file detection. |
scripts/lint/gitleaks.sh |
Extracts PR and history secret scanning. |
scripts/lint/gitleaks-report.sh |
Extracts secret-scan annotations and summaries. |
scripts/lint/dprint.sh |
Extracts formatting checks and config selection. |
scripts/lint/config-drift.sh |
Extracts central configuration comparisons. |
scripts/lint/checkov.sh |
Extracts infrastructure scanning. |
scripts/lint/checkov-sarif-filter.sh |
Extracts skipped-check filtering from SARIF. |
docs/architecture.md |
Documents shared scripts and their checkout lifecycle. |
.mise.toml |
Adds the script tests to the test task. |
.github/workflows/lint.yml |
Replaces inline bodies with fetched script invocations. |
Review effort: Balanced
67b800f to
158f3ac
Compare
Layer 2c of #537. The multi-line run: blocks of the config-sync, apm-sync, apm-materialize, vendored-file-sync and autofix workflows move into scripts/<workflow>/, fetched at job.workflow_sha like #543 and #544 did. The App-key preflights of config-sync and apm-sync stay inline with a lint opt-out, since tests/app-key-confinement.py pins them, and tests/workflow-script-fetch.py now lets them (and harden-runner) run before the fetch steps. Refs #537 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Every multi-line run: block of the reusable lint.yml moves into a script under scripts/lint/, so shellcheck, shfmt and tests reach it, and the inline-script checker reports nothing for lint.yml. Both lint modes run the same scripts, so the 30 copied blocks become 16 scripts plus a shared require-mise-tool check. lint.yml runs in the caller's checkout, so every job first checks the scripts out from the DevSecNinja/.github commit the caller pinned (job.workflow_sha) and moves them to RUNNER_TEMP, out of reach of the caller's own linters and of the code checkout. The script bodies are unchanged. The gitleaks test runs the scripts directly, the contract test checks that every job fetches the scripts it runs, and tests/lint-scripts.sh covers the other moved scripts. Refs #537 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
158f3ac to
bc881e6
Compare
Layer 2c of #537. The multi-line run: blocks of the config-sync, apm-sync, apm-materialize, vendored-file-sync and autofix workflows move into scripts/<workflow>/, fetched at job.workflow_sha like #543 and #544 did. The App-key preflights of config-sync and apm-sync stay inline with a lint opt-out, since tests/app-key-confinement.py pins them, and tests/workflow-script-fetch.py now lets them (and harden-runner) run before the fetch steps. Refs #537 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Description
Layer 2a of #537, stacked on #541. Every multi-line
run:block of the reusablelint.ymlmoves into a script underscripts/lint/, where shellcheck, shfmt and tests reach it. The inline-script checker now reports nothing forlint.yml(30 findings before). Behaviour doesn't change: the script bodies are the oldrun:blocks, reindented.Both lint modes run the same scripts, so the 30 copied blocks become 16 scripts plus a shared
require-mise-tool.sh(the "tool not pinned" preamble that seven linters repeated).lint.ymlshrinks by about 770 lines.Changes
scripts/lint/*.sh: one script per formerrun:block (dprint, yamlfmt, yamllint, gitleaks, gitleaks-report, go-version-file, golangci-lint-version, shellcheck, shfmt, checkov, checkov-sarif-filter, trivy, zizmor, config-drift, lint-job-mode, report-results) andrequire-mise-tool.sh. Each keeps the-eo pipefailoptions GitHub'sbashshell used, and all are shellcheck- and shfmt-clean.lint.ymlruns in the caller's checkout, so every job that runs a script starts with two steps: Checkout lint scripts (sparse checkout ofscripts/lint/and the checker atjob.workflow_sha, the same pattern feat(lint): report inline scripts in workflow run steps #541 uses) and Move lint scripts out of the workspace (mvto$RUNNER_TEMP). Outside the workspace the caller's own shellcheck, shfmt, trivy and checkov don't scan our scripts, and the code checkout doesn't delete them. This replaces feat(lint): report inline scripts in workflow run steps #541's separate checker checkout.${{ }}values still reach the scripts throughenv:only.tests/lint-gitleaks-report.shrunsgitleaks.shandgitleaks-report.shdirectly, with every PR, history, public-log withholding and SARIF case from feat(lint): scan PR commits on PRs and full history privately via code scanning #520/feat(lint): scan PR commits on PRs and full history privately #525 unchanged, and checks that both lint modes call those scripts.tests/lint-job-modes-contract.shalso checks that every job running a script fetches and moves the scripts first, with identical fetch steps, and that every script it runs exists and is in the sparse checkout.tests/lint-scripts.shcovers the other moved scripts with stand-ins for mise and curl: the pinned-tool check, config-dir selection, shellcheck/shfmt excludes and.shellcheckrchandling, SARIF vs exit-code gating, the SARIF filter, the Go checks,lint-job-modevalidation, the single-job report, and config drift.tests/lint-inline-scripts.pyruns the checker in blocking mode onlint.yml; later layers add the files they clean up.docs/architecture.mddescribes where the linter scripts live and how jobs fetch them.Known edge: if fetching the scripts fails, the single-job report step can't run either, so the job fails without the summary table. Before, a failing setup step still produced the table.
Refs #537
Checklist
mise exec -- lefthook run pre-commit)actionlint(exit 0),shellcheckwithconfig-sync/files/.shellcheckrcandshfmt -don all new and changed shell files (exit 0),yamlfmt -lintandyamllintonlint.yml(exit 0),dprint check(exit 0),zizmor --offline .github/workflows/lint.yml(no findings).bash tests/lint-gitleaks-report.sh: passed.bash tests/lint-scripts.sh: passed (Git Bash and Debian/WSL).bash tests/lint-job-modes-contract.sh: passed (13 linters, 28 identical run lines, 13 jobs fetch the 17 scripts they run).uv run --script tests/lint-inline-scripts.py: passed (14 cases,lint.ymlclean in blocking mode).python3 tests/workflow-job-conditions.py: passed (9 lint.yml scenarios).mise run test(unchanged areas; this Windows machine lacks PyPI access and a Linuxpython3). CI runs it, and the lint-caller runs check both modes end to end.Summary by CodeRabbit