Skip to content

Give each entry of a GitHub strategy matrix its own hash and skip key (false skip, #43) - #51

Merged
ndbroadbent merged 3 commits into
mainfrom
fix/matrix-skip-key
Dec 4, 2026
Merged

ndbroadbent merged 3 commits into
mainfrom
fix/matrix-skip-key

Conversation

@ndbroadbent

@ndbroadbent ndbroadbent commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Fixes #43, a false skip. A job that runs GitHub's own matrix through the github: passthrough (github: { strategy: { matrix } }) gave every entry the same hash and the same skip key, job-skip-${{ runner.os }}-<job>-<hash>. So when nightly failed and stable passed on one commit, the next commit with unchanged inputs had nightly restore stable's marker and turn green. Found converting ripgrep's CI, where 14 Linux entries of one job would share a key.

The fix: the entry goes into the job's hash, not just the key. The generated hash step gets env: { CIGEN_MATRIX: "${{ toJSON(matrix) }}" } and runs cigen hash … --matrix "$CIGEN_MATRIX", for any job whose github: block has a strategy. cigen hash parses the entry and mixes its canonical JSON (keys sorted) into the digest (src/commands/matrix_entry.rs). The job hash, the cache key and the pass marker then all name one entry. This also avoids the comma problem: raw toJSON never goes into a cache key, and the JSON reaches the shell only as an environment variable, never parsed by it. A matrix built by an expression (fromJSON(...)) and include/exclude entries are covered, because the entry is read at runtime. Jobs without a strategy generate exactly as before; the golden fixtures are unchanged.

The entry is mixed in at the top only, never into the hashes of the jobs a job needs (#30), since those are other jobs.

CircleCI: no hole. Its provider renders no job passthrough keys other than type, and workflow entries are plain job names, so a matrix or job parameters can't be passed through. cigen's own matrix: expands into separately named variants, whose status keys include the variant name.

The planner (#29): DIRECTION.md now says a GitHub-matrix job's pass records must be per entry. Until the planner can enumerate a literal matrix, it plans such a job as run, and each entry checks its own marker keyed by --matrix.

Tests:

  • tests/matrix_skip.rs generates a workflow and runs the generated hash step itself with bash, once per entry, with CIGEN_MATRIX set as GitHub would.
    • Two entries get different keys, and the same entry gets the same key.
    • Scenario: on commit A stable passes and nightly fails; commit B changes only the README. nightly runs again and stable still skips.
    • A job without a matrix has no env and no --matrix.
  • mockci can't run a matrix yet, which is why the test runs the step directly.
  • Mutation checks: without the provider change, or with cigen hash ignoring the entry, the key tests fail.
  • matrix_entry.rs has unit tests: entries differ, key order doesn't matter, and an entry that isn't JSON is an error that names toJSON(matrix).

Docs and status:

  • The jobs page explains the passthrough matrix, and the CLI page lists --matrix.
  • STATUS: the GitHub provider bullet, a tests line, and known problem 23 (resolved).

task ci passes with no warnings.


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

A job running GitHub's own matrix through github: { strategy } gave every entry the same hash
and skip key, so an entry that failed reused the pass of one that succeeded (#43). The
generated hash step now passes toJSON(matrix), through an environment variable, to cigen hash
--matrix, which mixes the entry's canonical JSON into the job's hash. tests/matrix_skip.rs
runs the generated step once per entry: a failed entry runs again after another passed.
@ndbroadbent
ndbroadbent merged commit 440115c into main Dec 4, 2026
8 checks passed
ndbroadbent added a commit that referenced this pull request Dec 4, 2026
Ports #51: hashing::hash_job mixes a GitHub matrix entry into the job's hash
(matrix_entry.rs moved to src/hashing/matrix.rs with its tests), so hash
--matrix still gives each entry its own hash. cigen explain takes --matrix to
show an entry's hash, and for a job that runs a matrix without one, says each
entry is hashed in.
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.

False skip: entries of a GitHub strategy matrix share one skip key

1 participant