Skip to content

Commit 2f63e84

Browse files
committed
fix(ZMSKVR): fail Psalm CI when findings exist, still upload SARIF
Use continue-on-error on the scan step so SARIF normalize/upload run even when Psalm exits non-zero, then fail the job if SARIF is missing or the recorded Psalm exit code is not zero.
1 parent 75e56ba commit 2f63e84

1 file changed

Lines changed: 34 additions & 10 deletions

File tree

.github/workflows/psalm.yml

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ jobs:
7878

7979
- name: Run Psalm Security Scan
8080
id: psalm
81+
continue-on-error: true
8182
working-directory: ${{ matrix.project }}
8283
run: |
8384
set +e
@@ -86,11 +87,15 @@ jobs:
8687
--report=../results-${{ matrix.project }}.sarif
8788
psalm_exit=$?
8889
set -e
90+
echo "exit_code=${psalm_exit}" >> "$GITHUB_OUTPUT"
8991
if [ ! -f "../results-${{ matrix.project }}.sarif" ]; then
9092
echo "Psalm did not produce SARIF for ${{ matrix.project }} (exit code: ${psalm_exit})."
9193
exit 1
9294
fi
93-
echo "Psalm finished for ${{ matrix.project }} with exit code ${psalm_exit}; SARIF written."
95+
if [ "${psalm_exit}" -ne 0 ]; then
96+
echo "Psalm reported issues for ${{ matrix.project }} (exit code: ${psalm_exit})."
97+
exit "${psalm_exit}"
98+
fi
9499
95100
- name: Normalize SARIF paths to repository root
96101
env:
@@ -137,11 +142,18 @@ jobs:
137142
sarif_file: results-${{ matrix.project }}.sarif
138143
checkout_path: ${{ matrix.project }}
139144

140-
- name: Fail job if SARIF generation failed
141-
if: steps.sarif.outputs.exists != 'true'
145+
- name: Fail job if Psalm scan or SARIF generation failed
146+
if: always()
142147
run: |
143-
echo "Missing SARIF output for ${{ matrix.project }} (results-${{ matrix.project }}.sarif)."
144-
exit 1
148+
if [ "${{ steps.sarif.outputs.exists }}" != "true" ]; then
149+
echo "Missing SARIF output for ${{ matrix.project }} (results-${{ matrix.project }}.sarif)."
150+
exit 1
151+
fi
152+
psalm_exit="${{ steps.psalm.outputs.exit_code }}"
153+
if [ -z "${psalm_exit}" ] || [ "${psalm_exit}" != "0" ]; then
154+
echo "Psalm failed for ${{ matrix.project }} (exit code: ${psalm_exit:-unknown})."
155+
exit 1
156+
fi
145157
146158
psalm-dead-code:
147159
runs-on: ubuntu-latest
@@ -178,6 +190,7 @@ jobs:
178190

179191
- name: Run Psalm dead-code scan (monorepo)
180192
id: psalm_dead_code
193+
continue-on-error: true
181194
run: |
182195
set +e
183196
zmsapi/vendor/bin/psalm \
@@ -186,11 +199,15 @@ jobs:
186199
--report=results-monorepo.sarif
187200
psalm_exit=$?
188201
set -e
202+
echo "exit_code=${psalm_exit}" >> "$GITHUB_OUTPUT"
189203
if [ ! -f "results-monorepo.sarif" ]; then
190204
echo "Psalm did not produce monorepo SARIF (exit code: ${psalm_exit})."
191205
exit 1
192206
fi
193-
echo "Psalm monorepo scan finished with exit code ${psalm_exit}; SARIF written."
207+
if [ "${psalm_exit}" -ne 0 ]; then
208+
echo "Psalm monorepo scan reported issues (exit code: ${psalm_exit})."
209+
exit "${psalm_exit}"
210+
fi
194211
195212
- name: Check monorepo SARIF file exists
196213
id: sarif_monorepo
@@ -207,8 +224,15 @@ jobs:
207224
with:
208225
sarif_file: results-monorepo.sarif
209226

210-
- name: Fail job if monorepo SARIF generation failed
211-
if: steps.sarif_monorepo.outputs.exists != 'true'
227+
- name: Fail job if monorepo Psalm scan or SARIF generation failed
228+
if: always()
212229
run: |
213-
echo "Missing monorepo SARIF output (results-monorepo.sarif)."
214-
exit 1
230+
if [ "${{ steps.sarif_monorepo.outputs.exists }}" != "true" ]; then
231+
echo "Missing monorepo SARIF output (results-monorepo.sarif)."
232+
exit 1
233+
fi
234+
psalm_exit="${{ steps.psalm_dead_code.outputs.exit_code }}"
235+
if [ -z "${psalm_exit}" ] || [ "${psalm_exit}" != "0" ]; then
236+
echo "Psalm monorepo scan failed (exit code: ${psalm_exit:-unknown})."
237+
exit 1
238+
fi

0 commit comments

Comments
 (0)