Skip to content

Commit 4582c58

Browse files
committed
Replace checksum-phar with a simple job in phar.yml
1 parent d9155f8 commit 4582c58

File tree

2 files changed

+76
-124
lines changed

2 files changed

+76
-124
lines changed

.github/workflows/checksum-phar.yml

Lines changed: 0 additions & 124 deletions
This file was deleted.

.github/workflows/phar.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323

2424
outputs:
2525
checksum: ${{ steps.checksum.outputs.md5 }}
26+
changes: ${{ steps.changes.outputs }}
2627

2728
steps:
2829
- name: "Checkout"
@@ -107,6 +108,15 @@ jobs:
107108
- name: "Delete checksum PHAR"
108109
run: "rm tmp/phpstan.phar"
109110

111+
- uses: dorny/paths-filter@v3
112+
id: changes
113+
with:
114+
filters: |
115+
compiler:
116+
- 'compiler/**'
117+
- '.github/workflows/phar.yml'
118+
- '.github/scripts/**'
119+
110120
integration-tests:
111121
if: github.event_name == 'pull_request'
112122
needs: compiler-tests
@@ -131,6 +141,72 @@ jobs:
131141
ref: 2.1.x
132142
phar-checksum: ${{needs.compiler-tests.outputs.checksum}}
133143

144+
checksum-phar:
145+
if: github.event_name == 'pull_request' && needs.compiler-tests.outputs.changes.compiler == 'true'
146+
needs: compiler-tests
147+
runs-on: "ubuntu-latest"
148+
steps:
149+
- uses: actions/checkout@v4
150+
151+
- name: Get base commit SHA
152+
id: base
153+
run: echo "base_sha=${{ github.event.pull_request.base.sha }}" >> "$GITHUB_OUTPUT"
154+
155+
- name: Set up Node.js
156+
uses: actions/setup-node@v4
157+
with:
158+
node-version: 20
159+
160+
- name: Install dependencies
161+
working-directory: .github/scripts
162+
run: npm ci
163+
164+
- name: "Compile TS scripts"
165+
working-directory: .github/scripts
166+
run: npx tsc
167+
168+
- name: Find phar-file-checksum from base commit
169+
id: find-artifact
170+
uses: actions/github-script@v7
171+
env:
172+
BASE_SHA: ${{ steps.base.outputs.base_sha }}
173+
ARTIFACT_NAME: phar-file-checksum
174+
WORKFLOW_NAME: Compile PHAR
175+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
176+
with:
177+
script: |
178+
const script = require('./.github/scripts/dist/find-artifact.js');
179+
await script({github, context, core})
180+
181+
- name: Download old artifact by ID
182+
uses: actions/download-artifact@v4
183+
with:
184+
artifact-ids: ${{ steps.find-artifact.outputs.artifact_id }}
185+
run-id: ${{ steps.find-artifact.outputs.run_id }}
186+
github-token: ${{ secrets.GITHUB_TOKEN }}
187+
path: ./phar-file-checksum-old.phar
188+
189+
- name: "Save old checksum"
190+
id: "old_checksum"
191+
run: echo "md5=$(md5sum phar-file-checksum-old.phar | cut -d' ' -f1)" >> $GITHUB_OUTPUT
192+
193+
- name: Download new artifact
194+
uses: actions/download-artifact@v4
195+
with:
196+
name: phar-file-checksum
197+
path: ./phar-file-checksum-new.phar
198+
199+
- name: "Save new checksum"
200+
id: "new_checksum"
201+
run: echo "md5=$(md5sum phar-file-checksum-new.phar | cut -d' ' -f1)" >> $GITHUB_OUTPUT
202+
203+
- name: "Assert checksum"
204+
run: |
205+
old_checksum=${{ steps.old_checksum.outputs.md5 }}
206+
new_checksum=${{ steps.new_checksum.outputs.md5 }}
207+
[[ "$old_checksum" == "$new_checksum" ]];
208+
209+
134210
commit:
135211
name: "Commit PHAR"
136212
if: "github.repository_owner == 'phpstan' && (github.ref == 'refs/heads/2.1.x' || startsWith(github.ref, 'refs/tags/'))"

0 commit comments

Comments
 (0)