Skip to content

refactor(lint): move lint.yml run scripts into scripts/lint - #543

Merged
DevSecNinja merged 1 commit into
devsecninja-lint-inline-scripts-checkerfrom
devsecninja-lint-inline-scripts-lint-yml
Nov 17, 2026
Merged

DevSecNinja merged 1 commit into
devsecninja-lint-inline-scripts-checkerfrom
devsecninja-lint-inline-scripts-lint-yml

Conversation

@DevSecNinja

@DevSecNinja DevSecNinja commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Description

Layer 2a of #537, stacked on #541. Every multi-line run: block of the reusable lint.yml moves into a script under scripts/lint/, where shellcheck, shfmt and tests reach it. The inline-script checker now reports nothing for lint.yml (30 findings before). Behaviour doesn't change: the script bodies are the old run: 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.yml shrinks by about 770 lines.

Changes

  • scripts/lint/*.sh: one script per former run: 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) and require-mise-tool.sh. Each keeps the -eo pipefail options GitHub's bash shell used, and all are shellcheck- and shfmt-clean.
  • lint.yml runs in the caller's checkout, so every job that runs a script starts with two steps: Checkout lint scripts (sparse checkout of scripts/lint/ and the checker at job.workflow_sha, the same pattern feat(lint): report inline scripts in workflow run steps #541 uses) and Move lint scripts out of the workspace (mv to $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 through env: only.
  • Tests:
    • tests/lint-gitleaks-report.sh runs gitleaks.sh and gitleaks-report.sh directly, 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.sh also 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.
    • New tests/lint-scripts.sh covers the other moved scripts with stand-ins for mise and curl: the pinned-tool check, config-dir selection, shellcheck/shfmt excludes and .shellcheckrc handling, SARIF vs exit-code gating, the SARIF filter, the Go checks, lint-job-mode validation, the single-job report, and config drift.
    • tests/lint-inline-scripts.py runs the checker in blocking mode on lint.yml; later layers add the files they clean up.
  • docs/architecture.md describes 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

  • Linting passes locally (mise exec -- lefthook run pre-commit)
    • No lefthook config exists at the repository root, so I ran the linters directly: actionlint (exit 0), shellcheck with config-sync/files/.shellcheckrc and shfmt -d on all new and changed shell files (exit 0), yamlfmt -lint and yamllint on lint.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.yml clean in blocking mode).
    • python3 tests/workflow-job-conditions.py: passed (9 lint.yml scenarios).
    • Not run locally: the rest of mise run test (unchanged areas; this Windows machine lacks PyPI access and a Linux python3). CI runs it, and the lint-caller runs check both modes end to end.
  • Commit messages follow Conventional Commits
  • Documentation updated (if applicable)

Summary by CodeRabbit

  • Improvements
    • Individual and combined lint jobs now use the same pinned checks, with consistent handling of scan results and lint outcomes.
    • Added automated checks for lint scripts, workflow consistency, and configuration drift.
  • Documentation
    • Updated the architecture guide to describe how lint scripts are shared and run.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Lint workflow jobs now call shared scripts for tool checks, formatting, security scans, and reporting. The scripts are checked out at the caller-pinned commit and moved to RUNNER_TEMP. The PR adds contract checks and a test harness for the scripts.

Changes: Shared lint execution

Layer / File(s) Summary
Workflow support scripts
.github/workflows/lint.yml, scripts/lint/config-drift.sh, scripts/lint/go-version-file.sh, scripts/lint/golangci-lint-version.sh, scripts/lint/lint-job-mode.sh, scripts/lint/report-results.sh, scripts/lint/require-mise-tool.sh, tests/lint-scripts.sh
Shared scripts handle mise tool checks, Go-version checks, job-mode validation, config drift, and result reporting. Workflow steps call these scripts, and the test harness covers their behavior.
Formatting and shell lint scripts
.github/workflows/lint.yml, scripts/lint/dprint.sh, scripts/lint/yamlfmt.sh, scripts/lint/yamllint.sh, scripts/lint/shellcheck.sh, scripts/lint/shfmt.sh, tests/lint-scripts.sh
Shared scripts run formatting and shell lint tools with config selection and file exclusions. Per-linter and combined workflow jobs invoke the scripts. Tests check tool arguments, file selection, configs, and failure handling.
Security scan and finding scripts
.github/workflows/lint.yml, scripts/lint/checkov*.sh, scripts/lint/gitleaks*.sh, scripts/lint/trivy.sh, scripts/lint/zizmor.sh, tests/lint-gitleaks-report.sh, tests/lint-scripts.sh
Shared scripts run security scans and process SARIF or Gitleaks findings. Workflow jobs call these scripts, and tests cover scan modes, SARIF handling, and Gitleaks reporting.
Pinned checkout and contract validation
.github/workflows/lint.yml, .mise.toml, docs/architecture.md, tests/lint-inline-scripts.py, tests/lint-job-modes-contract.sh, tests/lint-scripts.sh
Jobs check out shared scripts at the caller-pinned commit and move them to RUNNER_TEMP. Contract checks validate script references and checkout steps. The inline-script checker adds a blocking check for lint.yml, and the architecture guide documents the checkout.

Estimated code review effort: 4 (Complex) | ~50 minutes

Change: Refactor

Possibly related issues

  • DevSecNinja/.github issue 537 — This PR moves lint.yml inline scripts into shared scripts and adds a blocking check for that workflow; the issue’s other workflow and composite-action scope is not covered.

Possibly related PRs

  • DevSecNinja/.github#541 — This PR moves the inline workflow commands detected by the checker into shared scripts and uses the checker in validation.
  • DevSecNinja/.github#469 — This PR uses the lint job modes introduced there and relocates scripts to RUNNER_TEMP.
  • DevSecNinja/.github#505 — This PR moves the Gitleaks reporting implementation into shared scripts and tests those scripts directly.
Merge Risk: Minimal · up to bc881

This refactor moves lint workflow shell blocks into shared scripts without changing behavior. No concrete merge-blocking risk was found. CI should run the remaining test suite and the caller-side lint checks before merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: the run scripts from lint.yml are moved into scripts/lint. The raw summary confirms the workflow now calls shared scripts under scripts/lint and the inline run blocks …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the run scripts from lint.yml are moved into scripts/lint. The raw summary confirms the workflow now calls shared scripts under scripts/lint and the inline run blocks are removed. The title follows the conventional-commit style and is specific enough for a teammate scanning history.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bf4ace42-5f0c-474c-b894-d6974b2d4e3a
Commits

Reviewing files that changed from the base of the PR and between 59451ac and bc881e6.

Files selected for processing: 24

  • .github/workflows/lint.yml
  • .mise.toml
  • docs/architecture.md
  • scripts/lint/checkov-sarif-filter.sh
  • scripts/lint/checkov.sh
  • scripts/lint/config-drift.sh
  • scripts/lint/dprint.sh
  • scripts/lint/gitleaks-report.sh
  • scripts/lint/gitleaks.sh
  • scripts/lint/go-version-file.sh
  • scripts/lint/golangci-lint-version.sh
  • scripts/lint/lint-job-mode.sh
  • scripts/lint/report-results.sh
  • scripts/lint/require-mise-tool.sh
  • scripts/lint/shellcheck.sh
  • scripts/lint/shfmt.sh
  • scripts/lint/trivy.sh
  • scripts/lint/yamlfmt.sh
  • scripts/lint/yamllint.sh
  • scripts/lint/zizmor.sh
  • tests/lint-gitleaks-report.sh
  • tests/lint-inline-scripts.py
  • tests/lint-job-modes-contract.sh
  • tests/lint-scripts.sh

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain, though validation was static only and tests, builds, and linters were not run.

No open issues 🎉

Review effort: Balanced

DevSecNinja added a commit that referenced this pull request Nov 16, 2026
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>
@DevSecNinja
DevSecNinja force-pushed the devsecninja-lint-inline-scripts-lint-yml branch from 158f3ac to bc881e6 Compare November 17, 2026 10:53
DevSecNinja added a commit that referenced this pull request Nov 17, 2026
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>
@DevSecNinja
DevSecNinja merged commit ce0dd16 into main Nov 17, 2026
38 checks passed
@DevSecNinja
DevSecNinja deleted the devsecninja-lint-inline-scripts-lint-yml branch November 17, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants