Skip to content

Commit f722085

Browse files
committed
fix: don't pass (potentially) large values via environment variables
1 parent c3338dc commit f722085

1 file changed

Lines changed: 42 additions & 51 deletions

File tree

.github/workflows/review.yml

Lines changed: 42 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,6 @@ jobs:
124124
|| (matrix.system == 'aarch64-linux' && 'ubuntu-24.04-arm')
125125
|| (matrix.system == 'x86_64-darwin' && 'macos-latest')
126126
|| (matrix.system == 'aarch64-darwin' && 'macos-latest') }}
127-
outputs:
128-
report_x86_64-linux: ${{ steps.report.outputs.report_x86_64-linux }}
129-
report_aarch64-linux: ${{ steps.report.outputs.report_aarch64-linux }}
130-
report_x86_64-darwin: ${{ steps.report.outputs.report_x86_64-darwin }}
131-
report_aarch64-darwin: ${{ steps.report.outputs.report_aarch64-darwin }}
132-
fetch_cmd_x86_64-linux: ${{ steps.report.outputs.fetch_cmd_x86_64-linux }}
133-
fetch_cmd_aarch64-linux: ${{ steps.report.outputs.fetch_cmd_aarch64-linux }}
134-
fetch_cmd_x86_64-darwin: ${{ steps.report.outputs.fetch_cmd_x86_64-darwin }}
135-
fetch_cmd_aarch64-darwin: ${{ steps.report.outputs.fetch_cmd_aarch64-darwin }}
136127
137128
steps:
138129
- uses: actions/checkout@v4
@@ -244,10 +235,8 @@ jobs:
244235
- name: generate report
245236
id: report
246237
run: |
247-
if [[ -s fetch_cmd ]]; then
248-
cat fetch_cmd
249-
echo fetch_cmd_${{ matrix.system }}=$(base64 -w0 fetch_cmd) >> "$GITHUB_OUTPUT"
250-
fi
238+
touch fetch_cmd
239+
cat fetch_cmd
251240
dir=~/.cache/nixpkgs-review/pr-${PR_NUMBER}
252241
if [[ "$OS" != "Linux" ]]; then
253242
sandbox=$(nix config show sandbox)
@@ -259,86 +248,88 @@ jobs:
259248
echo ":white_check_mark: *No rebuilds*" >> "$dir/report.md"
260249
fi
261250
cat $dir/report.md
262-
report=$(jq -c '.+{$md}' $dir/report.json --rawfile md $dir/report.md | base64 -w0)
263-
echo report_${{ matrix.system }}=$report >> "$GITHUB_OUTPUT"
251+
jq -c '.+{$md, $fetch_cmd}' $dir/report.json \
252+
--rawfile md $dir/report.md \
253+
--rawfile fetch_cmd fetch_cmd \
254+
> report_${{ matrix.system }}.json
264255
env:
265256
OS: ${{ runner.os }}
266257

258+
- uses: actions/upload-artifact@v4
259+
with:
260+
name: report_${{ matrix.system }}.json
261+
path: report_${{ matrix.system }}.json
262+
if-no-files-found: error
263+
267264
report:
268265
runs-on: ubuntu-latest
269266
needs: [prepare, review]
270267
outputs:
271-
report: ${{ steps.report.outputs.report }}
272268
success: ${{ steps.report.outputs.success }}
273269

