An open source, non-profit web search engine
Retry the native build, which fails on a reset download
Daoud Clarke0bb088118c8b
diff --git a/.github/actions/setup-project/action.yml b/.github/actions/setup-project/action.ymlindex 367e71a..a526863 100644--- a/.github/actions/setup-project/action.yml+++ b/.github/actions/setup-project/action.yml@@ -18,11 +18,18 @@ runs:cache-dependency-glob: "uv.lock"- name: Install Rust toolchainuses: dtolnay/rust-toolchain@stable+ # Both of these build the Rust extension, and its xgboost_lib-sys dependency's build+ # script downloads a prebuilt libxgboost.so from github.com every time it runs. That+ # download is not retried and its failure is a panic, so a single reset connection+ # ends the whole job before Claude has started - which is what killed run 34278357092+ # ("Connection reset by peer" fetching libxgboost.so). Retrying the build is enough:+ # the download is repeated from scratch each attempt, and everything cargo already+ # compiled is still in target/, so a second attempt costs little.- name: Install dependencies- run: uv sync --group dev+ run: .github/scripts/retry.sh uv sync --group devshell: bash- name: Install project with maturin- run: uv run maturin develop+ run: .github/scripts/retry.sh uv run maturin developshell: bash- name: Create test directories and filesrun: mkdir -p /tmp/test_mwmbl_datadiff --git a/.github/scripts/retry.sh b/.github/scripts/retry.shnew file mode 100755index 0000000..7386644--- /dev/null+++ b/.github/scripts/retry.sh@@ -0,0 +1,27 @@+#!/usr/bin/env bash+#+# Run a command, and run it again if it fails.+#+# For build steps whose failures are dominated by the network rather than by the code:+# see the comment in .github/actions/setup-project/action.yml for the one that made this+# necessary. A command that fails because the tree is broken fails every attempt, so the+# only thing this costs in that case is the time of the extra attempts.++set -euo pipefail++attempts=${RETRY_ATTEMPTS:-3}+delay=${RETRY_DELAY:-15}++for attempt in $(seq 1 "$attempts"); do+ status=0+ "$@" || status=$?+ if [[ $status -eq 0 ]]; then+ exit 0+ fi+ if [[ $attempt -eq $attempts ]]; then+ echo "::error::'$*' failed $attempts times; giving up."+ exit "$status"+ fi+ echo "::warning::'$*' failed (attempt $attempt of $attempts, exit $status); retrying in ${delay}s."+ sleep "$delay"+donediff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex b029c7a..4c74f26 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -79,15 +79,19 @@ jobs:#----------------------------------------------# install dependencies+ #+ # Retried for the same reason as in .github/actions/setup-project: building the+ # Rust extension downloads a prebuilt libxgboost.so, and a reset connection there+ # panics the build script rather than being retried by it.#----------------------------------------------- name: Install dependencies- run: uv sync --group dev+ run: .github/scripts/retry.sh uv sync --group dev#----------------------------------------------# build and install the project with maturin# (compiles the Rust extension and installs the package)#----------------------------------------------- name: Install project with maturin- run: uv run maturin develop+ run: .github/scripts/retry.sh uv run maturin develop#----------------------------------------------# run test suite#----------------------------------------------