Skip to content

Commit 5c8eb0a

Browse files
fix(workflows): retry nix-hashes compute-hash on transient failure (anomalyco#30743)
1 parent 1e216e1 commit 5c8eb0a

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

.github/workflows/nix-hashes.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,24 @@ jobs:
5656
BUILD_LOG=$(mktemp)
5757
trap 'rm -f "$BUILD_LOG"' EXIT
5858
59-
# Build with fakeHash to trigger hash mismatch and reveal correct hash
60-
nix build ".#packages.${SYSTEM}.node_modules_updater" --no-link 2>&1 | tee "$BUILD_LOG" || true
59+
HASH=""
60+
MAX_ATTEMPTS=3
61+
for ((ATTEMPT = 1; ATTEMPT <= MAX_ATTEMPTS; ATTEMPT++)); do
62+
# Build with fakeHash to trigger hash mismatch and reveal correct hash
63+
nix build ".#packages.${SYSTEM}.node_modules_updater" --no-link 2>&1 | tee "$BUILD_LOG" || true
6164
62-
# Extract hash from build log with portability
63-
HASH="$(nix run --inputs-from . nixpkgs#gnugrep -- -oP 'got:\s*\Ksha256-[A-Za-z0-9+/=]+' "$BUILD_LOG" | tail -n1 || true)"
65+
HASH="$(nix run --inputs-from . nixpkgs#gnugrep -- -oP 'got:\s*\Ksha256-[A-Za-z0-9+/=]+' "$BUILD_LOG" | tail -n1 || true)"
66+
67+
[ -n "$HASH" ] && break
68+
69+
if [ "$ATTEMPT" -lt "$MAX_ATTEMPTS" ]; then
70+
echo "::warning::Attempt ${ATTEMPT}/${MAX_ATTEMPTS} produced no hash for ${SYSTEM}; retrying in $((ATTEMPT * 10))s"
71+
sleep $((ATTEMPT * 10))
72+
fi
73+
done
6474
6575
if [ -z "$HASH" ]; then
66-
echo "::error::Failed to compute hash for ${SYSTEM}"
76+
echo "::error::Failed to compute hash for ${SYSTEM} after ${MAX_ATTEMPTS} attempts"
6777
cat "$BUILD_LOG"
6878
exit 1
6979
fi

0 commit comments

Comments
 (0)