Skip to content

fix: make e2e localizer uses-rewrite idempotent - #143

Merged
joshua-temple merged 1 commit into
mainfrom
fix/e2e-localizer-idempotent-uses
Jun 13, 2026
Merged

joshua-temple merged 1 commit into
mainfrom
fix/e2e-localizer-idempotent-uses

Conversation

@joshua-temple

Copy link
Copy Markdown
Collaborator

Problem

After the generator began emitting fully-qualified local callback paths (uses: ./.github/workflows/build.yaml), the harness reusable-workflow localizer in e2e/harness/harness.go kept running a stale sed (s|uses: \([^/][^@]*\.yaml\)|uses: ./\1|g). Its leading [^/] matched the already-present ., so it prepended a second ./ and produced uses: ././.github/workflows/build.yaml, which act cannot resolve.

This breaks three scenarios on main:

  • Inline_Run_Callback (12) and Inline_Job_Attributes (10) fail their uses: ./.github/workflows/build.yaml substring assertion.
  • Promote_rolls_back_a_successful_deploy_when_a_sibling_deploy_fails corrupts the reusable-deploy uses: the same way, so the appdeploy/infradeploy jobs never run and step 6 sees empty conclusions.

Fix

Tighten the capture group to a bare filename: s|uses: \([^./@][^/@]*\.yaml\)|uses: ./\1|g. This rewrite is now idempotent. It skips values already starting with . or /, anything containing @ (cross-repo owner/repo/...@ref), and any path with an embedded /, while still localizing a bare build.yaml to ./build.yaml. The two sed expressions are extracted to named constants and the stale comment is updated.

Verification (local Docker is down, so the act suite could not run)

  • go build ./..., cd e2e && go vet ./..., and golangci-lint run ./... are all clean.
  • New unit test TestUsesLocalizeSedExpr_Idempotent_LeavesQualifiedPathsUnchanged runs the exact expression and asserts no ././ is produced and a second pass is a no-op.
  • Generated the scenario-12 and rollback configs with the built CLI, then ran both the old and new expressions over the real generated lines:
    • old: uses: ././.github/workflows/build.yaml and ././.github/workflows/deploy-{infra,app}.yaml
    • new: uses: ./.github/workflows/build.yaml and ./.github/workflows/deploy-{infra,app}.yaml

The post-merge Orchestrate e2e run is the final confirmation. This is expected to resolve all three failing scenarios (10, 12, and the rollback scenario via the corrected reusable-deploy uses:).

The harness reusable-workflow localizer prefixed any `uses:` value
matching `[^/]...\.yaml` with `./`. Once the generator began emitting
fully-qualified local callback paths (`uses: ./.github/workflows/build.yaml`),
the leading `.` matched `[^/]` and the rewrite produced `uses: ././...`,
which act cannot resolve.

Tighten the capture group to a bare filename (no leading `.`, `/`, or `@`
and no embedded `/`) so already-qualified local paths and cross-repo
`owner/repo/...@ref` values are left unchanged while a bare `build.yaml`
still gains its `./` prefix. Extract the two sed expressions to named
constants and add an idempotency test that runs the real expression and
asserts no `././` is ever produced.

Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
@joshua-temple
joshua-temple merged commit c027741 into main Jun 13, 2026
6 checks passed
@joshua-temple
joshua-temple deleted the fix/e2e-localizer-idempotent-uses branch June 13, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant