scan, vex: pass collected files through disk, not argv
A 230-statement VEX file (234 KB) made jq fail with 'Argument list too long' (--argjson of the accumulated array). Each file is now one JSON object in an ndjson file, slurped into the report.
This commit is contained in:
1 parent
2b4b140200
commit
0e5054f5d0
2 files changed
+11
-8
No files matched your search
+5
-3
@@ -45,11 +45,13 @@ runs:
|
||||
run: |
|
||||
set -euo pipefail
|
||||
url=${PANEL_URL:-${DTRACK_URL%/}/panel-ci/vex}
|
||||
files='[]'
|
||||
# One JSON object per file on disk (never as an argument: a big VEX
|
||||
# file blows the argv limit), slurped into the report.
|
||||
: > vex-files.ndjson
|
||||
while IFS= read -r f; do
|
||||
files=$(jq --arg p "$f" --rawfile c "$f" '. + [{path: $p, content: $c}]' <<<"$files")
|
||||
jq -n --arg p "$f" --rawfile c "$f" '{path: $p, content: $c}' >> vex-files.ndjson
|
||||
done < <(find "$VEX_PATH" -name '*.json' -not -path '*/.git/*' | sort | head -500)
|
||||
jq -n --arg repo "$REPO" --arg commit "$COMMIT" --argjson files "$files" \
|
||||
jq -n --arg repo "$REPO" --arg commit "$COMMIT" --slurpfile files vex-files.ndjson \
|
||||
'{repo: $repo, commit: $commit, files: $files}' > vex-report.json
|
||||
echo "Posting $(jq '.files | length' vex-report.json) VEX file(s) to ${url}"
|
||||
# -f: a rejected file (bad JSON, no justification) fails the job.
|
||||
|
||||
Reference in new issue
Block a user