Skip to content

refactor(workflows): move sync and autofix run scripts into scripts/ - #548

Merged
DevSecNinja merged 1 commit into
devsecninja-lint-inline-scripts-release-workflowsfrom
devsecninja-lint-inline-scripts-sync-workflows
Nov 17, 2026
Merged

DevSecNinja merged 1 commit into
devsecninja-lint-inline-scripts-release-workflowsfrom
devsecninja-lint-inline-scripts-sync-workflows

Conversation

@DevSecNinja

Copy link
Copy Markdown
Owner

Description

Layer 2c of #537, stacked on #544. The multi-line run: blocks of the config-sync, apm-sync, apm-materialize, vendored-file-sync and autofix workflows move into scripts, following the pattern #543 and #544 set up. The inline-script checker now reports nothing to move for those five files (18 findings before; 0 to move, 2 documented opt-outs). Behaviour doesn't change: the script bodies are the old run: blocks, reindented by shfmt, and each keeps the shell options its step had (set -e where the step relied on the default bash -e, its own set -euo pipefail otherwise).

About 350 of the added lines are moved code. The hand-written part is the workflow wiring, the fetch-test change and the new tests.

Changes

  • scripts/config-sync/: sync-files.sh (the sync step) and ensure-label.sh. The Python heredoc that checks the renovate.json5 extends is now renovate-extends-preset.py, unchanged apart from a docstring.
  • scripts/apm-sync/: check-manifest.sh, install-apm.sh and update.sh.
  • scripts/apm-materialize/: the same three steps for the materialize workflow. It runs in this repository (push to main), not as a reusable workflow, so it calls them from its own checkout. docs/apm-sync-onboarding.md now says to copy the scripts along with the workflow.
  • scripts/vendored-file-sync/: detect-drift.sh, report-drift.sh and fetch-working-branch.sh. The refresher step is now the single line bash -c "${REFRESH_COMMAND}"; the dropped set -euo pipefail never applied inside bash -c, and the step still fails with its exit code.
  • scripts/autofix/: dprint.sh, yamlfmt.sh, shfmt.sh and commit-and-push.sh. Moving the scripts to $RUNNER_TEMP keeps them out of reach of the formatters and of git add ..
  • Every job that runs these scripts fetches scripts/<workflow>/ at job.workflow_sha and moves it to $RUNNER_TEMP, as in refactor(workflows): move pages, release and label-sync run scripts into scripts/ #544.
  • App-key preflights: the Resolve GitHub App credentials steps of config-sync and apm-sync stay inline with # lint: allow-inline-script and the same reason comment as release-please in refactor(workflows): move pages, release and label-sync run scripts into scripts/ #544. Their run: is untouched, so the hashes in tests/app-key-confinement.py still match, and nothing but harden-runner runs before them. The script fetch comes right after the preflight.
  • Signed API commits (feat(automation): sign config-sync and APM PR commits through the API #538): this layer doesn't touch the checkout or open-pr inputs. A trial merge with main auto-merges all three workflows, keeps persist-credentials: false and commit-method: api, and the checker still reports 0 to move on the merged files. The only conflict in that trial merge is lint.yml, which comes from the lower layers.
  • .github/actionlint.yaml: the job.workflow_* ignore now also covers the four reusable workflows.
  • Tests:
    • tests/workflow-script-fetch.py: the fetch steps may now follow harden-runner and the App-key preflights that tests/app-key-confinement.py pins (read from its EMPTINESS_CHECKS, so the two tests can't drift apart). Each script step must also come after the fetch. Scripts that a workflow calls from its own checkout (apm-materialize) must exist. The four reusable workflows join the expected list. Mutation checks: a step before the fetch, a missing script and a missing local script all fail it.
    • tests/config-sync-renovate-stub.sh, tests/config-sync-ai-toolkit-instructions.sh and tests/open-pr-push.sh run the scripts directly instead of extracting them from the workflows. Their cases are unchanged.
    • New tests/apm-scripts.sh: manifest check, both installers (with curl and python3 stand-ins) and apm update/apm install, including failures.
    • New tests/config-sync-scripts.sh: label creation, and a warning only when it fails.
    • New tests/vendored-file-sync-scripts.sh: drift detection (clean, unwatched, trimmed watched path, no paths) and the drift report.
    • New tests/autofix-scripts.sh: config selection for dprint and yamlfmt, shfmt, and commit-and-push against a bare remote.
    • tests/lint-inline-scripts.py runs the checker in blocking mode on the five files too.
  • docs/architecture.md: the Workflow scripts paragraph covers the preflight ordering and apm-materialize.

Refs #537

Checklist

  • Linting passes locally (mise exec -- lefthook run pre-commit)
    • No lefthook config exists at the repository root, so I ran the linters directly: actionlint (exit 0), shellcheck --rcfile config-sync/files/.shellcheckrc and shfmt -d on all new scripts (exit 0), default shellcheck and shfmt -d on the new and changed tests (exit 0), yamlfmt -lint and yamllint with the config-sync/files configs on the changed workflows (exit 0), dprint check on the two docs (exit 0), zizmor --offline on the five workflows (no findings).
    • uv run --script scripts/lint-inline-scripts.py --blocking on the five workflows: 0 to move, 2 opted out.
    • uv run --script tests/app-key-confinement.py: passed (4 token steps, 3 emptiness checks, 30 fixture cases).
    • uv run --script tests/workflow-script-fetch.py: passed (apm-sync 3, autofix 4, config-sync 2, label-sync 1, lint 32, pages 5, vendored-file-sync 3 script steps).
    • uv run --script tests/lint-inline-scripts.py: passed (10 files clean in blocking mode).
    • python3 tests/workflow-job-conditions.py: passed.
    • Bash tests on Debian/WSL: apm-scripts.sh, autofix-scripts.sh, config-sync-scripts.sh, vendored-file-sync-scripts.sh, config-sync-renovate-stub.sh, config-sync-ai-toolkit-instructions.sh, open-pr-push.sh, open-pr-api-commit.sh, open-pr-labels.sh, automation-app-contract.sh, release-please-auth-contract.sh, lint-job-modes-contract.sh, lint-scripts.sh, label-sync-scripts.sh, pages-scripts.sh, pages-custom-domain-contract.sh and copilot-model-policy-contract.sh passed.
    • Not run locally: the renovate, config-sync-lint-excludes and gitleaks tests, which need dprint or gitleaks in WSL. They cover areas this PR doesn't touch, and CI runs them.
  • Commit messages follow Conventional Commits
  • Documentation updated (if applicable)

@DevSecNinja
DevSecNinja requested a balanced review from Copilot November 16, 2026 19:37
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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 44 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d0a6bde5-2630-4bb1-8ab3-600add1b5f92
Commits

Reviewing files that changed from the base of the PR and between a49cb9e and 041317e.

Files selected for processing: 34

  • .github/actionlint.yaml
  • .github/workflows/apm-materialize.yml
  • .github/workflows/apm-sync.yml
  • .github/workflows/autofix.yml
  • .github/workflows/config-sync.yml
  • .github/workflows/vendored-file-sync.yml
  • .mise.toml
  • docs/apm-sync-onboarding.md
  • docs/architecture.md
  • scripts/apm-materialize/check-manifest.sh
  • scripts/apm-materialize/install-apm.sh
  • scripts/apm-materialize/install.sh
  • scripts/apm-sync/check-manifest.sh
  • scripts/apm-sync/install-apm.sh
  • scripts/apm-sync/update.sh
  • scripts/autofix/commit-and-push.sh
  • scripts/autofix/dprint.sh
  • scripts/autofix/shfmt.sh
  • scripts/autofix/yamlfmt.sh
  • scripts/config-sync/ensure-label.sh
  • scripts/config-sync/renovate-extends-preset.py
  • scripts/config-sync/sync-files.sh
  • scripts/vendored-file-sync/detect-drift.sh
  • scripts/vendored-file-sync/fetch-working-branch.sh
  • scripts/vendored-file-sync/report-drift.sh
  • tests/apm-scripts.sh
  • tests/autofix-scripts.sh
  • tests/config-sync-ai-toolkit-instructions.sh
  • tests/config-sync-renovate-stub.sh
  • tests/config-sync-scripts.sh
  • tests/lint-inline-scripts.py
  • tests/open-pr-push.sh
  • tests/vendored-file-sync-scripts.sh
  • tests/workflow-script-fetch.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the workflow-script extraction.

No open issues 🎉

What changed in this PR

Moves inline scripts from five sync and autofix workflows into scripts/, continuing #537’s effort to make workflow code directly lintable and testable.

Changes:

  • Replaces inline blocks with script calls while preserving shell options and documented App-key preflight exceptions.
  • Fetches reusable-workflow scripts at the pinned workflow commit and moves them outside the workspace; APM materialization uses its own checkout.
  • Adds script tests, strengthens fetch-order checks, and updates architecture and onboarding documentation.
File Description
tests/​workflow-script-fetch.py Checks preflight ordering, fetched-script ordering, and local script existence.
tests/​vendored-file-sync-scripts.sh Adds drift detection and reporting tests.
tests/​open-pr-push.sh Tests the extracted branch-fetch script directly.
tests/​lint-inline-scripts.py Adds the five workflows to blocking checks.
tests/​config-sync-scripts.sh Tests label creation and warning behavior.
tests/​config-sync-renovate-stub.sh Runs the extracted config-sync script directly.
tests/​config-sync-ai-toolkit-instructions.sh Tests APM ownership handling through the extracted script.
tests/​autofix-scripts.sh Tests formatter calls and commit-and-push behavior.
tests/​apm-scripts.sh Tests manifest checks, installers, and APM commands.
scripts/​vendored-file-sync/​report-drift.sh Extracts drift reporting and validation failure.
scripts/​vendored-file-sync/​fetch-working-branch.sh Extracts the working-branch fetch workaround.
scripts/​vendored-file-sync/​detect-drift.sh Extracts watched-path drift detection.
scripts/​config-sync/​sync-files.sh Extracts config and template synchronization.
scripts/​config-sync/​renovate-extends-preset.py Extracts the Renovate preset check from its heredoc.
scripts/​config-sync/​ensure-label.sh Extracts config-sync label creation.
scripts/​autofix/​yamlfmt.sh Extracts YAML formatting.
scripts/​autofix/​shfmt.sh Extracts shell formatting.
scripts/​autofix/​dprint.sh Extracts Markdown formatting and config selection.
scripts/​autofix/​commit-and-push.sh Extracts formatting commit and push logic.
scripts/​apm-sync/​update.sh Extracts APM package updates.
scripts/​apm-sync/​install-apm.sh Extracts installation through the official installer.
scripts/​apm-sync/​check-manifest.sh Extracts the sync manifest check.
scripts/​apm-materialize/​install.sh Extracts APM materialization.
scripts/​apm-materialize/​install-apm.sh Extracts pinned CLI installation through pip.
scripts/​apm-materialize/​check-manifest.sh Extracts the materialization manifest check.
docs/​architecture.md Documents preflight ordering and local materialization scripts.
docs/​apm-sync-onboarding.md Adds scripts to the adoption instructions.
.mise.toml Registers four new script test suites.
.github/​workflows/​vendored-file-sync.yml Fetches and invokes drift and branch-fetch scripts.
.github/​workflows/​config-sync.yml Wires extracted scripts after the inline credential preflight.
.github/​workflows/​autofix.yml Runs formatting scripts outside the workspace.
.github/​workflows/​apm-sync.yml Fetches and invokes scripts after the credential preflight.
.github/​workflows/​apm-materialize.yml Calls scripts from the repository checkout.
.github/​actionlint.yaml Extends workflow-context compatibility exceptions.

Review effort: Balanced

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>
@DevSecNinja
DevSecNinja force-pushed the devsecninja-lint-inline-scripts-sync-workflows branch from 3572389 to 041317e Compare November 17, 2026 11:09
@DevSecNinja
DevSecNinja merged commit defbbea into main Nov 17, 2026
38 checks passed
@DevSecNinja
DevSecNinja deleted the devsecninja-lint-inline-scripts-sync-workflows branch November 17, 2026 12:33
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.

2 participants