Skip to content

Commit 63697b8

Browse files
committed
ci(dependency-review): read SFW report path from env var, drop stdout scrape
Match socket-python-cli: discover the firewall report via the $SFW_JSON_REPORT_PATH env var that socketdev/action exports, instead of parsing the 'sfw report written to:' line out of stdout. The two sync steps return to plain 'set -o pipefail' + tee. A new 'Collect SFW JSON report' step (if: always(), before each upload) copies $SFW_JSON_REPORT_PATH into sfw-artifacts/sfw-report.json -- copy, not move, since socketdev/action's post step reads that temp path for its job summary -- and drops a sfw-report-missing.txt breadcrumb when absent. More robust than scraping an undocumented log string, and keeps the report-capture pattern uniform across both repos. Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
1 parent bdaa197 commit 63697b8

1 file changed

Lines changed: 35 additions & 30 deletions

File tree

.github/workflows/dependency-review.yml

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -144,27 +144,14 @@ jobs:
144144
mode: firewall-free
145145

146146
- name: Sync project through Socket Firewall (free)
147+
# pipefail keeps sfw's exit code through the tee so a firewall block
148+
# still fails the job; tee captures the report for the artifact upload.
147149
env:
148150
UV_PYTHON: "3.12"
149151
UV_PYTHON_DOWNLOADS: never
150152
run: |
151153
set -o pipefail
152-
set +e
153154
sfw uv sync --locked --extra test --extra dev 2>&1 | tee sfw-artifacts/sfw-uv-sync.log
154-
sync_status=${PIPESTATUS[0]}
155-
156-
report_path="$(
157-
sed -n 's/^.*sfw report written to: //p' sfw-artifacts/sfw-uv-sync.log |
158-
tail -n 1 |
159-
tr -d '\r'
160-
)"
161-
if [ -n "$report_path" ] && [ -f "$report_path" ]; then
162-
cp "$report_path" sfw-artifacts/sfw-report.json
163-
else
164-
echo "No SFW report JSON found in sync output." > sfw-artifacts/sfw-report-missing.txt
165-
fi
166-
167-
exit "$sync_status"
168155
169156
- name: Import smoke test
170157
run: |
@@ -177,6 +164,21 @@ jobs:
177164
print('import smoke OK', __version__)
178165
" 2>&1 | tee sfw-artifacts/import-smoke.log
179166
167+
- name: Collect SFW JSON report
168+
# socketdev/action points sfw at SFW_JSON_REPORT_PATH (a $RUNNER_TEMP
169+
# file) and reads it back in its post step to render the job summary, so
170+
# COPY (don't move) the report into the bundle. sfw writes it even when
171+
# it blocks an install -- always() keeps it on failures too.
172+
if: always()
173+
run: |
174+
if [ -n "${SFW_JSON_REPORT_PATH:-}" ] && [ -f "$SFW_JSON_REPORT_PATH" ]; then
175+
cp "$SFW_JSON_REPORT_PATH" "$GITHUB_WORKSPACE/sfw-artifacts/sfw-report.json"
176+
echo "Collected SFW report -> sfw-artifacts/sfw-report.json"
177+
else
178+
echo "No SFW JSON report found at '${SFW_JSON_REPORT_PATH:-<unset>}'." \
179+
> "$GITHUB_WORKSPACE/sfw-artifacts/sfw-report-missing.txt"
180+
fi
181+
180182
- name: Upload SFW report artifact
181183
if: always()
182184
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
@@ -219,27 +221,15 @@ jobs:
219221
# See free job for the UV_PYTHON rationale: .python-version pins an
220222
# exact patch that uv would otherwise fetch from GitHub through the
221223
# firewall (blocked by its TLS interception); use the runner's Python.
224+
#
225+
# pipefail keeps sfw's exit code through the tee so a firewall block
226+
# still fails the job; tee captures the report for the artifact upload.
222227
env:
223228
UV_PYTHON: "3.12"
224229
UV_PYTHON_DOWNLOADS: never
225230
run: |
226231
set -o pipefail
227-
set +e
228232
sfw uv sync --locked --extra test --extra dev 2>&1 | tee sfw-artifacts/sfw-uv-sync.log
229-
sync_status=${PIPESTATUS[0]}
230-
231-
report_path="$(
232-
sed -n 's/^.*sfw report written to: //p' sfw-artifacts/sfw-uv-sync.log |
233-
tail -n 1 |
234-
tr -d '\r'
235-
)"
236-
if [ -n "$report_path" ] && [ -f "$report_path" ]; then
237-
cp "$report_path" sfw-artifacts/sfw-report.json
238-
else
239-
echo "No SFW report JSON found in sync output." > sfw-artifacts/sfw-report-missing.txt
240-
fi
241-
242-
exit "$sync_status"
243233
244234
- name: Import smoke test
245235
run: |
@@ -252,6 +242,21 @@ jobs:
252242
print('import smoke OK', __version__)
253243
" 2>&1 | tee sfw-artifacts/import-smoke.log
254244
245+
- name: Collect SFW JSON report
246+
# socketdev/action points sfw at SFW_JSON_REPORT_PATH (a $RUNNER_TEMP
247+
# file) and reads it back in its post step to render the job summary, so
248+
# COPY (don't move) the report into the bundle. sfw writes it even when
249+
# it blocks an install -- always() keeps it on failures too.
250+
if: always()
251+
run: |
252+
if [ -n "${SFW_JSON_REPORT_PATH:-}" ] && [ -f "$SFW_JSON_REPORT_PATH" ]; then
253+
cp "$SFW_JSON_REPORT_PATH" "$GITHUB_WORKSPACE/sfw-artifacts/sfw-report.json"
254+
echo "Collected SFW report -> sfw-artifacts/sfw-report.json"
255+
else
256+
echo "No SFW JSON report found at '${SFW_JSON_REPORT_PATH:-<unset>}'." \
257+
> "$GITHUB_WORKSPACE/sfw-artifacts/sfw-report-missing.txt"
258+
fi
259+
255260
- name: Upload SFW report artifact
256261
if: always()
257262
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1

0 commit comments

Comments
 (0)