Skip to content

Update Reflection Cache #3

Update Reflection Cache

Update Reflection Cache #3

name: Update Reflection Cache
# Checks whether any tracked PHP line (5.6 - 8.6) has a new patch release and, if so, regenerates
# the affected committed reflection caches (tests/cache/Reflection<version>.json) and opens a PR.
#
# Detection compares the patch versions recorded in tests/cache/php-versions.json against the
# latest `php:<minor>.<patch>-alpine` images on Docker Hub. New minor lines (e.g. 8.7) are NOT
# added automatically — that needs a hand-authored Dockerfile.
on:
workflow_dispatch:
schedule:
# 04:17 UTC on the 10th of every month (PHP patch releases land early in the month but docker hub updates later).
- cron: '17 4 10 * *'
permissions:
contents: write
pull-requests: write
concurrency:
group: update-reflection-cache
cancel-in-progress: false
jobs:
update:
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build test runner image
run: docker compose -f docker-compose.yml build test_runner >/dev/null
# Runs the detector inside the test_runner service. The script writes its
# `has_changes` / `updated_versions` outputs to a file inside the project bind mount
# (`.:/opt/project/phpstorm-stubs`) — the same mount the workflow already relies on to
# carry regenerated caches back to the host — and we then fold that file into the runner's
# real $GITHUB_OUTPUT on the host. We deliberately do NOT bind-mount $GITHUB_OUTPUT itself
# into the container: single-file bind mounts don't reliably propagate in-container writes
# back to the host across all Docker setups (rootless/userns-remap/storage drivers), which
# would silently drop the outputs and skip every conditional step below.
- name: Check for new PHP patch releases
id: detect
run: |
rm -f detect-output.txt
docker compose -f docker-compose.yml run --rm \
-e GITHUB_OUTPUT=/opt/project/phpstorm-stubs/detect-output.txt \
test_runner php tests/check-and-update-php-versions.php
if [ -f detect-output.txt ]; then
cat detect-output.txt >> "$GITHUB_OUTPUT"
rm -f detect-output.txt
fi
- name: Composer Install
if: steps.detect.outputs.has_changes == 'true'
run: docker compose -f docker-compose.yml run --rm test_runner composer install --no-progress
- name: Regenerate reflection caches for updated versions
if: steps.detect.outputs.has_changes == 'true'
continue-on-error: true
run: |
versions="$(echo '${{ steps.detect.outputs.updated_versions }}' | tr ',' ' ')"
echo "Regenerating reflection caches for: $versions"
bash tests/run-all-reflection-parsers.sh $versions
- name: Clean up intermediate reflection data
if: always()
run: rm -f tests/cache/*.dat
- name: Create pull request
if: steps.detect.outputs.has_changes == 'true'
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: automated/reflection-cache-update
delete-branch: true
commit-message: 'tests: refresh reflection caches for new PHP patch release(s)'
title: 'Update reflection caches for new PHP patch release(s)'
body: |
Automated refresh triggered by new PHP patch release(s) for: **${{ steps.detect.outputs.updated_versions }}**.
`tests/check-and-update-php-versions.php` detected that the latest
`php:<minor>.<patch>-alpine` image(s) are newer than the patch recorded in
`tests/cache/php-versions.json`, and the reflection caches for the affected versions
were regenerated via `tests/run-all-reflection-parsers.sh`.
What to review:
- `tests/cache/php-versions.json` — the recorded patch version(s) bumped.
- `tests/cache/Reflection<version>.json` — changes here mean the new patch altered the
reflected API surface. No cache change (only the manifest moved) is normal and just
confirms the line is still in sync.
Generated by `.github/workflows/update-reflection-cache.yml`.
If the regeneration step failed for a version, check the run logs — the affected image
may need attention before its cache can be produced.
add-paths: |
tests/cache/Reflection*.json
tests/cache/php-versions.json