Skip to content

Hash the inputs a job doesn't declare: commands, scripts, toolchain pins - #6

Merged
ndbroadbent merged 1 commit into
mainfrom
inputs/derived
Dec 3, 2026
Merged

ndbroadbent merged 1 commit into
mainfrom
inputs/derived

Conversation

@ndbroadbent

@ndbroadbent ndbroadbent commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Automatically derived inputs: the second part of step 3 in internal_docs/DIRECTION.md. It fixes a false-skip risk. A job's hash covered only its own definition and declared inputs, so changing a command it uses, a script its steps run or the toolchain version left the job skipping.

What cigen hash --job adds now (src/inputs.rs)

  • The commands the job uses, including commands used through other commands.
  • The services it names, as defined in the top-level services.
  • The top-level github: and circleci: blocks.
  • Every project file its steps name: sh scripts/check.sh, require('./.github/wait-for-checks.js'), every file of a local uses: ./action.
  • Root toolchain pins (rust-toolchain.toml, .ruby-version, .nvmrc, .tool-versions, …), lockfiles, and package.json's packageManager.

Each rule includes too much rather than too little. An extra input costs a rerun; a missing one turns a real failure into a green check.

Tests

tests/derived_inputs.rs:

  • mockci scenarios: a job runs again after a script it calls or a toolchain pin changes, and still skips after an unrelated change.
  • Hash tests: the hash changes for a command used two levels deep, a named service, a top-level provider block, a local action, a lockfile and packageManager. It doesn't change for an unused command or service. These are hash tests because the GitHub provider doesn't render commands or services yet (new STATUS known problem 12).

With derivation disabled, 7 of the 8 tests fail. The eighth is the control.

The mockci helpers moved to tests/support/skip.rs so both test files share them.

Known gaps (STATUS known problem 1)

  • Files a script mentions aren't followed.
  • Paths are looked up from the project root, so a step with a working-directory can miss its script.
  • Image tags aren't resolved to digests.
  • Pins and lockfiles go into every job. Modules will narrow that per toolchain.

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

A job's hash covered its definition and declared inputs, so changing a
command it uses, a script its steps run or the toolchain version left
the job skipping: a false skip. cigen hash --job now adds, on top of
the declared inputs (src/inputs.rs):

- the commands the job uses, through other commands too
- the services it names, as defined at the top level
- the top-level github: and circleci: blocks
- every project file its steps name (sh scripts/check.sh,
  require('./x.js')) and every file of a local uses: ./action
- root toolchain pins, lockfiles and package.json packageManager

Each rule includes too much rather than too little. The mockci
scenarios show a job runs after a script or toolchain pin changes, and
hash tests cover the rest (the GitHub provider doesn't render commands
or services yet). With derivation disabled, seven of the eight new tests
fail; the eighth checks that an unnamed file still skips.
@ndbroadbent
ndbroadbent merged commit 2f74a8c into main Dec 3, 2026
6 checks passed
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