ci: harden cache, timeouts and retries across CI and release (#328)
Hardens both workflows after the R-on-ubuntu job repeatedly hit the 20-minute job cap and was cancelled (no R-package cache + no retry + a slow source build). Each item below maps to the requested checklist. ### CI (`ci.yml`) - **Timeouts 20 → 30 min** on every job (backstop only; real jobs finish well under). - **R dependencies cached**: replace the manual `install.packages(testthat/knitr)` with `r-lib/actions/setup-r-dependencies` — restores a cached R library and pulls **RSPM binaries** instead of compiling from source (the slow/flaky path that blew the cap). This is the actual root-cause fix. - **NuGet cache** for the C# job (`~/.nuget/packages`, keyed on the project files). - **Retry** the network installs that had none — `npm ci`, `dotnet test`, `mvn install` — via `nick-fields/retry` (2–3 attempts, backoff). On top of the existing env-level retries (`CARGO_NET_RETRY`, `npm_config_fetch_retries`, `PIP_RETRIES`) and the setup-* CDN-flake retries. - **Go stays `cache: false`** on purpose: the module has no `go.sum` / external deps, so there is nothing to cache (enabling it would only warn). ### Release (`release.yml`) - **Per-job timeouts** added (there were none — only GitHub's 6h default): **45 min**, higher than CI's 30 because the wheel/build jobs compile from source incl. **vendored OpenSSL** and must not be killed mid-build. - **wasm-publish** gets a `Swatinem/rust-cache` like the other Rust-build jobs. - **Retry** the no-retry network installs (`npm ci` ×2, `dotnet pack`). The actual publish/deploy steps are left alone — they are already idempotent (skip-existing / skip-duplicate), so re-running the job is the safe recovery. ### R binding download (`bindings/r/configure[.win]`) - A freshly cut release can 404 for 1–2 min while assets propagate, which broke the C ABI download (`cannot open URL … 404`). Add a `wickra_download` retry helper (6 × 20s ≈ 2 min backoff) for both the release-asset and wasm-source downloads. Note: the CI R job builds the C ABI **locally** (`WICKRA_*_DIR`), so it never downloads — this fix covers the real-world r-universe / end-user build. This PR's own CI exercises the CI changes (the reworked R job, caches, retries, timeouts) before merge; the release-only changes are validated on the next tag.
This commit is contained in:
Vendored
+22
-4
@@ -14,6 +14,26 @@ set -e
|
||||
inc=""
|
||||
lib=""
|
||||
|
||||
# A freshly-cut GitHub release can briefly return 404 while its assets propagate
|
||||
# across the CDN, and a transient network blip should not fail the build either.
|
||||
# Retry base R's download.file with a backoff (~2 min total) instead of giving up
|
||||
# on the first miss.
|
||||
wickra_download() {
|
||||
_url="$1"
|
||||
_dest="$2"
|
||||
_attempt=1
|
||||
while [ "${_attempt}" -le 6 ]; do
|
||||
if "${R_HOME}/bin/Rscript" -e "download.file('${_url}', '${_dest}', mode = 'wb', quiet = TRUE)"; then
|
||||
return 0
|
||||
fi
|
||||
echo "wickra: download attempt ${_attempt}/6 failed (${_url}); the release asset may still be propagating — retrying in 20s..."
|
||||
sleep 20
|
||||
_attempt=$((_attempt + 1))
|
||||
done
|
||||
echo "wickra: failed to download ${_url} after 6 attempts"
|
||||
return 1
|
||||
}
|
||||
|
||||
# WebAssembly (r-universe / webR): there is no prebuilt wasm C ABI to download,
|
||||
# but the build image ships cargo (/usr/local/cargo/bin) and emscripten
|
||||
# (EMSDK on PATH), so build the C ABI staticlib from source for
|
||||
@@ -26,8 +46,7 @@ if [ "$(uname -s)" = "Emscripten" ]; then
|
||||
echo "wickra: building C ABI from source for wasm32-unknown-emscripten (v${version})"
|
||||
build=$(mktemp -d)
|
||||
url="https://github.com/wickra-lib/wickra/archive/refs/tags/v${version}.tar.gz"
|
||||
"${R_HOME}/bin/Rscript" -e "download.file('${url}', '${build}/src.tar.gz', mode = 'wb', quiet = TRUE)" \
|
||||
|| { echo "wickra: failed to download source ${url}"; exit 1; }
|
||||
wickra_download "${url}" "${build}/src.tar.gz" || exit 1
|
||||
"${R_HOME}/bin/Rscript" -e "untar('${build}/src.tar.gz', exdir = '${build}')"
|
||||
root="${build}/wickra-${version}"
|
||||
rustup target add wasm32-unknown-emscripten 2>/dev/null || true
|
||||
@@ -73,8 +92,7 @@ else
|
||||
esac
|
||||
url="https://github.com/wickra-lib/wickra/releases/download/v${version}/wickra-c-${triple}.tar.gz"
|
||||
echo "wickra: downloading C ABI ${triple} for v${version}"
|
||||
"${R_HOME}/bin/Rscript" -e "download.file('${url}', 'src/wickra-c.tar.gz', mode = 'wb', quiet = TRUE)" \
|
||||
|| { echo "wickra: failed to download ${url}"; exit 1; }
|
||||
wickra_download "${url}" "src/wickra-c.tar.gz" || exit 1
|
||||
"${R_HOME}/bin/Rscript" -e "untar('src/wickra-c.tar.gz', exdir = 'src/wickra-c')"
|
||||
inc="src/wickra-c/wickra-c-${triple}/include"
|
||||
lib="src/wickra-c/wickra-c-${triple}/lib"
|
||||
|
||||
@@ -10,6 +10,26 @@
|
||||
# WICKRA_LIB_DIR to build against a locally built C ABI instead (dev override).
|
||||
set -e
|
||||
|
||||
# A freshly-cut GitHub release can briefly return 404 while its assets propagate
|
||||
# across the CDN, and a transient network blip should not fail the build either.
|
||||
# Retry base R's download.file with a backoff (~2 min total) instead of giving up
|
||||
# on the first miss.
|
||||
wickra_download() {
|
||||
_url="$1"
|
||||
_dest="$2"
|
||||
_attempt=1
|
||||
while [ "${_attempt}" -le 6 ]; do
|
||||
if "${R_HOME}/bin/Rscript" -e "download.file('${_url}', '${_dest}', mode = 'wb', quiet = TRUE)"; then
|
||||
return 0
|
||||
fi
|
||||
echo "wickra: download attempt ${_attempt}/6 failed (${_url}); the release asset may still be propagating — retrying in 20s..."
|
||||
sleep 20
|
||||
_attempt=$((_attempt + 1))
|
||||
done
|
||||
echo "wickra: failed to download ${_url} after 6 attempts"
|
||||
return 1
|
||||
}
|
||||
|
||||
if [ -n "${WICKRA_INCLUDE_DIR}" ] && [ -n "${WICKRA_LIB_DIR}" ]; then
|
||||
echo "wickra: using C ABI from WICKRA_INCLUDE_DIR / WICKRA_LIB_DIR (dev override)"
|
||||
inc="${WICKRA_INCLUDE_DIR}"
|
||||
@@ -24,8 +44,7 @@ else
|
||||
esac
|
||||
url="https://github.com/wickra-lib/wickra/releases/download/v${version}/wickra-c-${triple}.tar.gz"
|
||||
echo "wickra: downloading C ABI ${triple} for v${version}"
|
||||
"${R_HOME}/bin/Rscript" -e "download.file('${url}', 'src/wickra-c.tar.gz', mode = 'wb', quiet = TRUE)" \
|
||||
|| { echo "wickra: failed to download ${url}"; exit 1; }
|
||||
wickra_download "${url}" "src/wickra-c.tar.gz" || exit 1
|
||||
"${R_HOME}/bin/Rscript" -e "untar('src/wickra-c.tar.gz', exdir = 'src/wickra-c')"
|
||||
inc="src/wickra-c/wickra-c-${triple}/include"
|
||||
lib="src/wickra-c/wickra-c-${triple}/lib"
|
||||
|
||||
Reference in New Issue
Block a user