Build/test tools: retry Docker image pulls in PHPUnit workflows - #12703
Build/test tools: retry Docker image pulls in PHPUnit workflows#12703lancewillett wants to merge 2 commits into
Conversation
Transient Docker Hub connection timeouts currently fail the affected matrix job immediately. Pre-pull the required images with a bounded retry before starting the Docker environment. Fixes #65722. Props lance.willett@automattic.com
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Pull request overview
This PR improves the reliability of the reusable PHPUnit GitHub Actions workflow by pre-pulling the Docker images needed for the local test environment with a bounded retry/backoff strategy, reducing transient Docker Hub/network failures before env:start.
Changes:
- Adds a new step to pre-pull the relevant Docker Compose services before starting the environment.
- Implements up to 3 pull attempts with incremental waits (10s, then 20s), and conditionally includes
memcachedwhen enabled.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| services=(wordpress-develop php mysql cli) | ||
| if [ "$LOCAL_PHP_MEMCACHED" = "true" ]; then | ||
| services+=(memcached) | ||
| fi | ||
|
|
||
| for attempt in 1 2 3; do | ||
| if docker compose pull --quiet "${services[@]}"; then | ||
| break | ||
| fi |
There was a problem hiding this comment.
Good catch on the resolution mismatch. Rather than list services by hand (which would also drift as services change), we switched the retry to wrap npm run env:pull (docker.js pull). It resolves the compose files through get_compose_files(), the same source of truth env:start uses, which removes the divergence risk entirely. See 7d72ff4.
The pre-pull retry step hardcoded its own list of Docker Compose services (and a separate conditional for memcached), which duplicates the service resolution that `npm run env:start` already performs via `get_compose_files()`. Replace the hardcoded list with `npm run env:pull`, which resolves the same compose files as `env:start` and picks up memcached and any compose override automatically, while keeping the existing 3-attempt retry with backoff. Props lance.willett@automattic.com.
Transient Docker registry failures (Docker Hub / GHCR pull timeouts and "premature close" errors) intermittently fail the PHPUnit jobs. Wrap the image pulls in a bounded retry with backoff. Developed in: #12703 Props barry, adrianmoldovanwp Fixes #65722 git-svn-id: https://develop.svn.wordpress.org/trunk@62857 602fd350-edb4-49c9-b593-d223f7449a82
Transient Docker registry failures (Docker Hub / GHCR pull timeouts and "premature close" errors) intermittently fail the PHPUnit jobs. Wrap the image pulls in a bounded retry with backoff. Developed in: WordPress/wordpress-develop#12703 Props barry, adrianmoldovanwp Fixes #65722 Built from https://develop.svn.wordpress.org/trunk@62857 git-svn-id: http://core.svn.wordpress.org/trunk@62137 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Trac ticket: https://core.trac.wordpress.org/ticket/65722
Summary
This pre-pulls the Docker images used by the reusable PHPUnit workflow before
env:start.The pull retries at most three times, waiting 10 seconds after the first failure and 20 seconds after the second.
The service list matches the existing Compose context. It pulls
wordpress-develop,php,mysql, andcli, addingmemcachedonly when enabled.Why
Transient Docker Hub connection timeouts currently fail the affected matrix job immediately. The affected image varies, indicating a registry or network failure rather than an image-specific
problem.
Successfully pulled images remain cached for environment startup.
The real timeout is nondeterministic and was not reproduced.
Testing
actionlintand workflow whitespace checks.memcachedwas included only when enabled.npm run env:install.Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Opus 4.8
Used for: Authoring the retry-with-backoff logic wrapping the Docker image pulls in the reusable PHPUnit workflow, and drafting the change description. All output was reviewed, tested against a live Docker/MySQL environment, and
verified by me.
Possible follow-up
Docker Hub authentication could provide stronger protection and higher pull limits. That requires repository credentials and should be considered separately.