From 17d1669803524faf418cc0c2956c3c540b58cca4 Mon Sep 17 00:00:00 2001 From: Tomas Rutkauskas Date: Mon, 9 Nov 2026 17:37:14 +0200 Subject: [PATCH] ci: list the tarball into a file before grep -q checks it `tar -tzf "$TGZ" | grep -qx "package/$f"` under pipefail failed at random: GNU tar writes the listing one line per write(), grep -q exits at its match, tar's next write fails ("tar: stdout: write error", exit 2), and pipefail turns that into "has no dist/convertapi.d.ts". The main Build of df2759a failed this way on 2026-11-09 (run 42633356489, attempt 1). Pack (build.yml) and "Check the package" (publish.yml) now list the tarball into $RUNNER_TEMP once and grep the file. The error messages are unchanged. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/build.yml | 5 ++++- .github/workflows/publish.yml | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 33f9722..449a407 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -127,8 +127,11 @@ jobs: npm pack --ignore-scripts --pack-destination out TGZ="out/convertapi-js-$VERSION.tgz" test -f "$TGZ" + # The listing goes to a file first. Piped into grep -q, tar can still be writing when grep exits + # at its first match; tar then fails ("stdout: write error") and pipefail reports a missing file. + tar -tzf "$TGZ" > "$RUNNER_TEMP/tgz-files.txt" for f in dist/convertapi.js dist/convertapi.d.ts; do - tar -tzf "$TGZ" | grep -qx "package/$f" || { echo "::error::$TGZ has no $f"; exit 1; } + grep -qx "package/$f" "$RUNNER_TEMP/tgz-files.txt" || { echo "::error::$TGZ has no $f"; exit 1; } done echo "version=$VERSION" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f2f8419..41eaff7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -191,8 +191,11 @@ jobs: test -f "$TGZ" PKG_JSON=$(tar -xzOf "$TGZ" package/package.json) [ "$(jq -r .version <<<"$PKG_JSON")" = "$VERSION" ] || { echo "::error::$TGZ does not carry version $VERSION"; exit 1; } + # The listing goes to a file first. Piped into grep -q, tar can still be writing when grep exits + # at its first match; tar then fails ("stdout: write error") and pipefail reports a missing file. + tar -tzf "$TGZ" > "$RUNNER_TEMP/tgz-files.txt" for f in dist/convertapi.js dist/convertapi.d.ts; do - tar -tzf "$TGZ" | grep -qx "package/$f" || { echo "::error::$TGZ has no $f"; exit 1; } + grep -qx "package/$f" "$RUNNER_TEMP/tgz-files.txt" || { echo "::error::$TGZ has no $f"; exit 1; } done tar -tzf "$TGZ"