Add auto-hoist-run-expressions codemod: hoist all ${{ ... }} run-block expressions to env bindings#32533
Draft
Copilot wants to merge 8 commits into
Draft
Add auto-hoist-run-expressions codemod: hoist all ${{ ... }} run-block expressions to env bindings#32533Copilot wants to merge 8 commits into
auto-hoist-run-expressions codemod: hoist all ${{ ... }} run-block expressions to env bindings#32533Copilot wants to merge 8 commits into
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…on hoisting Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add codemod to auto-hoist run-block ${{ ... }} expressions
Add May 16, 2026
auto-hoist-run-expressions codemod: hoist all ${{ ... }} run-block expressions to env bindings
pelikhan
reviewed
May 16, 2026
Comment on lines
+156
to
+157
| "steps-run-secrets-to-env", | ||
| "auto-hoist-run-expressions", |
Contributor
Author
There was a problem hiding this comment.
They're distinct and complementary:
steps-run-secrets-to-envhandles onlysecrets.*,env.*, andgithub.token, producing names likeMY_TOKEN,GH_AW_ENV_FOO,GH_AW_GITHUB_TOKEN.auto-hoist-run-expressionsis a catch-all for every remaining${{ ... }}expression (e.g.github.repository,inputs.*,steps.*.outputs.*) that slips past the first codemod, using theEXPR_prefix naming convention.
Because steps-run-secrets-to-env runs first and replaces its specific patterns, auto-hoist-run-expressions never sees those expressions again — it only picks up anything the first codemod didn't handle.
Collaborator
|
@copilot merge both code modes, move all expressions out of runs |
Extend the existing codemod to handle ALL ${{ ... }} expressions in
run: blocks, not just secrets.*, env.*, and github.token. Non-legacy
expressions receive EXPR_* names. PowerShell steps (shell: pwsh /
powershell) get $env:VARNAME syntax. Remove the separate
auto-hoist-run-expressions codemod.
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Contributor
Author
Done.
Commit: the latest two commits on this branch. |
Collaborator
|
@copilot recompile, add tests, fuzz tests |
- Update FuzzStepsRunSecretsToEnvCodemod: check no ${{ ... }} remains
in run line (was checking only specific patterns)
- Add FuzzStepsRunSecretsToEnvCodemodExpr: covers EXPR_* naming for
generic property-access chains (github.X, inputs.X, etc.)
- Add FuzzStepsRunSecretsToEnvCodemodPowerShell: verifies $env:VARNAME
output for pwsh/powershell steps
- Add sanitizeHoistPropertySegment helper for generating valid
property-chain segments
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Contributor
Author
Done. Build passes. Three fuzz functions now cover the merged codemod:
Commits: the last two on this branch. |
Collaborator
|
@copilot recompile, add tests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The existing
steps-run-secrets-to-envcodemod only handlessecrets.*,env.*, andgithub.token— leaving expressions likegithub.repository,inputs.*, orsteps.*.outputs.*inrun:scripts, which triggers the compiler's hard"compiler regression detected"guardrail error with no automated fix path.New codemod:
auto-hoist-run-expressionsCovers every
${{ ... }}expression that slips paststeps-run-secrets-to-env, registered immediately after it in the codemod chain.Naming convention:
EXPR_+ sanitised uppercase body:github.token→EXPR_GITHUB_TOKEN,inputs.my-input→EXPR_INPUTS_MY_INPUTEXPR_<fnv32-8hex>for collision safetyPowerShell awareness: steps with
shell: pwshorshell: powershellget$env:VARNAMEinstead of$VARNAME.Before / After (the failing
microsoft/aspirepattern):Changes
pkg/cli/codemod_auto_hoist_run_expressions.go— codemod implementation; reuses sharedparseStepKeyLine/effectiveStepLineIndentLen/hashedBindingNamehelpers from the existing codemodpkg/cli/codemod_auto_hoist_run_expressions_test.go— 18 test cases covering: block and inline run forms, simple/complex/PowerShell/multi-expression/dedup/pre-existing-binding scenariospkg/cli/fix_codemods.go— registers codemod aftersteps-run-secrets-to-envpkg/cli/fix_codemods_test.go— updates expected count (48 → 49) and orderdocs/— adds codemod tocli.mdandgh-aw-as-mcp-server.md.changeset/— minor release entry