Skip to content

Commit

Permalink
chore: Do not rebuild yarn-projects on bench-comment (AztecProtocol#6396
Browse files Browse the repository at this point in the history
)

The bench-comment job was re-running bootstrap.sh on yarn-project (see
[here](https://github.com/AztecProtocol/aztec-packages/actions/runs/9081368520/job/24957398753?pr=6211#step:7:314),
most likely because the "Download base benchmark" step on ci.yml was
downloading a new file to `yarn-projects`, which caused the `COPY . .`
in yarn project build to miss cache.

This downloads the bench files outside the source folder, so it doesn't
trigger a rebuild.
  • Loading branch information
spalladino authored May 21, 2024
1 parent 9321aef commit 797115b
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 14 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,33 @@ jobs:
concurrency_key: build-x86
- name: "Build and upload bench aggregate file"
working-directory: ./yarn-project/scripts
run: earthly-ci -P --secret AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} --secret AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} +bench-aggregate
- name: "Download base benchmark"
run: |
earthly-ci -P \
--secret AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} \
--secret AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} \
+bench-aggregate
- name: "Download base benchmark and package into earthly"
if: ${{ github.event_name == 'pull_request' }}
run: scripts/logs/download_base_benchmark_from_s3.sh
run: |
# Download the base benchmark locally (requires AWS creds and .git history)
mkdir -p $BENCH_FOLDER
./scripts/logs/download_base_benchmark_from_s3.sh
# Package it into an earthly artifact to read from bench-comment
earthly-ci -P ./scripts/logs+pack-base-benchmark --LOCAL_BENCH_FOLDER=./tmp/bench
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
BENCH_FOLDER: ./yarn-project/scripts/bench
BENCH_FOLDER: "./scripts/logs/tmp/bench"
PULL_REQUEST: "${{ github.event.pull_request.number }}"
- name: "Generate summary comment if pull request"
if: ${{ github.event_name == 'pull_request' }}
working-directory: ./yarn-project/scripts
run: earthly-ci -P --secret AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} --secret AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} --secret AZTEC_BOT_COMMENTER_GITHUB_TOKEN=${{ secrets.AZTEC_BOT_GITHUB_TOKEN }} +bench-comment
run: |
earthly-ci -P \
--secret AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} \
--secret AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} \
--secret AZTEC_BOT_COMMENTER_GITHUB_TOKEN=${{ secrets.AZTEC_BOT_GITHUB_TOKEN }} \
+bench-comment
# barretenberg (prover) native and AVM (public VM) tests
# only ran on x86 for resource reasons (memory intensive)
Expand Down
19 changes: 19 additions & 0 deletions scripts/logs/Earthfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
VERSION 0.8
FROM node:18.19.0

pack-base-benchmark:
# Copies the base benchmark (ie the master run) into a container and packs it as an artifact,
# so it can be consumed from bench-comment. Note that we need to download base-benchmark
# outside of this target beforehand. We cannot run it within an Earthly container because it needs
# access to the .git folder, and we cannot run it with a LOCALLY statement because Earthly does
# not support secrets when running locally (and we need) the AWS access keys to access S3.
# We also cannot COPY the local file directly from bench-comment, since the file must be present
# within the build context so we can copy it (ie within yarn-project/scripts), and that invalidates
# the cache of yarn-project+build since it does a `COPY . .`, and we cannot add the bench file to
# earthlyignore or we would not be able to copy it from anywhere. So we need to place this target
# outside yarn-project altogether, since that folder should not be modified.
ARG LOCAL_BENCH_FOLDER
FROM scratch
LET BENCH_FOLDER=/usr/var/bench
COPY $LOCAL_BENCH_FOLDER $BENCH_FOLDER
SAVE ARTIFACT $BENCH_FOLDER bench
13 changes: 4 additions & 9 deletions yarn-project/scripts/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ download-logs:
ARG BRANCH
FROM +build
LET LOG_FOLDER=/usr/var/logs
LET BENCH_FOLDER=/usr/var/bench
ENV LOG_FOLDER=$LOG_FOLDER
ENV BENCH_FOLDER=$BENCH_FOLDER
ENV COMMIT_HASH=$COMMIT_HASH
ENV PULL_REQUEST=$PULL_REQUEST
ENV BRANCH=$BRANCH
Expand Down Expand Up @@ -44,11 +42,8 @@ bench-aggregate:
SAVE ARTIFACT $BENCH_FOLDER bench

bench-comment:
# Use the scripts image to run bench comment after loading the benchmark from bench-aggregate.
# Requires base-benchmark to be downloaded outside of this target. Note we cannot run it within
# an Earthly container because it needs access to the .git folder, and we cannot run it with a
# LOCALLY statement because Earthly does not support secrets when running locally (and we need)
# the AWS access keys to access S3. This step is then manually run in the ci.yml.
# Use the scripts image to run bench comment after loading the benchmark from bench-aggregate
# and the base benchmark (ie the benches from master to compare to) from pack-base-benchmark.
ARG COMMIT_HASH
ARG PULL_REQUEST
ARG BRANCH
Expand All @@ -59,8 +54,8 @@ bench-comment:
ENV PULL_REQUEST=$PULL_REQUEST
ENV PR_NUMBER=$PULL_REQUEST
ENV BRANCH=$BRANCH
COPY ./bench $BENCH_FOLDER/
COPY +bench-aggregate/bench $BENCH_FOLDER
COPY ../../scripts/logs+pack-base-benchmark/bench $BENCH_FOLDER/
COPY +bench-aggregate/bench $BENCH_FOLDER/
RUN echo "Bench folder contents $(ls $BENCH_FOLDER)"
RUN --secret AZTEC_BOT_COMMENTER_GITHUB_TOKEN \
[ -f $BENCH_FOLDER/benchmark.json ] \
Expand Down

0 comments on commit 797115b

Please sign in to comment.