Skip to content

Commit ccf6b37

Browse files
committed
fix(ci): pre-clone nargo external git deps with retry to survive DNS flakes
1 parent 460a87e commit ccf6b37

5 files changed

Lines changed: 76 additions & 0 deletions

File tree

noir-projects/aztec-nr/bootstrap.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ else
1313
fi
1414

1515
function build {
16+
# Pre-clone external nargo git deps with retry, to survive transient DNS
17+
# hiccups that otherwise fail a single merge-queue-heavy shard.
18+
../scripts/prefetch_nargo_git_deps.sh
19+
1620
# Being a library, aztec-nr does not technically need to be built. But we can still run nargo check to find any type
1721
# errors and prevent warnings
1822
echo_stderr "Checking aztec-nr for warnings..."

noir-projects/bootstrap.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ function build {
99
# Also doubles up as our formatting check.
1010
function prep {
1111
set -eu
12+
./scripts/prefetch_nargo_git_deps.sh
1213
(cd noir-protocol-circuits && yarn && node ./scripts/generate_variants.js)
1314
for dir in noir-contracts noir-protocol-circuits mock-protocol-circuits aztec-nr; do
1415
(cd $dir && ../../noir/noir-repo/target/release/nargo fmt --check)

noir-projects/noir-contracts/bootstrap.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ export -f compile
137137
# If given an argument, it's the contract to compile.
138138
# Otherwise parse out all relevant contracts from the root Nargo.toml and process them in parallel.
139139
function build {
140+
# Pre-clone external nargo git deps with retry, to survive transient DNS
141+
# hiccups that otherwise fail a single merge-queue-heavy shard.
142+
../scripts/prefetch_nargo_git_deps.sh
143+
140144
echo_stderr "Compiling contracts (bb-hash: $BB_HASH)..."
141145
local folder_name
142146
if [ -n "${DOCS_WORKING_DIR:-}" ]; then

noir-projects/noir-protocol-circuits/bootstrap.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ export -f hex_to_fields_json compile
149149
function build {
150150
set -eu
151151

152+
# Pre-clone external nargo git deps with retry, to survive transient DNS
153+
# hiccups that otherwise fail a single merge-queue-heavy shard.
154+
../scripts/prefetch_nargo_git_deps.sh
155+
152156
# If pinned-build.tar.gz exists, use it instead of compiling.
153157
if [ -f pinned-build.tar.gz ]; then
154158
echo_stderr "Using pinned-build.tar.gz instead of compiling."
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env bash
2+
# Pre-clone external nargo git dependencies referenced in Nargo.toml files under
3+
# noir-projects/ with bounded retry. Works around transient DNS / network failures
4+
# during nargo's on-demand clone (e.g. "Could not resolve host: github.com"),
5+
# which on merge-queue-heavy shards halts the entire run via parallel --halt fail=1.
6+
#
7+
# Idempotent: skips deps already cached. Safe under concurrent invocation across
8+
# parallel make targets via a per-dep flock.
9+
10+
set -euo pipefail
11+
12+
NARGO_HOME="${NARGO_HOME:-$HOME/nargo}"
13+
ROOT="$(git rev-parse --show-toplevel)"
14+
15+
mapfile -t deps < <(
16+
find "$ROOT/noir-projects" -name Nargo.toml -print0 \
17+
| xargs -0 grep -hE 'git\s*=\s*"https://github\.com/[^"]+"' \
18+
| sed -nE 's/.*git\s*=\s*"https:\/\/github\.com\/([^"]+)".*tag\s*=\s*"([^"]+)".*/\1|\2/p;
19+
t end;
20+
s/.*tag\s*=\s*"([^"]+)".*git\s*=\s*"https:\/\/github\.com\/([^"]+)".*/\2|\1/p;
21+
:end' \
22+
| sort -u
23+
)
24+
25+
clone_one() (
26+
set -euo pipefail
27+
local org_repo=$1
28+
local tag=$2
29+
local dest="$NARGO_HOME/github.com/$org_repo/$tag"
30+
if [ -f "$dest/Nargo.toml" ]; then
31+
return 0
32+
fi
33+
mkdir -p "$(dirname "$dest")"
34+
local lock="$NARGO_HOME/github.com/$org_repo/.$tag.lock"
35+
exec 9>"$lock"
36+
flock 9
37+
if [ -f "$dest/Nargo.toml" ]; then
38+
return 0
39+
fi
40+
rm -rf "$dest"
41+
local attempt
42+
for attempt in 1 2 3; do
43+
if git -c advice.detachedHead=false clone --quiet --depth 1 --branch "$tag" "https://github.com/$org_repo" "$dest"; then
44+
return 0
45+
fi
46+
rm -rf "$dest"
47+
if [ "$attempt" -lt 3 ]; then
48+
sleep $((attempt * 2))
49+
fi
50+
done
51+
echo "ERROR: failed to clone https://github.com/$org_repo @ $tag after 3 attempts" >&2
52+
return 1
53+
)
54+
55+
failed=0
56+
for dep in "${deps[@]}"; do
57+
IFS='|' read -r org_repo tag <<< "$dep"
58+
if ! clone_one "$org_repo" "$tag"; then
59+
failed=1
60+
fi
61+
done
62+
63+
exit $failed

0 commit comments

Comments
 (0)