-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·142 lines (117 loc) · 4.5 KB
/
bootstrap.sh
File metadata and controls
executable file
·142 lines (117 loc) · 4.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/usr/bin/env bash
source $(git rev-parse --show-toplevel)/ci3/source_bootstrap
export RAYON_NUM_THREADS=${RAYON_NUM_THREADS:-16}
export HARDWARE_CONCURRENCY=${HARDWARE_CONCURRENCY:-16}
export NARGO=${NARGO:-../../noir/noir-repo/target/release/nargo}
# Fairies want to run these tests on every PR
if [ "${TARGET_BRANCH:-}" = "merge-train/fairies" ]; then
hash=disabled-cache
else
hash=$(hash_str $(../../noir/bootstrap.sh hash) $(cache_content_hash "^noir-projects/aztec-nr"))
fi
function build {
# Being a library, aztec-nr does not technically need to be built. But we can still run nargo check to find any type
# errors and prevent warnings
echo_stderr "Checking aztec-nr for warnings..."
$NARGO check --deny-warnings
# We also check that no docstring links are broken
$NARGO doc --check
}
function test_cmds {
i=0
$NARGO test --list-tests --silence-warnings | sort | while read -r package test; do
# We assume there are 8 txe's running.
port=$((14730 + (i++ % ${NUM_TXES:-1})))
echo "$hash noir-projects/scripts/run_test.sh aztec-nr $package $test $port"
done
}
function test {
# Start txe server.
# Port is below the Linux ephemeral range (32768-60999) to avoid conflicts.
local txe_base_port=14730
trap 'kill $(jobs -p)' EXIT
check_port $txe_base_port || echo "WARNING: port $txe_base_port is in use, TXE may fail to start"
(cd $root/yarn-project/txe && UV_THREADPOOL_SIZE=8 LOG_LEVEL=error TXE_PORT=$txe_base_port yarn start) &
echo "Waiting for TXE to start..."
local j=0
while ! nc -z 127.0.0.1 $txe_base_port &>/dev/null; do
if [ $j == 60 ]; then
echo "TXE failed to start on port $txe_base_port after 60s." >&2
check_port $txe_base_port
exit 1
fi
sleep 1
j=$((j+1))
done
export NARGO_FOREIGN_CALL_TIMEOUT=300000
test_cmds | filter_test_cmds | parallelize
# Run the macro compilation failure tests
./macro_compilation_failure_tests/assert_macro_compilation_failure.sh
}
function format {
$NARGO fmt
}
function release {
release_git_push "master" $REF_NAME
}
function release_git_push {
local branch_name=$1
local tag_name=$2
local mirrored_repo_url="https://github.com/AztecProtocol/aztec-nr.git"
# Clean up our release directory.
rm -rf release-out && mkdir release-out
# Copy our git files to our release directory.
git archive HEAD -- . | tar -x -C release-out
cd release-out
# Update Nargo.toml files to reference noir-protocol-circuits from the monorepo tag
monorepo_url="https://github.com/AztecProtocol/aztec-packages"
monorepo_protocol_circuits_path="noir-projects/noir-protocol-circuits"
# Find all Nargo.toml files that reference noir-protocol-circuits
nargo_files="$(find . -name 'Nargo.toml' | xargs grep --files-with-matches 'noir-protocol-circuits' || true)"
# Replace relative paths with git references
for nargo_file in $nargo_files; do
sed --regexp-extended --in-place \
"s;path\s*=\s*\".*noir-protocol-circuits(.*)\";git=\"$monorepo_url\", tag=\"$tag_name\", directory=\"$monorepo_protocol_circuits_path\1\";" \
$nargo_file
done
# CI needs to authenticate from GITHUB_TOKEN.
gh auth setup-git &>/dev/null || true
git init &>/dev/null
git remote add origin "$mirrored_repo_url" &>/dev/null
git fetch origin --quiet
# Checkout the existing branch or create it if it doesn't exist.
if git ls-remote --heads origin "$branch_name" | grep -q "$branch_name"; then
# Update branch reference without checkout.
git branch -f "$branch_name" origin/"$branch_name"
# Point HEAD to the branch.
git symbolic-ref HEAD refs/heads/"$branch_name"
# Move to latest commit, keep working tree.
git reset --soft origin/"$branch_name"
else
git checkout -b "$branch_name"
fi
if git rev-parse "$tag_name" >/dev/null 2>&1; then
echo "Tag $tag_name already exists. Skipping release."
else
git add .
git commit -m "Release $tag_name." >/dev/null
git tag -a "$tag_name" -m "Release $tag_name."
do_or_dryrun git push origin "$branch_name" --quiet
do_or_dryrun git push origin --quiet --force "$tag_name" --tags
echo "Release complete ($tag_name) on branch $branch_name."
fi
do_or_dryrun git push origin "$branch_name" --quiet
do_or_dryrun git push origin --quiet --force "$tag_name" --tags
echo "Release complete ($tag_name) on branch $branch_name."
}
case "$cmd" in
"")
build
;;
"test-macro-compilation-failure")
./macro_compilation_failure_tests/assert_macro_compilation_failure.sh
;;
*)
default_cmd_handler "$@"
;;
esac