274270
steps:
271+
- uses: actions/download-artifact@v5
272+
with:
273+
merge-multiple: true
274+
275275
- name: generate report
276276
id: report
277277
run: |
278+
systems=(x86_64-linux aarch64-linux x86_64-darwin aarch64-darwin)
279+
280+
for system in "${systems[@]}"; do
281+
[[ -s "report_${system}.json" ]] || continue
282+
jq -j '.md' "report_${system}.json" > "report_${system}.md"
283+
jq -j '.fetch_cmd' "report_${system}.json" > "fetch_cmd_${system}"
284+
done
285+
278286
echo -e "## \`nixpkgs-review\` result\n" >> report.md
279287
echo -e "Generated using [\`nixpkgs-review-gha\`](https://github.com/Defelo/nixpkgs-review-gha)\n" >> report.md
280288
echo -e "Command: \`nixpkgs-review pr ${PR_NUMBER}${EXTRA_ARGS:+ $EXTRA_ARGS}\`" >> report.md
281289
echo -e "Commit: [\`$HEAD\`](https://github.com/NixOS/nixpkgs/commit/$HEAD) ([subsequent changes](https://github.com/NixOS/nixpkgs/compare/$HEAD..pull/$PR_NUMBER/head))" >> report.md
282290
echo -e "Merge: [\`$MERGE\`](https://github.com/NixOS/nixpkgs/commit/$MERGE)\n" >> report.md
283291
echo -e "Logs: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\n" >> report.md
284292
285-
mkdir .tmp
286-
cd .tmp
287-
echo ${FETCH_CMD_X86_64_LINUX} | base64 -d > x86_64-linux
288-
echo ${FETCH_CMD_AARCH64_LINUX} | base64 -d > aarch64-linux
289-
echo ${FETCH_CMD_X86_64_DARWIN} | base64 -d > x86_64-darwin
290-
echo ${FETCH_CMD_AARCH64_DARWIN} | base64 -d > aarch64-darwin
291-
for system in x86_64-linux aarch64-linux x86_64-darwin aarch64-darwin; do
292-
[[ -s $system ]] || continue
293-
echo -e "<li><details><summary><code>$system</code></summary>\n\n\`\`\`shell" >> ../cache.md
294-
cat $system >> ../cache.md
295-
echo -e "\n\`\`\`\n</details></li>" >> ../cache.md
293+
for system in "${systems[@]}"; do
294+
[[ -s "fetch_cmd_${system}" ]] || continue
295+
echo -e "<li><details><summary><code>$system</code></summary>\n\n\`\`\`shell" >> cache.md
296+
cat "fetch_cmd_${system}" >> cache.md
297+
echo -e "\n\`\`\`\n</details></li>" >> cache.md
296298
done
297-
cd ..
298299
if [[ -s cache.md ]]; then
299300
echo -e "<details><summary>Download packages from cache:</summary><ul>" >> report.md
300301
cat cache.md >> report.md
301302
echo -e "</ul></details>\n" >> report.md
302303
fi
303304
304-
mkdir reports
305-
echo ${REPORT_X86_64_LINUX} | base64 -d > reports/x86_64-linux.json
306-
echo ${REPORT_AARCH64_LINUX} | base64 -d > reports/aarch64-linux.json
307-
echo ${REPORT_X86_64_DARWIN} | base64 -d > reports/x86_64-darwin.json
308-
echo ${REPORT_AARCH64_DARWIN} | base64 -d > reports/aarch64-darwin.json
309-
for system in x86_64-linux aarch64-linux x86_64-darwin aarch64-darwin; do
310-
if [[ -s reports/$system.json ]]; then
311-
jq -r '.md' reports/$system.json >> report.md
312-
fi
305+
for system in "${systems[@]}"; do
306+
[[ -s "report_${system}.md" ]] || continue
307+
cat "report_${system}.md" >> report.md
313308
done
314309
315310
cat report.md
316-
echo report=$(base64 -w0 report.md) >> "$GITHUB_OUTPUT"
317-
echo success=$(jq -s 'all(.[].result[]; .failed==[])' reports/*.json) >> "$GITHUB_OUTPUT"
311+
echo success=$(jq -s 'all(.[].result[]; .failed==[])' report_*.json) >> "$GITHUB_OUTPUT"
318312
sed '1s|$| for [#'"$PR_NUMBER"'](https://github.com/NixOS/nixpkgs/pull/'"$PR_NUMBER"')|' report.md >> $GITHUB_STEP_SUMMARY
319313
env:
320314
HEAD: ${{ needs.prepare.outputs.head }}
321315
MERGE: ${{ needs.prepare.outputs.merge }}
322316
EXTRA_ARGS: ${{ inputs.extra-args }}
323-
FETCH_CMD_X86_64_LINUX: ${{ needs.review.outputs.fetch_cmd_x86_64-linux }}
324-
FETCH_CMD_AARCH64_LINUX: ${{ needs.review.outputs.fetch_cmd_aarch64-linux }}
325-
FETCH_CMD_X86_64_DARWIN: ${{ needs.review.outputs.fetch_cmd_x86_64-darwin }}
326-
FETCH_CMD_AARCH64_DARWIN: ${{ needs.review.outputs.fetch_cmd_aarch64-darwin }}
327-
REPORT_X86_64_LINUX: ${{ needs.review.outputs.report_x86_64-linux }}
328-
REPORT_AARCH64_LINUX: ${{ needs.review.outputs.report_aarch64-linux }}
329-
REPORT_X86_64_DARWIN: ${{ needs.review.outputs.report_x86_64-darwin }}
330-
REPORT_AARCH64_DARWIN: ${{ needs.review.outputs.report_aarch64-darwin }}
317+
318+
- uses: actions/upload-artifact@v4
319+
with:
320+
name: report.md
321+
path: report.md
322+
if-no-files-found: error
331323

332324
post-result:
333325
runs-on: ubuntu-latest
334326
needs: [prepare, report]
335327
if: ${{ inputs.post-result || inputs.on-success != 'nothing' }}
336328

337329
steps:
338-
- name: fetch report
339-
run: echo ${REPORT} | base64 -d > report.md
340-
env:
341-
REPORT: ${{ needs.report.outputs.report }}
330+
- uses: actions/download-artifact@v5
331+
with:
332+
name: report.md
342333

343334
- name: post comment
344335
if: ${{ inputs.post-result }}

0 commit comments

Comments
 (0)