Skip to content

Commit 07b1fae

Browse files
committed
Fix PR validation: paginated API response and devx invocation
gh api --paginate returns multiple JSON objects (one per page). The old jq heredoc processed each page separately, producing multiple arrays (some empty []) which GitHub Actions rejected as invalid output format. Use jq --slurp to merge all pages into a single array before filtering. Also fix the validate step: the devx wrapper sources $1 as a file path, it doesn't support bash-style -c. Write smoke test commands to a temp file instead.
1 parent c61d198 commit 07b1fae

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

.github/workflows/pr-validate.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ jobs:
3030
id: set-matrix
3131
run: |
3232
# Fetch all check-runs for this commit from Hydra.
33+
# --paginate returns multiple JSON objects (one per page),
34+
# so we pipe through jq --slurp to merge them before filtering.
3335
RUNS=$(gh api "repos/$GITHUB_REPOSITORY/commits/${{ github.event.pull_request.head.sha }}/check-runs" --paginate)
3436
3537
# Pick a representative subset: one -env per platform to keep
3638
# the matrix small (avoids 80+ jobs on every PR push).
37-
FILTERED=$(jq -c -r '
38-
[.check_runs[]
39+
FILTERED=$(echo "$RUNS" | jq -s -c '
40+
[.[].check_runs[]
3941
| select(.name | endswith("-env"))
4042
| { "config": .name,
4143
"build_path": .output.summary,
@@ -44,10 +46,10 @@ jobs:
4446
| map(.[0])
4547
| sort_by(.config)
4648
| .[0:8]
47-
' <<< "$RUNS")
49+
')
4850
4951
echo "Selected closures for validation:"
50-
jq . <<< "$FILTERED"
52+
echo "$FILTERED" | jq .
5153
echo "matrix=$FILTERED" >> $GITHUB_OUTPUT
5254
5355
validate:
@@ -89,12 +91,15 @@ jobs:
8991
echo "Found devx wrapper: $DEVX_PATH"
9092
9193
echo "::group::Smoke test"
92-
# Import the closure and symlink the devx wrapper
93-
sudo ln -sf "$DEVX_PATH" /usr/local/bin/devx
94+
# Write smoke test commands to a temporary file — the devx
95+
# wrapper sources $1 as a script, it doesn't support -c.
96+
SMOKE_TEST=$(mktemp)
97+
cat > "$SMOKE_TEST" << 'TESTEOF'
98+
echo "GHC: $(ghc --version 2>/dev/null || echo N/A)"
99+
echo "Cabal: $(cabal --version 2>/dev/null | head -1 || echo N/A)"
100+
TESTEOF
94101
95-
# Basic smoke test: source the env and verify tools are available
96-
devx -c 'echo "GHC: $(ghc --version 2>/dev/null || echo N/A)"'
97-
devx -c 'echo "Cabal: $(cabal --version 2>/dev/null | head -1 || echo N/A)"'
102+
"$DEVX_PATH" "$SMOKE_TEST"
98103
echo "::endgroup::"
99104
100105
echo "Validation passed for ${{ matrix.job.short_name }}"

0 commit comments

Comments
 (0)