Skip to content

feat(hooks): shellcheck the run bodies of composite actions - #1718

Merged
c-vigo merged 10 commits into
devfrom
feature/1704-shellcheck-composite-actions
Sep 25, 2026
Merged

c-vigo merged 10 commits into
devfrom
feature/1704-shellcheck-composite-actions

Conversation

@c-vigo

@c-vigo c-vigo commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Description

actionlint lints the shell in workflow run: steps but refuses composite actions outright (unexpected key "runs" for "workflow" section) and has no composite mode (#245 closed as a duplicate of the dormant #46; 1.7.12 is the latest release). So the 44 run: bodies across the seven composites — devkit's build-image, setup-env, test-image, test-integration, test-project, and the scaffold's resolve-toolchain and setup-devkit-toolchain under assets/workspace/, which are the ones consumers actually run — had no shellcheck pass at all, locally or in CI. #1692 moved seven more bodies into test-project, each shellchecked by hand for that PR and unguarded since.

This adds shellcheck-composite-actions, a vig-utils console script wired as a scaffolded pre-commit hook. It reproduces actionlint's own recipe rather than approximating it: stdin = set -eo pipefail + body, each ${{ … }} replaced by same-length underscores with newlines kept (so line and column offsets are exact), and actionlint's exclude list passed verbatim (SC1091,SC2194,SC2050,SC2153,SC2154,SC2157,SC2043 — precisely the placeholder-induced false positives). Gate is -S warning; findings print in action.yml coordinates with the step name; inline # shellcheck disable= directives survive extraction. sh steps get set -e and --shell sh; python/pwsh/powershell/cmd/node and uses: steps and non-composite actions are skipped; any other unrecognised shell: value is skipped with a stderr note so a typo cannot quietly unlint a body (review finding).

The files regex (^|/)\.github/actions/[^/]+/action\.ya?ml$ covers both trees with one pattern (the scaffold's copy is .github/actions/ once scaffolded), so the same hook serves devkit, the scaffold copy and consumers unchanged. The Nix check and consumer fragments pin both the vig-utils binary and shellcheck by store path; the portable YAML entry stays store-path free like its siblings.

First run over the seven composites: one real finding, exactly as triage predicted — an unquoted $(id -u) in the podman socket URI of test-integration (SC2046). Fixed, not suppressed. The $TEST_ARGS SC2086 the issue cites is info-level and does not fire at -S warning (a test pins that --severity info surfaces it), so acceptance criterion 2 needs no suppression.

Type of Change

  • feat -- New feature
  • fix -- Bug fix
  • docs -- Documentation only
  • chore -- Maintenance task (deps, config, etc.)
  • refactor -- Code restructuring (no behavior change)
  • test -- Adding or updating tests
  • ci -- CI/CD pipeline changes
  • build -- Build system or dependency changes
  • revert -- Reverts a previous commit
  • style -- Code style (formatting, whitespace)

Modifiers

  • Breaking change (!) -- This change breaks backward compatibility

Changes Made

packages/vig-utils/src/vig_utils/shellcheck_composite_actions.py (new), pyproject.toml, uv.lock, nix/vig-utils.nix

  • Console script shellcheck-composite-actions; YAML composed with marks so block-scalar findings map to file line/column; exit 0 / 1 (findings) / 2 (tool error); --shellcheck PATH and SHELLCHECK; -S/--severity default warning. pyyaml added to vig-utils (already pinned at the root, no new lock entry) and to the Nix build

nix/hooks.nix, .pre-commit-config.yaml, assets/workspace/.pre-commit-config.yaml

  • compositeActionFiles regex; hook after actionlint with scaffold = true, pass_filenames = true, check and consumer fragments pinning ${pkgs.shellcheck}/bin/shellcheck; both rendered configs hand-synced (no render recipe) and matching nix eval .#lib.hooksPortable

.github/actions/test-integration/action.yml

  • "unix:///run/user/$(id -u)/podman/podman.sock"

packages/vig-utils/tests/test_shellcheck_composite_actions.py (new, 21 tests), tests/test_flake_hooks.py (+4)

  • Clean body; planted SC2046 naming the step; ${{ }} inside [ … ] not flagged; shell: python and runs.using: node20 skipped; inline disable honoured; same-length neutralisation; exact line+column mapping; severity gate both ways; tool errors → 2. Hook-shape pins: portable entries, consumer entry pins both store paths, regex covers both trees and nothing else, every committed composite in scope. RED before the hook: KeyError: 'shellcheck-composite-actions'

CHANGELOG.md, assets/workspace/.devcontainer/CHANGELOG.md

  • ### Added entry, identical in both

Changelog Entry

Added

  • Composite-action run: bodies are shellchecked
    (#1704)
    • actionlint refuses a composite action outright (unexpected key "runs" for "workflow" section) and has no composite mode, so every run: body that
      moved out of a workflow and into .github/actions/*/action.yml silently lost
      its shellcheck pass — locally and in CI
    • The new shellcheck-composite-actions hook reproduces actionlint's own
      recipe over those bodies: each ${{ … }} blanked to same-length underscores
      (so findings still point at the real line and column), GitHub's shell prelude
      prepended, and actionlint's exclude list passed verbatim — one lint, not two
      dialects of one. Inline # shellcheck disable= directives keep working
    • Scaffolded: new scaffolds and flake-hooks consumers gate their own
      composites from this release; a consumer with a preserved
      .pre-commit-config.yaml receives the hook on the release that adds its
      insert row. Findings are reported in action.yml coordinates. The first
      pass caught one real defect: an unquoted $(id -u) in the podman socket
      URI of test-integration

Testing

  • Tests pass locally (just test)
  • Manual testing performed (describe below)

Manual Testing Details

  • Hook over all 7 composites: RED test-integration/action.yml:151:57: SC2046 (warning): Quote this to prevent word splitting. [step: Start podman socket], exit 1; GREEN after the one-character fix, exit 0. Column 57 lands exactly on the $(
  • uv run pytest packages/vig-utils/tests tests/test_flake_hooks.py tests/test_changelog_unreleased_typos.py tests/test_scaffold_lint.py → 744 passed
  • nix build of vig-utils with pyyaml succeeds and its store bin/shellcheck-composite-actions runs the 7 composites to exit 0; nix build .#checks.x86_64-linux.pre-commit green (the sandbox fragment runs hermetically over both trees)
  • prek run --all-files → 55 hooks passed in both roots, the new hook among them
  • actionlint .github/workflows/*.yml unaffected

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (edit docs/templates/, then run just docs)
  • I have updated CHANGELOG.md in the [Unreleased] section (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

Refs: #1704

A step whose `shell:` is neither a checked shell nor a known non-shell
must not drop out of the gate silently.

Refs: #1704
`python`, `pwsh`, `powershell`, `cmd` and `node` are skipped silently;
any other `shell:` outside the checked set (a typo, a custom template)
prints a stderr note naming the file and step.

Refs: #1704
…ck hook

A preserved `.pre-commit-config.yaml` only gains a new hook through an
insert row, which lands with the release that first ships it.

Refs: #1704
@c-vigo
c-vigo merged commit 447829c into dev Sep 25, 2026
17 checks passed
@c-vigo
c-vigo deleted the feature/1704-shellcheck-composite-actions branch September 25, 2026 16:10
c-vigo added a commit that referenced this pull request Sep 25, 2026
…ain (#1723)

## Description

#1718 added the scaffolded `shellcheck-composite-actions` hook. A
consumer whose `.pre-commit-config.yaml` is preserved receives a new
hook only through `inserted_hook_blocks()` in
`assets/init-workspace.sh`, whose rows are keyed on the *first release
that ships the hook*. That version is a literal nothing else checks,
trains have been renamed mid-flight twice, and a stale number either
under-inserts or re-adds a hook a consumer deleted. The row for the new
hook therefore goes on the release branch once the version is fixed
(#1717 stays open for that).

What can land now is the guard against forgetting: the Phase 1
prerequisites in `docs/RELEASE_CYCLE.md` gain one bullet — re-check the
table's rows against the version being cut — so the lesson is a repo
artefact rather than session memory. Triage notes on the issue confirm
the mechanism already accepts a hook with no feature group and extracts
the block structurally, so no code change is needed on `dev`.

## Type of Change

- [ ] `feat` -- New feature
- [ ] `fix` -- Bug fix
- [x] `docs` -- Documentation only
- [ ] `chore` -- Maintenance task (deps, config, etc.)
- [ ] `refactor` -- Code restructuring (no behavior change)
- [ ] `test` -- Adding or updating tests
- [ ] `ci` -- CI/CD pipeline changes
- [ ] `build` -- Build system or dependency changes
- [ ] `revert` -- Reverts a previous commit
- [ ] `style` -- Code style (formatting, whitespace)

### Modifiers

- [ ] Breaking change (`!`) -- This change breaks backward compatibility

## Changes Made

`docs/RELEASE_CYCLE.md`

- One prerequisite bullet under Phase 1: every hook added since the last
release has its `inserted_hook_blocks()` row, every row's version is the
one being cut, rows are added or fixed on the release branch with
`tests/test_scaffold_preserved_hooks.py` updated to match

## Changelog Entry

No changelog needed — devkit-internal release procedure; the doc is not
scaffolded.

## Testing

- [x] Tests pass locally (`just test`)
- [ ] Manual testing performed (describe below)

### Manual Testing Details

N/A — `prek run --all-files` (pymarkdown, typos, generate-docs) all
green; `docs/RELEASE_CYCLE.md` is not template-generated.

## Checklist

- [x] My code follows the project's style guidelines
- [x] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [x] I have updated the documentation accordingly (edit
`docs/templates/`, then run `just docs`)
- [ ] I have updated `CHANGELOG.md` in the `[Unreleased]` section (and
pasted the entry above)
- [x] My changes generate no new warnings or errors
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [x] Any dependent changes have been merged and published

## Additional Notes

The issue stays open: its row (`'X.Y.Z shellcheck-composite-actions'`,
after the actionlint row, plus `COMPOSITE_SINCE` and the boundary tests)
is release-branch work.

Refs: #1717
c-vigo added a commit that referenced this pull request Sep 25, 2026
The composite-action shellcheck hook (#1704, scaffolded by #1718) reaches new
scaffolds only: a preserved .pre-commit-config.yaml never receives template
evolution (#878), so every existing consumer leaves .github/actions/*/action.yml
run bodies unlinted. Case 2 of #1654 is the seam that fixes it, and it needs one
row in inserted_hook_blocks().

The row's version is 1.17.0. dev already holds two feat commits since 1.16.0
(#1718 and #1724) and no breaking change, so the next train is 1.17.0 by
construction; the only rename still possible is upward, and an upward rename is
harmless for this row (every consumer's pin is below 1.17.0 at adoption, and
nobody can sit exactly at 1.17.0). A DOWNWARD rename is the one that would hurt
— it re-adds a hook a consumer deleted, the #1651 defect — and a feat on dev
rules that out. #1723's Phase 1 prerequisite covers the re-check either way.

Two fields, not three: the hook belongs to no feature group, so the row omits
the group and `read -r ver hook feat` leaves feat empty. The row must also come
AFTER the actionlint one, because the insert anchors on the previous hook in
template order: a pre-1.16.0 tree receives actionlint first and anchors this
block on what that row just inserted, in a single pass.

The three boundary tests (pin at 1.17.0, pin at 1.17.1, hook already present)
pass vacuously until the row exists; they are the guard against the row being
set too low later.

Refs: #1717
c-vigo added a commit that referenced this pull request Sep 25, 2026
…ed configs from 1.17.0

One row in inserted_hook_blocks(), so Case 2 of #1654 carries #1704's hook into
the preserved .pre-commit-config.yaml of every consumer whose tree predates it.
Until now the hook reached new scaffolds only (#1718), leaving every existing
repo's .github/actions/*/action.yml run bodies unlinted — actionlint refuses a
composite action outright and has no composite mode.

The row is two fields wide: the hook belongs to no feature group, and
`read -r ver hook feat` leaves feat empty, which the gate reads as "never
opted out". It sits AFTER the actionlint row because the insert anchors on the
hook the template places before this one, so a pre-1.16.0 tree gains actionlint
and then anchors this block on it within the same pass.

1.17.0 is the version by construction: dev already holds two feat commits since
1.16.0 (#1718, #1724) and no breaking change, so the next train is a minor. The
only rename still available is upward, and an upward rename leaves the row
harmless — every consumer's pin is below 1.17.0 at adoption and nobody can be
pinned exactly at 1.17.0. A downward rename is the direction that would re-add a
hook a consumer deleted (the #1651 defect); it would have to edit this row on
the release branch, which #1723's Phase 1 prerequisite now makes a checked step.

Refs: #1717
c-vigo added a commit that referenced this pull request Sep 25, 2026
…ed configs from 1.17.0 (#1726)

## Description

#1718 added the scaffolded `shellcheck-composite-actions` hook, but a
consumer with a preserved `.pre-commit-config.yaml` only receives a new
hook through the `inserted_hook_blocks()` table in
`assets/init-workspace.sh`, keyed on the first release that ships it.
#1723 already put the re-check of that table on the Phase 1
prerequisites; this adds the row itself.

**Why the version can be fixed now.** `dev` holds two `feat` commits
since 1.16.0 (#1718 and #1724) and no breaking change, so the next train
is `1.17.0` by construction, and it is planned for Monday 2026-09-28.
The only rename possible from here is upward, and an upward rename
leaves a `1.17.0` row harmless: every consumer's pin is still below it
at adoption, and nobody can ever sit exactly at `1.17.0`. The #1651
defect (re-adding a hook a consumer deleted) needs the row to be *below*
the real first release, which would require a downward rename that a
`feat` on `dev` rules out unless both are pulled — the case the #1723
prerequisite now catches on the release branch.

**Mechanism, verified rather than assumed.** Rows are `<first release>
<hook> [feature group]`; `insert_missing_hook_blocks` reads `read -r ver
hook feat`, so the two-field row is legal and the empty group never
gates. The block comes from the rendered template structurally (the `-
repo:` entry holding `- id: shellcheck-composite-actions`); the anchor
derived from the template is `actionlint`, so the row must follow the
actionlint row: a pre-1.16.0 tree gains actionlint first and the
composite block right after it, in one pass.

**End-to-end, with the real script:** a temp workspace at
`DEVKIT_VERSION=1.16.0` whose config lacks the composite block gains
exactly that block after the actionlint sentinel end, nothing else
changes, and a second run is byte-identical. Output: `Inserted the
'shellcheck-composite-actions' hook after 'actionlint' (shipped since
1.17.0, this tree predates it at 1.16.0, #1654).`

## Type of Change

- [x] `feat` -- New feature
- [ ] `fix` -- Bug fix
- [ ] `docs` -- Documentation only
- [ ] `chore` -- Maintenance task (deps, config, etc.)
- [ ] `refactor` -- Code restructuring (no behavior change)
- [x] `test` -- Adding or updating tests
- [ ] `ci` -- CI/CD pipeline changes
- [ ] `build` -- Build system or dependency changes
- [ ] `revert` -- Reverts a previous commit
- [ ] `style` -- Code style (formatting, whitespace)

### Modifiers

- [ ] Breaking change (`!`) -- This change breaks backward compatibility

## Changes Made

`assets/init-workspace.sh`

- `inserted_hook_blocks()`: `'1.17.0 shellcheck-composite-actions'`
after the actionlint row, with a comment carrying the version rationale
and the ordering constraint

`tests/test_scaffold_preserved_hooks.py`

- `COMPOSITE_SINCE` / `COMPOSITE_HOOK`; the table test asserts the
quoted two-field row and that it follows the actionlint row;
`_composite_seed()` builds the 1.16.0 shape; a 1.16.0 pin gains exactly
the block (no consumer line removed, every added line the template's
own), 1.17.0 and 1.17.1 pins are left alone, an existing hook is never
duplicated, a pre-1.16.0 tree gains both blocks in template order
`[shellcheck, actionlint, shellcheck-composite-actions, typos]`,
`--preview` reports the planned insert. RED before the row: 5 failed /
22 passed. Two existing assertions were scoped from
`preserved-hook-insert:` to `preserved-hook-insert: actionlint` where an
older pin now legitimately gains the composite hook; the at-release pin
test stays unscoped (review finding)

## Changelog Entry

No changelog needed — the issue says so; the consumer-visible feature is
#1718's entry, this is its delivery path for preserved configs.

## Testing

- [x] Tests pass locally (`just test`)
- [x] Manual testing performed (describe below)

### Manual Testing Details

- End-to-end upgrade run described above, plus idempotence on a second
pass
- `uv run pytest tests/test_scaffold_preserved_hooks.py
tests/test_flake_hooks.py -q` → 105 passed
- `bats -j 4 --filter '1660|1651|preserved|hook'
tests/bats/init-workspace.bats` → 48 ok; the one failure is the
pre-existing environmental one (the test shells out to a bare `python3`
that lacks PyYAML in the plain `nix develop` shell; green in CI)
- `shellcheck -x` clean; `prek run --all-files` → 55 hooks passed

## Checklist

- [x] My code follows the project's style guidelines
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have updated the documentation accordingly (edit
`docs/templates/`, then run `just docs`)
- [ ] I have updated `CHANGELOG.md` in the `[Unreleased]` section (and
pasted the entry above)
- [x] My changes generate no new warnings or errors
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [x] Any dependent changes have been merged and published

## Additional Notes

Found while verifying, not fixed here: a consumer pinned below 1.17.0
with `DEVKIT_FEATURES_DISABLED=actionlint` has no actionlint block to
anchor on, so the composite insert is skipped with a warning (exit 0, no
partial write). Safe, but the message reads as a defect to that
consumer; a fallback anchor would be the fix. No known consumer is in
that state. Filed separately: #1725.

Refs: #1717
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.

1 participant