From d16df1e2240323f0fad04c00ddd3ad485610ea55 Mon Sep 17 00:00:00 2001 From: kingchenc Date: Mon, 8 Jun 2026 02:22:26 +0200 Subject: [PATCH] ci: warm the cargo registry with backoff so a DNS blip can't fail clippy (#210) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Problem A macOS runner on #206 failed the **Rust** job's clippy step with: ``` Updating crates.io index error: failed to get `rayon` as a dependency ... download of config.json failed [6] Couldn't resolve host name (Could not resolve host: index.crates.io) ``` A pure transient DNS blip — unrelated to the change (a docs-only PR). `CARGO_NET_RETRY=10` only does fast in-process retries; a longer DNS outage outlasts them, so the very first cargo step's crates.io index fetch fails the whole job. ## Fix Add a **Warm cargo registry** step right after the cache restore in the `rust`, `clippy-bindings` and `msrv` jobs. It runs `cargo fetch` in a 5-attempt loop with real backoff (20/40/60/80s sleeps) so the dependency graph is pulled once, patiently, riding out a multi-second DNS outage that cargo's rapid retries can't. The later clippy/build/test steps then resolve from the warmed local cache. Mirrors the existing inline retry pattern already used for setup-node/setup-python CDN flakes. Can be extended to the coverage/python/wasm/node jobs if they ever hit the same blip. --- .github/workflows/ci.yml | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 54838916..dccd7c5c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,6 +53,22 @@ jobs: continue-on-error: true # cache is an optimisation; never block on a stuck/slow restore timeout-minutes: 6 + - name: Warm cargo registry (retry transient DNS/registry flakes) + shell: bash + # CARGO_NET_RETRY rides out short blips, but a longer runner DNS outage + # outlasts cargo's rapid in-process retries: the crates.io index fetch + # the first cargo step does ("Could not resolve host: index.crates.io") + # then fails the whole job. Pre-fetch the dependency graph here with real + # backoff so clippy/build/test resolve from the warmed local cache. + run: | + for attempt in 1 2 3 4 5; do + if cargo fetch; then exit 0; fi + echo "::warning::cargo fetch failed (attempt $attempt/5) — likely a registry/DNS flake; retrying in $((attempt * 20))s..." + sleep $((attempt * 20)) + done + echo "::error::cargo fetch still failing after 5 attempts" + exit 1 + - name: Format check run: cargo fmt --all -- --check @@ -232,6 +248,19 @@ jobs: continue-on-error: true # cache is an optimisation; never block on a stuck/slow restore timeout-minutes: 6 + - name: Warm cargo registry (retry transient DNS/registry flakes) + shell: bash + # See the rust job: pre-fetch with backoff so the clippy index update + # can't fail the job on a transient "Could not resolve host" DNS blip. + run: | + for attempt in 1 2 3 4 5; do + if cargo fetch; then exit 0; fi + echo "::warning::cargo fetch failed (attempt $attempt/5) — likely a registry/DNS flake; retrying in $((attempt * 20))s..." + sleep $((attempt * 20)) + done + echo "::error::cargo fetch still failing after 5 attempts" + exit 1 + - name: Clippy (bindings, all targets) run: cargo clippy -p wickra-node -p wickra-python --all-targets -- -D warnings @@ -272,6 +301,19 @@ jobs: continue-on-error: true # cache is an optimisation; never block on a stuck/slow restore timeout-minutes: 6 + - name: Warm cargo registry (retry transient DNS/registry flakes) + shell: bash + # See the rust job: pre-fetch with backoff so the first cargo step can't + # fail the job on a transient "Could not resolve host" DNS blip. + run: | + for attempt in 1 2 3 4 5; do + if cargo fetch; then exit 0; fi + echo "::warning::cargo fetch failed (attempt $attempt/5) — likely a registry/DNS flake; retrying in $((attempt * 20))s..." + sleep $((attempt * 20)) + done + echo "::error::cargo fetch still failing after 5 attempts" + exit 1 + - name: Build on MSRV run: cargo build ${{ matrix.packages }} --verbose