Skip to content

test(cli): isolate the CLI release tag cases from the runner identity - #3973

Merged
yannickmonney merged 1 commit into
mainfrom
test/cli-release-tag-fixture-identity
Sep 30, 2026
Merged

yannickmonney merged 1 commit into
mainfrom
test/cli-release-tag-fixture-identity

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

What changed

tools/cli/src/lib/compose/services/compose-parity.test.ts is the only file this PR touches. Each CLI release tag case now owns its whole dispatch identity.

Root cause (#3970).

  • The CLI Resolve version step (cli.yml prepare) reads the runner's own GITHUB_REF and GITHUB_SHA, besides its mapped inputs:
    • the exact-tag guard, cli.yml:89;
    • the exact-source guard, cli.yml:98.
  • The cases ran the real step through shell, which spreads process.env into the child. They named only RELEASE_TAG and the tag source.
  • Inside the v0.5.64 publication runner (run 36658878748, workflow_dispatch on refs/tags/v0.5.64), the valid synthetic tags v0.5.42, 0.5.42 and v0.5.42-rc.1 hit the exact-tag guard. They exited 1 at :1069 on all five platforms.
  • The same-source candidate run 36654688277 (repository_dispatch on main) never took that path, so it passed.

Fix.

  • A typed resolveCliRelease({ RELEASE_TAG, GITHUB_REF, GITHUB_SHA, TEST_TAG_SOURCE? }) runs the real extracted step with the existing shell helper and the inert gh shell-function stand-in. EVENT_NAME, REPOSITORY and GITHUB_OUTPUT are always set.
  • The six existing tag cases each run twice:
    • from a branch: refs/heads/main at a branch head that is not the tag's commit. It still publishes the tag's commit.
    • from the tag itself: refs/tags/<tag> at the tag's commit.
  • Three new refusals each assert their own ::error:: line and that no outputs were written:
    • another tag ref (refs/tags/v0.5.41);
    • the same version under another tag name (refs/tags/0.5.42 for v0.5.42);
    • the tag has since moved: it resolves to a commit other than the dispatched one.
  • The invalid-tag cases now also assert the semantic-version refusal, not just exit 1.
  • Regression lock. Every case must decide alike in two environments: its caller's, and a synthetic tag-publication runner for another tag at another commit (GITHUB_REF=refs/tags/v0.5.64, GITHUB_SHA=d…d). A branch, PR or candidate run therefore exercises the tag-runner context too, so a leak like this one can no longer hide until publication.

Unchanged.

  • .github/workflows/cli.yml: the exact-tag and exact-source guards are byte-identical.
  • The shared shell helper, and every other fixture.
  • Nothing is skipped on tags.

Sweep of sibling release fixtures. None of the others reads the runner's identity.

  • In compose-parity:
    • resolveRelease pins EVENT_NAME=workflow_dispatch, so release.yml never reaches its GITHUB_REF branch.
    • The image-pull, container-check, document-gate and CLI-dispatch scripts read no GITHUB_* at all.
  • release-candidate-workflows.test.ts sets GITHUB_REF and GITHUB_SHA itself.
  • deployment-ci.test.ts builds its env from PATH plus explicit values.

How I verified it

Everything below ran locally. The outer contexts are plain environment variables. There was no network, no gh and no dispatch. Old = origin/main 89109e3c0; new = this branch at e37c741.

-t 'CLI release' in compose-parity old new
ordinary 7 pass 10 pass
outer refs/tags/v0.5.64 @ ebf4546f (the publication) 3 fail: v0.5.42, 0.5.42, v0.5.42-rc.1 at :1069 10 pass
outer refs/heads/main @ ebf4546f (the candidate) 7 pass 10 pass
outer refs/tags/v0.5.42 @ the fixture's mock source 2 fail: 0.5.42, v0.5.42-rc.1 10 pass
outer refs/tags/v0.5.42 @ ebf4546f (wrong inherited source) 3 fail 10 pass
Whole suite old new
compose-parity, ordinary 86 pass 89 pass
compose-parity, outer tag publication 83 pass / 3 fail 89 pass
release-candidate-workflows + deployment-ci, ordinary / outer tag — 39 / 39 pass
whole CLI unit suite (bun test --timeout 30000, the publication job's own step), ordinary 1454 pass / 19 skip / 14 fail 1457 pass / 19 skip / 14 fail
same, outer tag publication 1451 pass / 19 skip / 17 fail (the three + the same 14) 1457 pass / 19 skip / 14 fail

The 14 whole-suite failures are identical in all four cells and are specific to this sandbox:

  • six historical/legacy config-release tests: Git 2.39 here has no archive --mtime;
  • four OpenSSH source-acquisition tests: no ssh-keygen here;
  • two action-archive tests: a 512 MiB file-size limit kills git archive of this repository (SIGXFSZ);
  • two rollback-confirmation cases: they pass alone here but fail in the full local run, on both trees.

The publication's own Linux log shows none of them (1465 pass / 19 skip / 3 fail, of the same 1487 tests).

Mutations. Each ran in the ordinary context, and each file was restored byte-for-byte afterwards:

  • The caller's runner identity overrides the fixture's: the three valid tags fail, plus the moved-tag refusal (wrong reason).
  • The fixture drops GITHUB_REF/GITHUB_SHA, i.e. the CLI tag publication tests inherit the runner ref and reject valid fixtures #3970 shape: 6 fail.
  • cli.yml without the exact-tag guard: exactly the two wrong-ref refusals fail.
  • cli.yml without the exact-source guard: exactly the moved-tag refusal fails.

Gates on the changed file:

  • oxfmt --check: clean.
  • oxlint (the package's lint): clean.
  • oxlint --type-aware --type-check: the same 28 pre-existing findings as on origin/main, and none new.
  • tsc --noEmit over the file and its imports: clean.
  • Opengrep: 0 findings.

Closes #3970

The CLI `Resolve version` step reads the runner's own GITHUB_REF and
GITHUB_SHA besides its mapped inputs. Its compose-parity cases ran it
through `shell`, which hands them the caller's environment, and named
only RELEASE_TAG and the tag source. Inside the v0.5.64 publication
runner (refs/tags/v0.5.64) the valid synthetic tags v0.5.42, 0.5.42 and
v0.5.42-rc.1 therefore hit the exact-tag guard and exited 1. The branch
candidate never took that path, so it passed the same source.

Every case now names its whole dispatch: EVENT_NAME, RELEASE_TAG,
REPOSITORY, GITHUB_REF, GITHUB_SHA and the tag source. Each tag runs
from a branch (building the tag's commit, not the branch head) and from
the tag itself. New refusals cover another tag ref, the same version
under another tag name, and a tag that has since moved to another
commit. Every case must decide alike in its caller's environment and
inside a synthetic publication runner for another tag at another
commit. So a branch run now catches a tag-only leak.

The workflow's exact-tag and exact-source guards are unchanged.

Closes #3970
@yannickmonney
yannickmonney merged commit 74b6efd into main Sep 30, 2026
26 checks passed
@yannickmonney
yannickmonney deleted the test/cli-release-tag-fixture-identity branch September 30, 2026 06:58
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.

CLI tag publication tests inherit the runner ref and reject valid fixtures

1 participant