From efeeb60b551390a380f589ab6a019f84f4ab92b0 Mon Sep 17 00:00:00 2001 From: Conner Swenberg Date: Tue, 2 Jun 2026 11:12:10 -0400 Subject: [PATCH] fix(ci): correct fork-test PASS/FAIL counting in result comment `grep -c` prints the count `0` AND exits non-zero when there are no matches, so the `|| echo 0` fallback appended a SECOND `0`. With zero failing tests, `failed` became the two-line string "0\n0". The later `[ "$((passed + failed))" -eq 0 ]` then expanded to an arithmetic expression containing a newline, raising "syntax error in expression", which aborts the step under `set -e`. The follow-up `gh api` call then runs with an unset body and returns HTTP 422. This is self-masking: it only triggers when ALL fork tests pass (so `failed` is empty and the fallback fires), which is why it surfaced on the first all-green run. It is infra-only and unrelated to any contract or test change. Fix: use `|| true` (keeps the substitution exit status 0 so `set -e` does not abort and no second `0` is echoed) plus `${var:-0}` to default to `0` when the output file is missing or empty. Applied at both the "Summarize fork test results" and "Comment fork test results on PR" steps. Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/base-std-fork-tests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/base-std-fork-tests.yml b/.github/workflows/base-std-fork-tests.yml index 460e7de..1e9fb4c 100644 --- a/.github/workflows/base-std-fork-tests.yml +++ b/.github/workflows/base-std-fork-tests.yml @@ -140,8 +140,8 @@ jobs: shell: bash run: | output="$RUNNER_TEMP/fork-test-output.txt" - passed=$(grep -c '\[PASS\]' "$output" 2>/dev/null || echo 0) - failed=$(grep -c '\[FAIL' "$output" 2>/dev/null || echo 0) + passed=$(grep -c '\[PASS\]' "$output" 2>/dev/null || true); passed=${passed:-0} + failed=$(grep -c '\[FAIL' "$output" 2>/dev/null || true); failed=${failed:-0} { echo "## Fork Test Results" @@ -168,8 +168,8 @@ jobs: GH_TOKEN: ${{ github.token }} run: | output="$RUNNER_TEMP/fork-test-output.txt" - passed=$(grep -c '\[PASS\]' "$output" 2>/dev/null || echo 0) - failed=$(grep -c '\[FAIL' "$output" 2>/dev/null || echo 0) + passed=$(grep -c '\[PASS\]' "$output" 2>/dev/null || true); passed=${passed:-0} + failed=$(grep -c '\[FAIL' "$output" 2>/dev/null || true); failed=${failed:-0} marker="" if [ ! -s "$output" ] || [ "$((passed + failed))" -eq 0 ]; then