Skip to content

Commit 663dcf7

Browse files
ondrejmirtesclaude
andcommitted
Stage turbo binaries the dist does not carry even at an unchanged extension version
The commit job staged turbo binaries only when EXPECTED_EXTENSION_VERSION differed from the dist's turbo-ext/.version, so a compile-matrix addition that does not touch turbo-ext/src — like the PHP 8.3 legs — built and tested binaries on every run without ever committing them. The version check now also reports a difference when a built artifact has no counterpart file in the dist, and the staging step fills in only the missing files in that case, leaving existing byte-unreproducible binaries unchurned. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018JjTadZNEUo9tmVT3KXzt9
1 parent 873b78c commit 663dcf7

1 file changed

Lines changed: 39 additions & 15 deletions

File tree

‎.github/workflows/phar.yml‎

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,24 +1001,50 @@ jobs:
10011001
echo "result=same" >> "$GITHUB_OUTPUT"
10021002
fi
10031003
1004-
- name: "Check turbo extension version"
1004+
- name: "Download turbo extension artifacts"
1005+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
1006+
with:
1007+
pattern: "phpstan_turbo-*"
1008+
path: "turbo-artifacts"
1009+
1010+
- name: "Check turbo extension version and binary set"
10051011
id: turbo-difference
10061012
run: |
10071013
EXPECTED="$(sed -n "s/.*EXPECTED_EXTENSION_VERSION = '\([^']*\)'.*/\1/p" phpstan-src/src/Turbo/TurboExtensionEnabler.php)"
10081014
CURRENT="$(cat phpstan-dist/turbo-ext/.version 2>/dev/null || echo none)"
10091015
echo "enabler expects: $EXPECTED, dist carries: $CURRENT"
1016+
RESULT=same
1017+
VERSION_CHANGED=no
10101018
if [[ "$EXPECTED" != "$CURRENT" ]]; then
1011-
echo "result=different" >> "$GITHUB_OUTPUT"
1012-
else
1013-
echo "result=same" >> "$GITHUB_OUTPUT"
1019+
RESULT=different
1020+
VERSION_CHANGED=yes
10141021
fi
1022+
# A new compile-matrix leg (new PHP minor or platform) produces
1023+
# binaries the dist does not carry even though the extension
1024+
# version is unchanged.
1025+
for dir in turbo-artifacts/phpstan_turbo-*; do
1026+
[ -d "$dir" ] || continue
1027+
name="${dir#turbo-artifacts/phpstan_turbo-}"
1028+
target="${name%-php*}"
1029+
minor="${name##*-php}"
1030+
for file in "$dir"/*; do
1031+
dist_file="phpstan-dist/turbo-ext/$target/phpstan_turbo-$minor.${file##*.}"
1032+
if [[ ! -f "$dist_file" ]]; then
1033+
echo "missing from dist: $dist_file"
1034+
RESULT=different
1035+
fi
1036+
done
1037+
done
1038+
echo "result=$RESULT" >> "$GITHUB_OUTPUT"
1039+
echo "version-changed=$VERSION_CHANGED" >> "$GITHUB_OUTPUT"
10151040
echo "version=$EXPECTED" >> "$GITHUB_OUTPUT"
10161041
10171042
# The phar is staged only when its checksum changed (or on tags, which
10181043
# always produce a commit) — a turbo-only update must not churn the
1019-
# byte-unstable phar; the turbo binaries are staged only when the
1020-
# extension version changed, since native builds are never
1021-
# byte-reproducible (signing timestamps, Mach-O UUIDs).
1044+
# byte-unstable phar; existing turbo binaries are overwritten only when
1045+
# the extension version changed, since native builds are never
1046+
# byte-reproducible (signing timestamps, Mach-O UUIDs). Binaries the
1047+
# dist does not carry at all are staged even at an unchanged version.
10221048
- name: "Download phpstan.phar"
10231049
if: startsWith(github.ref, 'refs/tags/') || steps.checksum-difference.outputs.result == 'different'
10241050
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
@@ -1051,24 +1077,22 @@ jobs:
10511077
working-directory: phpstan-dist
10521078
run: "gpg --verify phpstan.phar.asc"
10531079

1054-
- name: "Download turbo extension artifacts"
1055-
if: steps.turbo-difference.outputs.result == 'different'
1056-
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
1057-
with:
1058-
pattern: "phpstan_turbo-*"
1059-
path: "turbo-artifacts"
1060-
10611080
- name: "Stage turbo extension binaries"
10621081
if: steps.turbo-difference.outputs.result == 'different'
10631082
env:
10641083
TURBO_VERSION: ${{ steps.turbo-difference.outputs.version }}
1084+
VERSION_CHANGED: ${{ steps.turbo-difference.outputs.version-changed }}
10651085
run: |
10661086
for dir in turbo-artifacts/phpstan_turbo-*; do
1087+
[ -d "$dir" ] || continue
10671088
name="${dir#turbo-artifacts/phpstan_turbo-}"
10681089
target="${name%-php*}"
10691090
minor="${name##*-php}"
10701091
for file in "$dir"/*; do
1071-
install -D -m 644 "$file" "phpstan-dist/turbo-ext/$target/phpstan_turbo-$minor.${file##*.}"
1092+
dest="phpstan-dist/turbo-ext/$target/phpstan_turbo-$minor.${file##*.}"
1093+
if [[ "$VERSION_CHANGED" == "yes" || ! -f "$dest" ]]; then
1094+
install -D -m 644 "$file" "$dest"
1095+
fi
10721096
done
10731097
done
10741098
echo "$TURBO_VERSION" > phpstan-dist/turbo-ext/.version

0 commit comments

Comments
 (0)