Skip to content

ci: fallback on gh when the php.net API is down#2233

Open
dunglas wants to merge 3 commits intomainfrom
ci/php-api-fallback
Open

ci: fallback on gh when the php.net API is down#2233
dunglas wants to merge 3 commits intomainfrom
ci/php-api-fallback

Conversation

@dunglas
Copy link
Member

@dunglas dunglas commented Mar 3, 2026

Unfortunately, GitHub Actions is often blocked by the php.net CDN. This patch adds a fallback to use GitHub to try to determine the PHP version to use. This is less ideal because PHP currently doesn't use GitHub extensively, and distribution archives aren't available in the GitHub releases, only on php.net.

Copilot AI review requested due to automatic review settings March 3, 2026 09:49
Copy link
Contributor

Copilot AI left a comment

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 CI resilience when php.net’s releases API is unavailable (e.g., blocked by the php.net CDN) by adding a fallback mechanism to infer the latest PHP patch version via GitHub.

Changes:

  • Add php.net → GitHub (gh) fallback logic to determine the latest PHP version when PHP_VERSION isn’t set.
  • Update the sanitizers workflow to use the same fallback and to handle fetching either php.net .xz archives or GitHub .tar.gz archives.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
build-static.sh Adds php.net API lookup with a GitHub (gh) fallback to resolve the latest patch version for a given minor series.
.github/workflows/sanitizers.yaml Adds fallback logic for determining the PHP version and adjusts extraction to support GitHub tarballs.

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

env:
GH_TOKEN: ${{ github.token }}
run: |
curl -fsSL 'https://www.php.net/releases/index.php?json&max=1&version=8.5' -o version.json
Copy link
Contributor

Choose a reason for hiding this comment

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

Could it also be good enough to just add an exponential backoff to curl? (1s, 2s, 4s, 8s)

curl --retry 5 -fsSL 'https://www.php.net/releases/index.php?json&max=1&version=8.5' -o version.json

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm nvm. Looks like the specific github runners where the sanitizers are currently running are somehow IP-blocked.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes that's the main issue. This happens frequently.

Copy link
Contributor

Choose a reason for hiding this comment

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

A better idea than using github might be falling back to a php mirror. We're running one on phpmirror.static-php.dev now, but it's simple enough to rsync to a vps every few hours.

GitHub tags release earlier or later than actual php.net releases, so it's not optimal.

Copy link
Member Author

@dunglas dunglas Mar 4, 2026

Choose a reason for hiding this comment

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

Do mirrors also expose the JSON API?

Copy link
Contributor

Choose a reason for hiding this comment

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

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.

5 participants