-
Notifications
You must be signed in to change notification settings - Fork 333
/
Copy pathEarthfile
260 lines (209 loc) · 8 KB
/
Earthfile
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
VERSION 0.8
nargo-src:
FROM ../build-images/+from-registry
WORKDIR /usr/src
# Relevant source (TODO finer-grained 'tooling')
COPY --dir \
noir-repo/acvm-repo \
noir-repo/compiler \
noir-repo/noir_stdlib \
noir-repo/tooling \
noir-repo/test_programs \
noir-repo/utils \
noir-repo/Cargo.lock \
noir-repo/Cargo.toml \
noir-repo/.github \
noir-repo
# Fetch any dependencies so that they can be cached
RUN cd noir-repo && cargo fetch && cd ../
# NOTE: we use a fake commit hash here
# we don't want Noir to rebuild everytime the parent repo changes
# just only when it changes
# the commit hash gets injected into version strings
ENV COMMIT_HASH=$(find . -type f -exec sha256sum {} ';' | sort | sha256sum | awk '{print $1}')
RUN echo $COMMIT_HASH > .content-hash
# # borrow Nix's approach to build everything in 1970
ENV SOURCE_TIMESTAMP=1
ENV SOURCE_DATE_EPOCH=1
nargo:
FROM +nargo-src
RUN ./noir-repo/.github/scripts/wasm-bindgen-install.sh
COPY ./scripts/bootstrap_native.sh ./scripts/bootstrap_native.sh
# build noir nargo & acvm, and make sure the big build and deps folders don't hit cache
RUN ./scripts/bootstrap_native.sh && rm -rf /usr/src/noir-repo/target/release/{build,deps}
SAVE ARTIFACT /usr/src/noir-repo/target/release/nargo nargo
SAVE ARTIFACT /usr/src/noir-repo/target/release/acvm acvm
SAVE IMAGE aztecprotocol/nargo
test:
FROM +nargo
COPY ./scripts/test_native.sh ./scripts/test_native.sh
COPY noir-repo/.rustfmt.toml noir-repo/.rustfmt.toml
# Some of the debugger tests are a little flaky wrt to timeouts so we allow a couple of retries.
ENV NEXTEST_RETRIES=2
RUN ./scripts/test_native.sh
examples:
FROM +nargo
ENV PATH="/usr/src/noir-repo/target/release:${PATH}"
COPY --dir noir-repo/examples noir-repo
COPY ../barretenberg/cpp/+preset-clang-assert/bin/bb /usr/src/barretenberg/cpp/build/bin/bb
ENV BACKEND=/usr/src/barretenberg/cpp/build/bin/bb
WORKDIR noir-repo/examples/codegen_verifier
RUN ./test.sh
WORKDIR ../prove_and_verify
RUN ./test.sh
WORKDIR ../recursion
RUN ./test.sh
format:
FROM +nargo
ENV PATH=$PATH:/usr/src/noir-repo/target/release
COPY ./noir-repo/test_programs ./noir-repo/test_programs
COPY ./noir-repo/noir_stdlib ./noir-repo/noir_stdlib
WORKDIR ./noir-repo/test_programs
RUN ./format.sh check
WORKDIR ../noir_stdlib
RUN nargo fmt --check
packages-deps:
BUILD ../barretenberg/ts/+build # prefetch
LOCALLY
LET packages = $(git ls-files "**/package*.json" package*.json)
LET tsconfigs = $(git ls-files "**/tsconfig*.json" tsconfig*.json)
FROM +nargo-src
COPY ../barretenberg/ts/+build/build /usr/src/barretenberg/ts
WORKDIR /usr/src/noir
COPY --dir \
./noir-repo/package.json \
./noir-repo/yarn.lock \
./noir-repo/.yarnrc.yml \
./noir-repo/.yarn \
./noir-repo
FOR file IN $packages
COPY $file $file
END
RUN cd noir-repo && yarn install --immutable && cd ../
FOR file IN $tsconfigs
COPY $file $file
END
# Relevant source (TODO finer-grained)
COPY --dir \
noir-repo/acvm-repo \
noir-repo/compiler \
noir-repo/docs \
noir-repo/noir_stdlib \
noir-repo/scripts \
noir-repo/test_programs \
noir-repo/tooling \
noir-repo/utils \
noir-repo/Cargo.lock \
noir-repo/.yarnrc.yml \
noir-repo/.yarn \
noir-repo/yarn.lock \
noir-repo/package.json \
noir-repo/LICENSE* \
noir-repo/*.toml \
noir-repo/*.json \
noir-repo/*.js \
noir-repo/.github \
noir-repo
packages:
FROM +packages-deps
COPY ./scripts/bootstrap_packages.sh ./scripts/bootstrap_packages.sh
RUN ./scripts/bootstrap_packages.sh
SAVE ARTIFACT packages
SAVE IMAGE --cache-hint
packages-test-build:
FROM +packages-deps
COPY +nargo/nargo /usr/src/noir/noir-repo/target/release/nargo
COPY +nargo/acvm /usr/src/noir/noir-repo/target/release/acvm
ENV NARGO_BACKEND_PATH=/usr/src/barretenberg/ts/dest/node/main.js
ENV PATH=$PATH:/usr/src/noir/noir-repo/target/release
WORKDIR /usr/src/barretenberg/ts
RUN yarn --immutable
WORKDIR /usr/src/noir/noir-repo
COPY --dir noir-repo/.github/scripts/wasm-bindgen-install.sh ./.github/scripts/wasm-bindgen-install.sh
RUN ./.github/scripts/wasm-bindgen-install.sh
ENV SOURCE_DATE_EPOCH=$(date +%s)
ENV GIT_DIRTY=false
ENV GIT_COMMIT=$COMMIT_HASH
RUN yarn build
# this builds text fixtures to be used in tests
RUN yarn workspace @noir-lang/noir_wasm run test:build_fixtures
SAVE ARTIFACT /usr/src /usr/src
packages-test-node:
FROM +packages-test-build
ENV NODE_OPTIONS=--max_old_space_size=8192
WORKDIR /usr/src/noir/noir-repo
RUN yarn workspaces foreach \
--parallel \
--verbose \
--exclude @noir-lang/root \ # foreach includes the root workspace, ignore it
--exclude @noir-lang/noir_js \ # noir_js OOMs
--exclude integration-tests \ # separate node and browser tests
--exclude @noir-lang/noir_wasm \
run test
RUN yarn workspaces foreach \
--parallel \
--verbose \
--include integration-tests \
--include @noir-lang/noir_wasm \
run test:node
packages-test-browser:
FROM ../build-images/+base-slim-node
COPY --dir +packages-test-build/usr/src /usr
WORKDIR /usr/src/noir/noir-repo
RUN ./.github/scripts/playwright-install.sh
RUN yarn workspaces foreach \
--verbose \
--include integration-tests \
--include @noir-lang/noir_wasm \
run test:browser
packages-test:
BUILD +packages-test-node
BUILD +packages-test-browser
build-acir-tests:
LOCALLY
# Prepare our exact dependency formula, this avoids problems with copied empty folders or build artifacts
RUN rm -rf .earthly-staging && mkdir -p .earthly-staging
RUN cp --parents $(git ls-files "noir-repo/test_programs/*.toml" "noir-repo/test_programs/*.nr" "noir-repo/test_programs/rebuild.sh") .earthly-staging
FROM ../build-images/+from-registry
COPY +nargo/ /usr/src/noir-repo/target/release
ENV PATH="/usr/src/noir-repo/target/release:${PATH}"
WORKDIR /usr/src/noir-repo/test_programs
COPY .earthly-staging/noir-repo/test_programs /usr/src/noir-repo/test_programs/
RUN /usr/src/noir-repo/target/release/nargo --version
# TODO(#6225): We have trouble with concurrency and pass 'true' to build in serial, see #6225 for details
RUN ./rebuild.sh
SAVE ARTIFACT /usr/src/noir-repo/test_programs/acir_artifacts/*
barretenberg-acir-benches-bb:
FROM ubuntu:noble
RUN apt update && \
apt install -y curl git jq unzip
COPY ../barretenberg/cpp/+preset-clang-assert/bin/bb /usr/src/barretenberg/cpp/build/bin/bb
COPY ../barretenberg/+acir-tests/ /usr/src/barretenberg/acir_tests
COPY +build-acir-tests/ /usr/src/acir_artifacts
ENV TEST_SRC=/usr/src/acir_artifacts
WORKDIR /usr/src/barretenberg/acir_tests
bench-acir-bb:
# This target is used for debugging the benchmarking target.
# For precise benchmarks in CI use `bench-publish-acir-bb`
FROM +barretenberg-acir-benches-bb
RUN ./bench_acir_tests.sh
export-bench-acir-bb:
ARG EARTHLY_GIT_HASH
FROM +barretenberg-acir-benches-bb
SAVE IMAGE aztecprotocol/barretenberg-acir-benches:$EARTHLY_GIT_HASH
bench-publish-acir-bb:
ARG PULL_REQUEST
ARG BRANCH
ARG COMMIT_HASH
LOCALLY
# Let docker compose know about the pushed tags above
ENV AZTEC_DOCKER_TAG=$(git rev-parse HEAD)
# Optimize to not cause serial behavior if image already exists
IF ! docker image ls --format '{{.Repository}}:{{.Tag}}' | grep "aztecprotocol/barretenberg-acir-benches:$AZTEC_DOCKER_TAG"
WAIT
BUILD +export-bench-acir-bb
END
END
RUN mkdir -p ./log
RUN docker run -v "$(pwd)/log":/log -e LOG_FILE=/log/bench-acir.jsonl --rm aztecprotocol/barretenberg-acir-benches:$AZTEC_DOCKER_TAG ./bench_acir_tests.sh
DO ../+UPLOAD_LOGS --PULL_REQUEST=$PULL_REQUEST --BRANCH=$BRANCH --COMMIT_HASH=$COMMIT_HASH