Skip to content

Copilot: pre-warm wp-env in the coding agent's setup steps#2473

Merged
westonruter merged 5 commits into
trunkfrom
add/copilot-setup-steps
May 19, 2026
Merged

Copilot: pre-warm wp-env in the coding agent's setup steps#2473
westonruter merged 5 commits into
trunkfrom
add/copilot-setup-steps

Conversation

@westonruter
Copy link
Copy Markdown
Member

@westonruter westonruter commented May 13, 2026

Fixes #2351

Summary

  • Adds .github/workflows/copilot-setup-steps.yml, the workflow GitHub Copilot's coding agent runs in its dev environment before its network firewall engages.
  • Pre-fetches everything the agent needs offline later: WordPress core (from wordpress.org), Composer + npm packages, the Docker images wp-env pulls, and the built plugin assets.

Why

In #2461 the Copilot agent failed running composer test:plugins because its firewall blocked DNS for wordpress.org — see this comment. wp-env start (which npm run test-php triggers) downloads WordPress core at runtime, and the agent never gets a chance to allowlist the host.

The setup-steps workflow is GitHub's intended fix for this: it runs the same install/build/start sequence as php-test-plugins.yml while the network is still open, so by the time the firewall locks down DNS, everything is already on disk or in the local Docker cache.

The filename (copilot-setup-steps.yml) and the job name (copilot-setup-steps) are required exactly — Copilot won't pick it up otherwise — and the workflow only takes effect once it's on the default branch. See the GitHub docs.

Test plan

  • After merging to trunk, trigger a new Copilot coding agent run on a follow-up task that calls npm run test-php and confirm the wordpress.org DNS block no longer appears.
  • Sanity-check the workflow itself: the push / pull_request path filter on this PR will exercise it. Confirm all steps succeed on Actions.

🤖 Generated with Claude Code

The Copilot coding agent's firewall blocks DNS for hosts not on its
allowlist, so `wp-env start` (called from `npm run test-php`) fails when
it tries to download WordPress core from wordpress.org.

Add `.github/workflows/copilot-setup-steps.yml`, the special workflow
Copilot runs in its dev environment before the firewall engages, to
pre-fetch everything the agent will need offline later: WordPress core,
Composer/npm packages, and the Docker images wp-env uses. The filename
and the `copilot-setup-steps` job name are both required exactly for
Copilot to pick it up, and the file must be on the default branch to
take effect.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 13, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: westonruter <[email protected]>
Co-authored-by: mukeshpanchal27 <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@westonruter westonruter added [Type] Enhancement A suggestion for improvement of an existing feature no milestone PRs that do not have a defined milestone for release labels May 13, 2026
westonruter and others added 2 commits May 14, 2026 11:32
The repo's .npmrc sets `ignore-scripts = true` to mitigate supply-chain
attacks, which also blocks this project's own `prepare` script from
running. So `npm ci` leaves the husky pre-commit hooks (phpstan-diff,
PHPCS) uninstalled. Run `npm run prepare` explicitly so the agent's
commits get the same hook coverage as a local contributor's.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
westonruter and others added 2 commits May 14, 2026 11:43
Pull two additions over from #2352 (Copilot's own attempt at this
workflow):

- Pin PHP via shivammathur/setup-php so `composer install` runs against
  a deterministic interpreter across runner image updates. Pinned to
  8.2 since that's the WordPress.org-reported most-used PHP version,
  which matches what most plugin users actually run.
- Cache the Composer cache directory across runs. The first session
  still pays the full packagist download cost, but subsequent setup-step
  runs restore the cache and `composer install` does much less network
  work — which both speeds the agent up and reduces firewall surface.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@westonruter westonruter merged commit 5e04750 into trunk May 19, 2026
10 checks passed
@westonruter westonruter deleted the add/copilot-setup-steps branch May 19, 2026 16:25
@westonruter
Copy link
Copy Markdown
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no milestone PRs that do not have a defined milestone for release [Type] Enhancement A suggestion for improvement of an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨ Set up Copilot instructions

2 participants