Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

ci: retry tool downloads so GitHub 5xx doesn't fail the gate (#6567)

cua-agents[bot]b432b196cbc4
diff --git a/.github/actions/cua-sandbox/cua-sandbox.sh b/.github/actions/cua-sandbox/cua-sandbox.sh
index ca600a5eae..0a76c9fadb 100755
--- a/.github/actions/cua-sandbox/cua-sandbox.sh
+++ b/.github/actions/cua-sandbox/cua-sandbox.sh
@@ -102,9 +102,9 @@ install_cua() {
mkdir -p "$dir"
url="https://github.com/trycua/cua/releases/download/cua-sdk-v$version"
log "installing cua $version ($platform)"
- curl -fsSL --retry 3 -o "$dir/cua.tar.gz" "$url/cua-cli-$version-$platform.tar.gz" \
+ curl -fsSL --retry 5 --retry-delay 2 --retry-all-errors --connect-timeout 20 -o "$dir/cua.tar.gz" "$url/cua-cli-$version-$platform.tar.gz" \
|| die "cua $version is not released for $platform ($url); pin another cua-version or pass cua-bin"
- curl -fsSL --retry 3 -o "$dir/checksums.txt" "$url/checksums.txt" || die "no checksums.txt in $url"
+ curl -fsSL --retry 5 --retry-delay 2 --retry-all-errors --connect-timeout 20 -o "$dir/checksums.txt" "$url/checksums.txt" || die "no checksums.txt in $url"
local want got
want="$(awk -v f="cua-cli-$version-$platform.tar.gz" '$2 == f || $2 == "*"f {print $1}' "$dir/checksums.txt")"
if command -v sha256sum >/dev/null 2>&1; then
diff --git a/.github/actions/install-actionlint/action.yml b/.github/actions/install-actionlint/action.yml
new file mode 100644
index 0000000000..b7b3b6f30a
--- /dev/null
+++ b/.github/actions/install-actionlint/action.yml
@@ -0,0 +1,25 @@
+name: Install actionlint
+description: >
+ Downloads a pinned actionlint release (retrying on GitHub 5xx and network
+ errors) and puts it on PATH.
+inputs:
+ version:
+ description: actionlint version, without the leading v
+ default: "1.7.12"
+runs:
+ using: composite
+ steps:
+ - name: Download actionlint (retrying)
+ shell: bash
+ env:
+ VERSION: ${{ inputs.version }}
+ run: |
+ set -euo pipefail
+ dir="$RUNNER_TEMP/actionlint-bin"
+ mkdir -p "$dir"
+ curl --fail --silent --show-error --location \
+ --retry 5 --retry-delay 2 --retry-all-errors --connect-timeout 20 \
+ -o "$RUNNER_TEMP/actionlint.tgz" \
+ "https://github.com/rhysd/actionlint/releases/download/v${VERSION}/actionlint_${VERSION}_linux_amd64.tar.gz"
+ tar xzf "$RUNNER_TEMP/actionlint.tgz" -C "$dir" actionlint
+ echo "$dir" >> "$GITHUB_PATH"
diff --git a/.github/scripts/fetch_static_spacesd.sh b/.github/scripts/fetch_static_spacesd.sh
index d08aa252c8..dd02f70505 100755
--- a/.github/scripts/fetch_static_spacesd.sh
+++ b/.github/scripts/fetch_static_spacesd.sh
@@ -11,6 +11,8 @@
# own architecture
# Needs `gh` (GH_TOKEN).
set -euo pipefail
+# shellcheck source=retry.sh
+. "$(dirname "${BASH_SOURCE[0]}")/retry.sh"
REPO="$1" WHAT="$2" DEST="$3"
ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
@@ -32,18 +34,18 @@ trap 'rm -rf "$tmp"' EXIT
download() {
local name="$1" f
if command -v gh >/dev/null 2>&1; then
- gh release download "$TAG" --repo "$REPO" --dir "$tmp" --pattern "$name" --pattern "$name.sha256"
+ retry gh release download "$TAG" --repo "$REPO" --dir "$tmp" --pattern "$name" --pattern "$name.sha256"
return
fi
local auth=()
[ -n "${GH_TOKEN:-}" ] && auth=(-H "Authorization: Bearer $GH_TOKEN")
local rel
- rel="$(curl -fsSL "${auth[@]}" -H "Accept: application/vnd.github+json" "https://api.github.com/repos/$REPO/releases/tags/$TAG")" || return 1
+ rel="$(curl -fsSL --retry 5 --retry-delay 2 --retry-all-errors --connect-timeout 20 "${auth[@]}" -H "Accept: application/vnd.github+json" "https://api.github.com/repos/$REPO/releases/tags/$TAG")" || return 1
for f in "$name" "$name.sha256"; do
local id
id="$(python3 -c 'import json,sys; n=sys.argv[1]; print(next((a["id"] for a in json.load(sys.stdin)["assets"] if a["name"]==n), ""))' "$f" <<<"$rel")"
[ -n "$id" ] || return 1
- curl -fsSL "${auth[@]}" -H "Accept: application/octet-stream" -o "$tmp/$f" "https://api.github.com/repos/$REPO/releases/assets/$id" || return 1
+ curl -fsSL --retry 5 --retry-delay 2 --retry-all-errors --connect-timeout 20 "${auth[@]}" -H "Accept: application/octet-stream" -o "$tmp/$f" "https://api.github.com/repos/$REPO/releases/assets/$id" || return 1
done
}
diff --git a/.github/scripts/retry.sh b/.github/scripts/retry.sh
new file mode 100755
index 0000000000..67dbe17156
--- /dev/null
+++ b/.github/scripts/retry.sh
@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+# Source this file, then run a flaky network command as `retry gh release download ...`.
+# Retries up to 5 times with a growing pause, so one GitHub 5xx does not fail a job.
+retry() {
+ local attempt=1 max=5
+ until "$@"; do
+ if [ "$attempt" -ge "$max" ]; then
+ echo "retry: giving up after $max attempts: $*" >&2
+ return 1
+ fi
+ echo "retry: attempt $attempt failed, retrying in $((attempt * 3))s: $*" >&2
+ sleep $((attempt * 3))
+ attempt=$((attempt + 1))
+ done
+}
diff --git a/.github/workflows/cd-cua-sdk.yml b/.github/workflows/cd-cua-sdk.yml
index d6eb1d5d69..e6619b3007 100644
--- a/.github/workflows/cd-cua-sdk.yml
+++ b/.github/workflows/cd-cua-sdk.yml
@@ -174,7 +174,7 @@ jobs:
apt-get update
apt-get install -y --no-install-recommends git ca-certificates curl build-essential \
pkg-config unzip python3 xz-utils cmake
- curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
+ curl -fsSL --retry 5 --retry-delay 2 --retry-all-errors --connect-timeout 20 https://deb.nodesource.com/setup_22.x | bash -
apt-get install -y nodejs
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Install protoc
@@ -830,7 +830,12 @@ jobs:
cp "$xcframework" release/
cosign sign-blob --yes --bundle release/CuaSDKFFI.xcframework.zip.sigstore.json \
release/CuaSDKFFI.xcframework.zip >/dev/null
- gh release download "$TAG" --pattern checksums.txt --dir previous --repo "$GITHUB_REPOSITORY"
+ # This job has no checkout: retry inline so a GitHub 5xx does not fail the attach.
+ for attempt in 1 2 3 4 5; do
+ gh release download "$TAG" --pattern checksums.txt --dir previous --repo "$GITHUB_REPOSITORY" && break
+ [ "$attempt" -lt 5 ] || exit 1
+ sleep $((attempt * 3))
+ done
(cd release && sha256sum -- CuaSDKFFI.xcframework.zip CuaSDKFFI.xcframework.zip.sigstore.json) > new.txt
grep -v ' CuaSDKFFI\.xcframework\.zip' previous/checksums.txt | cat - new.txt | sort > release/checksums.txt
gh release upload "$TAG" release/* --clobber --repo "$GITHUB_REPOSITORY"
diff --git a/.github/workflows/cd-cua-spaces.yml b/.github/workflows/cd-cua-spaces.yml
index 4c96e64a60..e870fcc00a 100644
--- a/.github/workflows/cd-cua-spaces.yml
+++ b/.github/workflows/cd-cua-spaces.yml
@@ -2224,7 +2224,8 @@ jobs:
# Every asset: the SwiftUI app's, and the Electron installers
# (Windows and Linux always, macOS for a prerelease) with their
# installer-named copies (electron-publish).
- gh release download "$TAG" --dir assets --repo "$GITHUB_REPOSITORY"
+ . "$GITHUB_WORKSPACE/.github/scripts/retry.sh"
+ retry gh release download "$TAG" --dir assets --repo "$GITHUB_REPOSITORY"
rm -f assets/checksums.txt assets/release-artifacts.json assets/latest.json assets/*.sigstore.json
# Keyless Sigstore bundles next to each installer (install.sh and
# install.ps1 verify them with cosign when it is installed).
diff --git a/.github/workflows/cd-py-cua-driver.yml b/.github/workflows/cd-py-cua-driver.yml
index dfede67db8..4aa6bb4014 100644
--- a/.github/workflows/cd-py-cua-driver.yml
+++ b/.github/workflows/cd-py-cua-driver.yml
@@ -271,7 +271,8 @@ jobs:
TAG: ${{ needs.get-version.outputs.tag }}
run: |
mkdir -p "$RUNNER_TEMP/cua-driver-assets" "$RUNNER_TEMP/cua-driver-native"
- gh release download "$TAG" --dir "$RUNNER_TEMP/cua-driver-assets" \
+ . "$GITHUB_WORKSPACE/.github/scripts/retry.sh"
+ retry gh release download "$TAG" --dir "$RUNNER_TEMP/cua-driver-assets" \
--pattern '*-darwin-universal-binary.tar.gz' \
--pattern '*-linux-x86_64-binary.tar.gz' \
--pattern '*-linux-arm64-binary.tar.gz' \
diff --git a/.github/workflows/ci-cua-s1-weights.yml b/.github/workflows/ci-cua-s1-weights.yml
index 3135a4d657..9dae1dfd5c 100644
--- a/.github/workflows/ci-cua-s1-weights.yml
+++ b/.github/workflows/ci-cua-s1-weights.yml
@@ -374,7 +374,7 @@ jobs:
mkdir -p "$PERCEPTION_DIR"
cd "$PERCEPTION_DIR"
for asset in "${stem}.catalog.json" "${stem}.tar.gz" SHA256SUMS; do
- curl --fail --silent --show-error --location --retry 3 -o "$asset" "$base/$asset"
+ curl --fail --silent --show-error --location --retry 5 --retry-delay 2 --retry-all-errors --connect-timeout 20 -o "$asset" "$base/$asset"
done
grep -E " \*?(${stem}\.catalog\.json|${stem}\.tar\.gz)$" SHA256SUMS | sha256sum --check --strict
echo "${PERCEPTION_ARCHIVE_SHA256} ${stem}.tar.gz" | sha256sum --check --strict
diff --git a/.github/workflows/ci-cua-sandbox-action.yml b/.github/workflows/ci-cua-sandbox-action.yml
index 7e2cd840f1..d40c1257b1 100644
--- a/.github/workflows/ci-cua-sandbox-action.yml
+++ b/.github/workflows/ci-cua-sandbox-action.yml
@@ -35,11 +35,9 @@ jobs:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: shellcheck
run: shellcheck .github/actions/cua-sandbox/cua-sandbox.sh
+ - name: Install actionlint
+ uses: ./.github/actions/install-actionlint
- name: actionlint on the docs examples
run: |
set -euo pipefail
- VERSION=1.7.12
- curl -fsSL -o actionlint.tgz \
- "https://github.com/rhysd/actionlint/releases/download/v${VERSION}/actionlint_${VERSION}_linux_amd64.tar.gz"
- tar xzf actionlint.tgz actionlint
- python3 .github/actions/cua-sandbox/lint-docs-yaml.py ./actionlint
+ python3 .github/actions/cua-sandbox/lint-docs-yaml.py actionlint
diff --git a/.github/workflows/ci-distro-compat-cua-driver.yml b/.github/workflows/ci-distro-compat-cua-driver.yml
index 89b1063eb7..3f65c2cf24 100644
--- a/.github/workflows/ci-distro-compat-cua-driver.yml
+++ b/.github/workflows/ci-distro-compat-cua-driver.yml
@@ -119,7 +119,7 @@ jobs:
# Release assets are staged before the draft becomes public. Keep a
# short retry window only for transient GitHub/CDN propagation.
curl --fail --silent --show-error --location \
- --retry 5 --retry-delay 2 --retry-all-errors \
+ --retry 5 --retry-delay 2 --retry-all-errors --connect-timeout 20 \
"$BINARY_URL" -o cua-driver-release.tar.gz
- name: Cache released binary for matrix
diff --git a/.github/workflows/ci-lint-workflows.yml b/.github/workflows/ci-lint-workflows.yml
index 3195e00769..ad80dc7e22 100644
--- a/.github/workflows/ci-lint-workflows.yml
+++ b/.github/workflows/ci-lint-workflows.yml
@@ -36,13 +36,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
+ - name: Install actionlint
+ uses: ./.github/actions/install-actionlint
- name: Run actionlint
run: |
set -euo pipefail
- VERSION=1.7.12
- curl -fsSL -o actionlint.tgz \
- "https://github.com/rhysd/actionlint/releases/download/v${VERSION}/actionlint_${VERSION}_linux_amd64.tar.gz"
- tar xzf actionlint.tgz actionlint
# shellcheck findings inside `run:` blocks are advisory here; the
# expression/context errors that kill a workflow outright are not.
- ./actionlint -shellcheck= -pyflakes=
+ actionlint -shellcheck= -pyflakes=
diff --git a/.github/workflows/ci-openkoalabot-example-samples.yml b/.github/workflows/ci-openkoalabot-example-samples.yml
index 0093877400..e6e147c99d 100644
--- a/.github/workflows/ci-openkoalabot-example-samples.yml
+++ b/.github/workflows/ci-openkoalabot-example-samples.yml
@@ -104,7 +104,7 @@ jobs:
npm ci
node ../scripts/stage-uniffi-library.mjs --only=node
npm run build
- command -v wasm-pack >/dev/null || curl -fsSL https://rustwasm.github.io/wasm-pack/installer/init.sh | sh -s -- -f
+ command -v wasm-pack >/dev/null || curl -fsSL --retry 5 --retry-delay 2 --retry-all-errors --connect-timeout 20 https://rustwasm.github.io/wasm-pack/installer/init.sh | sh -s -- -f
command -v wasm-bindgen >/dev/null || cargo install --locked wasm-bindgen-cli --version 0.2.126
npm run build:browser
- name: Test the sample
diff --git a/.github/workflows/ci-quick.yml b/.github/workflows/ci-quick.yml
index 94f55d8c6a..d3a242e17c 100644
--- a/.github/workflows/ci-quick.yml
+++ b/.github/workflows/ci-quick.yml
@@ -60,14 +60,7 @@ jobs:
enable-cache: true
- name: Install actionlint
if: steps.marker.outputs.cache-hit != 'true'
- run: |
- set -euo pipefail
- VERSION=1.7.12
- curl -fsSL -o "$RUNNER_TEMP/actionlint.tgz" \
- "https://github.com/rhysd/actionlint/releases/download/v${VERSION}/actionlint_${VERSION}_linux_amd64.tar.gz"
- mkdir -p "$RUNNER_TEMP/bin"
- tar xzf "$RUNNER_TEMP/actionlint.tgz" -C "$RUNNER_TEMP/bin" actionlint
- echo "$RUNNER_TEMP/bin" >> "$GITHUB_PATH"
+ uses: ./.github/actions/install-actionlint
- name: bin/ci --quick
if: steps.marker.outputs.cache-hit != 'true'
# --no-install: a check that needs a package's node_modules is skipped here (its own workflow
diff --git a/.github/workflows/cua-driver-release-signatures.yml b/.github/workflows/cua-driver-release-signatures.yml
index 3f792eba87..0098c9a0c4 100644
--- a/.github/workflows/cua-driver-release-signatures.yml
+++ b/.github/workflows/cua-driver-release-signatures.yml
@@ -88,7 +88,8 @@ jobs:
RELEASE_REPOSITORY: ${{ inputs.release_repository }}
run: |
set -euo pipefail
- gh release download "cua-driver-rs-v${VERSION}" \
+ . "$GITHUB_WORKSPACE/.github/scripts/retry.sh"
+ retry gh release download "cua-driver-rs-v${VERSION}" \
--repo "${RELEASE_REPOSITORY:-$GITHUB_REPOSITORY}" \
--dir signature-artifacts \
--pattern "cua-driver-rs-${VERSION}-darwin-*.tar.gz" \
@@ -140,7 +141,8 @@ jobs:
RELEASE_REPOSITORY: ${{ inputs.release_repository }}
run: |
set -euo pipefail
- gh release download "cua-driver-rs-v${VERSION}" \
+ . "$GITHUB_WORKSPACE/.github/scripts/retry.sh"
+ retry gh release download "cua-driver-rs-v${VERSION}" \
--repo "${RELEASE_REPOSITORY:-$GITHUB_REPOSITORY}" \
--dir signature-artifacts \
--pattern "cua-driver-rs-${VERSION}-windows-*.zip"
diff --git a/.github/workflows/nightly-cua-spaces.yml b/.github/workflows/nightly-cua-spaces.yml
index 54d84b31cf..0599254f98 100644
--- a/.github/workflows/nightly-cua-spaces.yml
+++ b/.github/workflows/nightly-cua-spaces.yml
@@ -348,7 +348,8 @@ jobs:
# Installers no feed names any more go (the fixed-name downloads stay).
mkdir -p "$RUNNER_TEMP/live"
- gh release download "$TAG" --repo "$GITHUB_REPOSITORY" --pattern "*.yml" --pattern "$APPCAST" \
+ . "$GITHUB_WORKSPACE/.github/scripts/retry.sh"
+ retry gh release download "$TAG" --repo "$GITHUB_REPOSITORY" --pattern "*.yml" --pattern "$APPCAST" \
--dir "$RUNNER_TEMP/live" --clobber
keep="$(python3 -I - "$RUNNER_TEMP/live" <<'PY'
import os, re, sys, urllib.parse
@@ -388,7 +389,8 @@ jobs:
{ echo "::error::$TAG is not a prerelease"; exit 1; }
# Every installer a nightly feed names, and every fixed-name download, resolves.
dir="$RUNNER_TEMP/check"; mkdir -p "$dir"
- gh release download "$TAG" --repo "$GITHUB_REPOSITORY" --pattern "*.yml" --pattern "$APPCAST" --dir "$dir" --clobber
+ . "$GITHUB_WORKSPACE/.github/scripts/retry.sh"
+ retry gh release download "$TAG" --repo "$GITHUB_REPOSITORY" --pattern "*.yml" --pattern "$APPCAST" --dir "$dir" --clobber
[ ! -f "$dir/$APPCAST" ] || python3 -I .github/scripts/sparkle_feed.py nightly "$dir/$APPCAST"
urls="$( { grep -hoE 'https://[^"'"'"' ]+' "$dir"/*.yml 2>/dev/null || true; \
grep -hoE 'url="https://[^"]+"' "$dir"/*.xml 2>/dev/null | sed 's/^url="//; s/"$//' || true; } | sort -u)"
diff --git a/.github/workflows/release-rollout.yml b/.github/workflows/release-rollout.yml
index ce6ff39932..8b3649465f 100644
--- a/.github/workflows/release-rollout.yml
+++ b/.github/workflows/release-rollout.yml
@@ -109,6 +109,7 @@ jobs:
if: ${{ !inputs.dry_run }}
run: |
set -euo pipefail
+ . "$GITHUB_WORKSPACE/.github/scripts/retry.sh"
shopt -s nullglob
files=(out/*.yml out/*.xml)
if [ ${#files[@]} -gt 0 ]; then
@@ -120,7 +121,7 @@ jobs:
# Read back what is live.
mkdir -p live
for f in "${files[@]}"; do
- gh release download "$TAG" --pattern "$(basename "$f")" --dir live --clobber --repo "$GITHUB_REPOSITORY"
+ retry gh release download "$TAG" --pattern "$(basename "$f")" --dir live --clobber --repo "$GITHUB_REPOSITORY"
cmp "$f" "live/$(basename "$f")"
done
echo "Uploaded: ${files[*]:-nothing}" >> "$GITHUB_STEP_SUMMARY"
diff --git a/.github/workflows/space-egress-nightly.yml b/.github/workflows/space-egress-nightly.yml
index a32bd02462..8ca6cc7b33 100644
--- a/.github/workflows/space-egress-nightly.yml
+++ b/.github/workflows/space-egress-nightly.yml
@@ -136,7 +136,7 @@ jobs:
run: |
set -euo pipefail
mkdir -p "$HOME/egress"
- curl -fsSL -o "$HOME/egress/noble.qcow2" \
+ curl -fsSL --fail --retry 5 --retry-delay 2 --retry-all-errors --connect-timeout 20 -o "$HOME/egress/noble.qcow2" \
https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img
cargo build --locked --release -p cua-microvm-init --target x86_64-unknown-linux-musl
- name: Egress policies of QEMU and Firecracker VMs
diff --git a/bin/ci b/bin/ci
index ba2f3551a1..4be0221238 100755
--- a/bin/ci
+++ b/bin/ci
@@ -626,7 +626,7 @@ def static_checks(changes: Changes, ctx: "Context") -> List[Check]:
if changes.touches(r"^\.github/(workflows|actions)/|^\.github/actionlint\.yaml$"):
add(Check("actionlint", "actionlint (workflows)", "actionlint -shellcheck= -pyflakes=",
tools=("actionlint",), hint="install: brew install actionlint (CI pins v1.7.12)",
- ci=(("ci-lint-workflows.yml", "./actionlint -shellcheck= -pyflakes="),)))
+ ci=(("ci-lint-workflows.yml", "actionlint -shellcheck= -pyflakes="),)))
if changes.touches(r"^\.github/(workflows/|larger-runners-allowed\.txt|scripts/check_no_larger_runners\.py)"):
add(Check("larger-runners", "no paid larger runners in workflows",