GeezerVison is showing github.com — fix(workflows): retry nix-hashes compute-hash on transient failure (#… · kpiwko/opencode@5c8eb0a
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: .github/workflows/nix-hashes.yml +15-5Lines changed: 15 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -56,14 +56,24 @@ jobs: |
56 | 56 | BUILD_LOG=$(mktemp) |
57 | 57 | trap 'rm -f "$BUILD_LOG"' EXIT |
58 | 58 |
|
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 |
61 | 64 |
|
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 |
64 | 74 |
|
65 | 75 | 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" |
67 | 77 | cat "$BUILD_LOG" |
68 | 78 | exit 1 |
69 | 79 | fi |
|