Skip to content

Build/test tools: retry Docker image pulls in PHPUnit workflows - #12703

Closed
lancewillett wants to merge 2 commits into
WordPress:trunkfrom
lancewillett:fix/ci-docker-pull-retry
Closed

Build/test tools: retry Docker image pulls in PHPUnit workflows#12703
lancewillett wants to merge 2 commits into
WordPress:trunkfrom
lancewillett:fix/ci-docker-pull-retry

Conversation

@lancewillett

@lancewillett lancewillett commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

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, and cli, adding memcached only 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

  • Passed actionlint and workflow whitespace checks.
  • Simulated a failed first attempt followed by a successful real pull.
  • Confirmed three simulated failures stopped after exactly three attempts.
  • Confirmed memcached was included only when enabled.
  • Started a PHP 8.4 and MySQL 8.4 environment using the pre-pulled images.
  • Confirmed MySQL became healthy.
  • Completed 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.

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
Copilot AI review requested due to automatic review settings July 26, 2026 23:57
@github-actions

Copy link
Copy Markdown

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.

Core Committers: Use this line as a base for the props when committing in SVN:

Props lancewillett.

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

@lancewillett lancewillett changed the title Build/Test Tools: Retry Docker image pulls in PHPUnit workflows Build/test tools: retry Docker image pulls in PHPUnit workflows Jul 26, 2026

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.

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 memcached when enabled.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +185 to +193
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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.
Copilot AI review requested due to automatic review settings July 27, 2026 18:01

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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

pento pushed a commit that referenced this pull request Jul 27, 2026
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
@github-actions

Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 62857
GitHub commit: d0a3047

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions Bot closed this Jul 27, 2026
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Jul 27, 2026
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
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.

4 participants