Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 54 additions & 9 deletions .github/workflows/ci.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion genie/ci-scripts/nix-gc-race-retry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ run_nix_gc_race_retry() {
[ -n "$path" ] && saw_invalid_path=true
printf '%s' "$flattened" | grep -Eq 'error:[[:space:]]*.*Failed to convert config\.cachix to JSON' && saw_cachix_signature=true || true
printf '%s' "$flattened" | grep -Eq 'error:[[:space:]]*.*while evaluating the option.*cachix\.package' && saw_cachix_signature=true || true
# Nix can surface fetched-source corruption as missing subpaths under
# «github:owner/repo/rev»/... during arbitrary flake evaluation, not only
# while resolving the devenv CLI. Retry after clearing fetch/eval caches:
# this indicates an incomplete or stale fetched-source view, not project source.
printf '%s' "$flattened" | grep -Eq "error:[[:space:]]*path '«(github|https?)[:/][^»]+»/[^']+' does not exist" && saw_fetch_signature=true || true
printf '%s' "$flattened" | grep -Eq 'error:[[:space:]]*cannot read file from tarball:[[:space:]]*Truncated tar archive detected while reading data' && saw_fetch_signature=true || true
rm -f "$log"

Expand All @@ -94,7 +99,7 @@ run_nix_gc_race_retry() {
fi

[ -z "$path" ] || nix-store --realise "$path" 2>/dev/null || true
rm -rf ~/.cache/nix/eval-cache-*
rm -rf ~/.cache/nix/eval-cache-* ~/.cache/nix/gitv3 ~/.cache/nix/tarball-cache ~/.cache/nix/tarball-cache-v2 ~/.cache/nix/fetcher-cache*.sqlite*
attempt=$((attempt + 1))
done

Expand Down
25 changes: 23 additions & 2 deletions genie/ci-scripts/nix-gc-race-retry.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,28 @@ chmod +x "$fetch_fixture"
CI_PROGRESS_HEARTBEAT_SECONDS=1 NIX_GC_RACE_MAX_RETRIES=2 run_nix_gc_race_retry "fetch-fixture" "$fetch_fixture" >/dev/null
assert_eq "2" "$(cat "$test_dir/fetch-attempt")" "truncated tarball retry count"

echo "Test 4: does not retry when literal signature strings appear outside Nix error context"
echo "Test 4: retries missing pretty flake source subpath failures"
pretty_source_fixture="$test_dir/pretty-source-fixture.sh"
cat > "$pretty_source_fixture" <<EOF
#!/usr/bin/env bash
set -euo pipefail
attempt_file="$test_dir/pretty-source-attempt"
attempt=1
if [ -f "\$attempt_file" ]; then
attempt=\$(cat "\$attempt_file")
fi
if [ "\$attempt" -eq 1 ]; then
echo 2 > "\$attempt_file"
echo "error: path '«github:cachix/devenv/ea3d94a»/xtask' does not exist" >&2
exit 1
fi
echo "pretty source recovered"
EOF
chmod +x "$pretty_source_fixture"
CI_PROGRESS_HEARTBEAT_SECONDS=1 NIX_GC_RACE_MAX_RETRIES=2 run_nix_gc_race_retry "pretty-source-fixture" "$pretty_source_fixture" >/dev/null
assert_eq "2" "$(cat "$test_dir/pretty-source-attempt")" "pretty flake source retry count"

echo "Test 5: does not retry when literal signature strings appear outside Nix error context"
false_positive_fixture="$test_dir/false-positive-fixture.sh"
cat > "$false_positive_fixture" <<'EOF'
#!/usr/bin/env bash
Expand All @@ -117,7 +138,7 @@ exit_code=$?
set -e
assert_exit_code 9 "$exit_code" "non-error-context strings do not trigger retries"

echo "Test 5: preserves the original exit code when no retry signature is present"
echo "Test 6: preserves the original exit code when no retry signature is present"
non_retry_fixture="$test_dir/non-retry-fixture.sh"
cat > "$non_retry_fixture" <<'EOF'
#!/usr/bin/env bash
Expand Down
1 change: 1 addition & 0 deletions genie/ci-workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export {
nixExtraConf,
runDevenvTasksBefore,
standardCIEnv,
withGcRaceRetry,
workspaceLocalNixCachePath,
workspaceLocalNixCacheRoot,
type NixBinaryCache,
Expand Down
7 changes: 6 additions & 1 deletion genie/ci-workflow/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,11 @@ run_nix_gc_race_retry() {
[ -n "$path" ] && saw_invalid_path=true
printf '%s' "$flattened" | grep -Eq 'error:[[:space:]]*.*Failed to convert config\.cachix to JSON' && saw_cachix_signature=true || true
printf '%s' "$flattened" | grep -Eq 'error:[[:space:]]*.*while evaluating the option.*cachix\.package' && saw_cachix_signature=true || true
# Nix can surface fetched-source corruption as missing subpaths under
# «github:owner/repo/rev»/... during arbitrary flake evaluation, not only
# while resolving the devenv CLI. Retry after clearing fetch/eval caches:
# this indicates an incomplete or stale fetched-source view, not project source.
printf '%s' "$flattened" | grep -Eq "error:[[:space:]]*path '«(github|https?)[:/][^»]+»/[^']+' does not exist" && saw_fetch_signature=true || true
printf '%s' "$flattened" | grep -Eq 'error:[[:space:]]*cannot read file from tarball:[[:space:]]*Truncated tar archive detected while reading data' && saw_fetch_signature=true || true
rm -f "$log"

Expand All @@ -422,7 +427,7 @@ run_nix_gc_race_retry() {
fi

[ -z "$path" ] || nix-store --realise "$path" 2>/dev/null || true
rm -rf ~/.cache/nix/eval-cache-*
rm -rf ~/.cache/nix/eval-cache-* ~/.cache/nix/gitv3 ~/.cache/nix/tarball-cache ~/.cache/nix/tarball-cache-v2 ~/.cache/nix/fetcher-cache*.sqlite*
attempt=$((attempt + 1))
done

Expand Down
Loading