From 5972cc2b109a99ee56cac6f37a98853f92f5c09f Mon Sep 17 00:00:00 2001 From: Rick Lam Date: Thu, 22 Oct 2026 05:12:19 +0100 Subject: [PATCH] Only test the PHP versions a PR changes Every PR built and tested all versions in versions.json, so a change to one version's folder (such as #47, only 7.4/) also showed unrelated failures from other versions. On pull requests the matrix job now diffs the PR against its base. If every changed file is inside a version folder listed in versions.json, only those versions are tested. Any other change (common/, the workflow, the Makefile, versions.json, the README), an unknown folder, or a failed diff tests every version as before. Pushes to master are unchanged. Fixes #51 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Uugex1w8qZoTbBRbcFwkcp --- .github/workflows/build.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e9da55c..f0c665c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,10 +16,26 @@ jobs: versions: ${{ steps.load.outputs.versions }} steps: - uses: actions/checkout@v6 + with: + fetch-depth: 0 - id: load + env: + EVENT: ${{ github.event_name }} + BASE_SHA: ${{ github.event.pull_request.base.sha }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} run: | + test_matrix=$(jq -c . versions.json) + if [ "$EVENT" = "pull_request" ] && changed=$(git diff --name-only "${BASE_SHA}...${HEAD_SHA}"); then + test_matrix=$(printf '%s\n' "$changed" | jq -R -s -c --slurpfile all versions.json ' + ($all[0] | map(.version)) as $known | + (split("\n") | map(select(length > 0) | split("/"))) as $parts | + if ($parts | length) > 0 and ($parts | all(length > 1 and (.[0] as $d | $known | index($d) != null))) + then ($parts | map(.[0]) | unique) as $vs | $all[0] | map(select(.version as $v | $vs | index($v) != null)) + else $all[0] end') + fi + echo "Testing: $(jq -r '[.[].version] | join(", ")' <<< "$test_matrix")" { - echo "test_matrix=$(jq -c . versions.json)" + echo "test_matrix=${test_matrix}" echo "build_matrix=$(jq -c '[ .[] | . as $v | ($v.platforms | split(",")) as $ps |