ci: fallback on gh when the php.net API is down#2233
Conversation
There was a problem hiding this comment.
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 whenPHP_VERSIONisn’t set. - Update the sanitizers workflow to use the same fallback and to handle fetching either php.net
.xzarchives or GitHub.tar.gzarchives.
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 |
There was a problem hiding this comment.
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.jsonThere was a problem hiding this comment.
Hmm nvm. Looks like the specific github runners where the sanitizers are currently running are somehow IP-blocked.
There was a problem hiding this comment.
Yes that's the main issue. This happens frequently.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Do mirrors also expose the JSON API?
There was a problem hiding this comment.
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.