Skip to content

Add cigen plan: hashes for a setup job, and the CircleCI config to continue with - #52

Open
ndbroadbent wants to merge 4 commits into
mainfrom
providers/cigen-plan
Open

ndbroadbent wants to merge 4 commits into
mainfrom
providers/cigen-plan

Conversation

@ndbroadbent

@ndbroadbent ndbroadbent commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

CircleCI parity item (b), part 1 of 2: the command the setup job will call. Part 2 generates the setup job, the job markers and the gate, with mockci scenarios on #41's CircleCI mode. It also resolves STATUS 13.

What changed

  • cigen plan --hash-dir <dir> --job <id>[=<modules digest>]... writes each job's hash to <dir>/<id>: the hash cigen hash --job prints, from one pass over the files. The =digest form matches the job's own --modules-digest, so the planner's hash and the job's are the same. A job it can't hash, or a config that doesn't load, gets a one-off unplanned-… value that no pass is recorded under, so the job runs. The setup job's {{ checksum }} always has a file to read.
  • cigen plan --circleci-continue <main.yml> --passed <dir> --output <file> drops each job that has a file in --passed, closed under requires: a passed job stays while a job that requires it runs. cigen_gate always stays, requiring only the remaining jobs, and its CIGEN_GATE_JOBS list shrinks to match. If it can't plan a config (bad YAML, no workflows, a workflow that would be left empty), it writes the config unchanged, so every job runs. When it skips nothing, the output is the input byte for byte.
  • hash.rs gains only job_hashes, at the end, so it stays out of tools' Add cigen explain <job>: what a job's hash covers #14's way (Add cigen explain <job>: what a job's hash covers #14 moves hashing to src/hashing/).
  • Docs: a cigen plan section in cli.md. STATUS: the CLI line and the tests list. No generated config calls it yet; both say so.

Testing

tests/cigen_plan.rs (4 tests):

  • hashes match cigen hash --job, with and without a digest, and change when an input changes;
  • an unknown job gets an unplanned- value;
  • a passed job is dropped and the gate trimmed;
  • a passed job stays while a dependent runs;
  • configs it can't plan are written unchanged.

With the closure loop removed, the dependent test fails. task ci green.


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

…ntinue with

CircleCI parity item (b), first part: the command the setup job will call.
The provider doesn't call it yet; that's the next PR, with the gate and
mockci scenarios.

- `cigen plan --hash-dir <dir> --job <id>[=<modules digest>]...` writes each
  job's hash to <dir>/<id>, the hash `cigen hash --job` prints, from one pass
  over the files. A job it can't hash (or a config that doesn't load) gets a
  one-off value no pass is recorded under, so the job runs.
- `cigen plan --circleci-continue <main.yml> --passed <dir> --output <file>`
  drops each job with a file in --passed, closed under requires: a passed job
  stays while a job that requires it runs. cigen_gate always stays, requiring
  the jobs that remain, and its CIGEN_GATE_JOBS list shrinks to match. A
  config it can't plan is written unchanged, so every job runs; with nothing
  to skip, the output is the input byte for byte.

hash.rs gains only `job_hashes` at the end, so it stays out of the way of
tools' #14, which moves hashing to src/hashing/.
…icate names, approvals, ids

--circleci-continue applies YAML merge keys first, continues unchanged when a workflow entry has
`matrix` or one name runs different jobs in two workflows, and checks that every remaining
`requires` names an entry still in its workflow. It writes the planned config as JSON, so
CircleCI's YAML 1.1 reads every string as written ("yes", "1:20"). An approval goes when
everything waiting on it does. With --hash-dir, a pass counts only if its file holds the job's
current hash.

--hash-dir writes the bytes `cigen hash --job` prints, newline included (CircleCI keys on the
file's checksum, so the setup job's key never matched a job's). Ids with `/` get subdirectories,
ids that would leave the directory are refused, and a job that can't be written runs instead of
stopping the rest.
# Conflicts:
#	docs/src/content/docs/cli.md
#	internal_docs/STATUS.md
#	src/commands/hash.rs
#	src/commands/mod.rs
#	src/main.rs

This branch has not been deployed

No deployments
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