Repository navigation
refactor(workflows): move pages, release and label-sync run scripts into scripts/ - #544
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 50 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified, though runtime tests and linters were not run during the static review.
No open issues 🎉
What changed in this PR
Continues #537’s inline-script cleanup, extending the pattern from #543 to the shared Pages, label-sync, and release workflows. The refactor moves shell logic into directly testable scripts while preserving existing behavior.
Changes:
- Extracts Pages and label-sync scripts, fetched at the reusable workflow’s SHA and moved outside the caller’s workspace.
- Simplifies the release command and documents the unchanged release-please credential preflight’s inline exception.
- Adds script tests and checkout-contract checks, expands inline-script enforcement, and updates architecture documentation.
Runtime tests and linters were not run during this static review.
| File | Description |
|---|---|
tests/workflow-script-fetch.py |
Checks script checkout, pinning, paths, and conditions. |
tests/pages-scripts.sh |
Covers Cloudflare detection, sitemap updates, and preview cleanup. |
tests/pages-custom-domain-contract.sh |
Tests extracted validation and registration scripts directly. |
tests/lint-inline-scripts.py |
Adds four workflows to blocking checks. |
tests/label-sync-scripts.sh |
Covers config selection and missing-file handling. |
scripts/pages/validate-inputs.sh |
Extracts Pages input validation. |
scripts/pages/update-sitemap-lastmod.sh |
Extracts sitemap date updates. |
scripts/pages/register-cloudflare-domain.sh |
Extracts custom-domain registration and DNS handling. |
scripts/pages/detect-cloudflare.sh |
Extracts Cloudflare deployment-target selection. |
scripts/pages/delete-preview-deployments.sh |
Extracts branch-specific preview cleanup. |
scripts/label-sync/resolve-config-files.sh |
Extracts label config-file resolution. |
docs/architecture.md |
Documents script layout, fetching, and the credential exception. |
.mise.toml |
Registers the new tests. |
.github/workflows/release.yml |
Converts release creation to one command line. |
.github/workflows/release-please.yml |
Documents and marks the unchanged inline preflight exception. |
.github/workflows/pages.yml |
Fetches and invokes the extracted Pages scripts. |
.github/workflows/label-sync.yml |
Fetches and invokes the label config resolver. |
.github/actionlint.yaml |
Extends workflow-context compatibility ignores. |
Review effort: Balanced
f1821d8 to
0ff5646
Compare
Layer 2c of #537. The multi-line run: blocks of the config-sync, apm-sync, apm-materialize, vendored-file-sync and autofix workflows move into scripts/<workflow>/, fetched at job.workflow_sha like #543 and #544 did. The App-key preflights of config-sync and apm-sync stay inline with a lint opt-out, since tests/app-key-confinement.py pins them, and tests/workflow-script-fetch.py now lets them (and harden-runner) run before the fetch steps. Refs #537 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
release.yml calls gh release create on one line. The Release Please credential preflight reads the App key, so it stays inline with a documented opt-out: tests/app-key-confinement.py pins its run: by SHA-256 and allows no earlier step, which a script fetch would need. Refs #537 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…l-sync The job fetches the script at job.workflow_sha and moves it to $RUNNER_TEMP before the code checkout, as lint.yml does. Adds tests/label-sync-scripts.sh. Refs #537 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The five multi-line run blocks become scripts that each job fetches at job.workflow_sha. The deploy job only fetches them when update-sitemap-lastmod is set. pages-custom-domain-contract.sh now runs the scripts directly, and tests/pages-scripts.sh covers Cloudflare detection, the sitemap update and preview cleanup. Refs #537 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
tests/workflow-script-fetch.py checks every reusable workflow job that runs a script from $RUNNER_TEMP. The inline-script test now runs pages, release, release-please and label-sync in blocking mode, and docs/architecture.md describes where workflow scripts live. Refs #537 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2f5e255 to
a49cb9e
Compare
Layer 2c of #537. The multi-line run: blocks of the config-sync, apm-sync, apm-materialize, vendored-file-sync and autofix workflows move into scripts/<workflow>/, fetched at job.workflow_sha like #543 and #544 did. The App-key preflights of config-sync and apm-sync stay inline with a lint opt-out, since tests/app-key-confinement.py pins them, and tests/workflow-script-fetch.py now lets them (and harden-runner) run before the fetch steps. Refs #537 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Description
Layer 2b of #537, stacked on #543. The multi-line
run:blocks of the reusablepages,release,release-pleaseandlabel-syncworkflows move into scripts, following the pattern #543 set up forlint.yml. The inline-script checker now reports nothing for those four files (8 findings before; 0 to move, 1 documented opt-out). Behaviour doesn't change: the script bodies are the oldrun:blocks, reindented by shfmt. I checked each one against its original block after shfmt; the only differences are the lint fixes listed below.Changes
scripts/pages/:validate-inputs.sh,detect-cloudflare.sh,update-sitemap-lastmod.sh,register-cloudflare-domain.shanddelete-preview-deployments.sh, one per formerrun:block ofpages.yml. Every job that runs one starts with Checkout pages scripts (sparse checkout ofscripts/pages/atjob.workflow_sha) and Move pages scripts out of the workspace (mvto$RUNNER_TEMP). The privilegeddeployjob only fetches them whenupdate-sitemap-lastmodis set, so the GitHub Pages deploy does no extra checkout otherwise.${{ }}values still reach the scripts only throughenv:.scripts/label-sync/resolve-config-files.sh: the config-file resolver oflabel-sync.yml, with the same fetch and move steps before the code checkout.release.yml:gh release createis now a single line. No script needed.release-please.yml: the Validate GitHub App credentials step stays inline with# lint: allow-inline-scriptand a comment giving the reason. It reads the App private key, sotests/app-key-confinement.pypins itsrun:by SHA-256, checks how it reads the key, and allows no step before it except harden-runner. Moving it to a fetched script would need a checkout step before it and would take the key-reading code out of reach of that test. Itsrun:is unchanged, so the pinned hash still matches. The App key stays confined to the token step.config-sync/files/.shellcheckrc:${REPOSITORY_NAME}braces, a no-op*) ;;default case, and two justifiedshellcheck disablecomments (SC2153 for an env input, SC2312 forapi_errors, which never fails)..github/actionlint.yaml: thejob.workflow_*ignore from refactor(lint): move lint.yml run scripts into scripts/lint #543 now also coverspages.ymlandlabel-sync.yml.tests/pages-custom-domain-contract.shrunsvalidate-inputs.shandregister-cloudflare-domain.shdirectly instead of extracting them from the workflow. All existing cases are unchanged.tests/pages-scripts.shcovers the pages scripts that had no tests: Cloudflare detection (disabled, missing secrets, invalid project name, production/acceptance targets, production-on-release), the sitemaplastmodupdate, and preview cleanup with a curl stand-in (branch filter, failed delete only warns, list and parse failures).tests/label-sync-scripts.shcovers merging, skipping and the no-files error.tests/workflow-script-fetch.pychecks every reusable-workflow job that runs a$RUNNER_TEMPscript: it must start with a SHA-pinned checkout ofjob.workflow_repositoryatjob.workflow_shawithout persisted credentials, followed by themv. The sparse checkout must include the script, the script must exist, and a conditional fetch must share its condition with every step that runs a script. It coverslint.ymlas well.tests/lint-inline-scripts.pyruns the checker in blocking mode on the four files as well aslint.yml.docs/architecture.md: a Workflow scripts paragraph on where scripts live, how jobs fetch them, and the App-key preflight exception.scripts/andtests/are added to the layout tree.Known edge (same as #543): if fetching the scripts fails, the job fails at that step instead of at the script.
Refs #537
Checklist
mise exec -- lefthook run pre-commit)actionlint(exit 0),shellcheck --rcfile config-sync/files/.shellcheckrcandshfmt -don all new scripts (exit 0),yamlfmt -lintandyamllintwith theconfig-sync/filesconfigs on the changed workflows (exit 0),dprint checkondocs/architecture.md(exit 0),zizmor --offlineon the four workflows (no findings)..shellcheckrcthey report only the opt-in SC2310/SC2312 info checks, the same ones the existing tests already report.uv run --script scripts/lint-inline-scripts.py --blockingon the four workflows: 0 to move, 1 opted out.uv run --script tests/app-key-confinement.py: passed (4 token steps, 3 emptiness checks, 30 fixture cases).uv run --script tests/lint-inline-scripts.py: passed (5 files clean in blocking mode).uv run --script tests/workflow-script-fetch.py: passed (label-sync 1, lint 32, pages 5 script steps). A mutation check confirmed it catches a missing condition, a wrong ref, a missing move step and a script left out of the sparse checkout.python3 tests/workflow-job-conditions.py: passed (18 pages.yml scenarios).pages-custom-domain-contract.sh,pages-scripts.sh,label-sync-scripts.sh,release-please-auth-contract.sh,automation-app-contract.sh,lint-job-modes-contract.sh,lint-scripts.sh,open-pr-*.sh,copilot-model-policy-contract.shandconfig-sync-ai-toolkit-instructions.shpassed.config-sync-lint-excludes,config-sync-renovate-stuband gitleaks tests, which need pyjson5, dprint or gitleaks in WSL. They cover areas this PR doesn't touch, and CI runs them.