Skip to content

Commit

Permalink
Pack base benchmark outside yarn project altogether
Browse files Browse the repository at this point in the history
  • Loading branch information
spalladino committed May 17, 2024
1 parent 283c938 commit 2ac2189
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 28 deletions.
13 changes: 5 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,14 @@ jobs:
if: ${{ github.event_name == 'pull_request' }}
run: |
# Download the base benchmark locally (requires AWS creds and .git history)
scripts/logs/download_base_benchmark_from_s3.sh
cd yarn-project/scripts
# Package it into an earthly artifact
mkdir -p ./bench
earthly-ci -P +pack-base-benchmark
# Delete it so we don't accidentally bust the yarn-project+build cache
rm -rf ./bench
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=$BENCH_FOLDER
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' }}
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
21 changes: 1 addition & 20 deletions yarn-project/scripts/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,6 @@ bench-aggregate:
|| (echo "Not all log files from benchmark jobs found"; mkdir -p $BENCH_FOLDER)
SAVE ARTIFACT $BENCH_FOLDER bench

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.
ARG COMMIT_HASH
ARG PULL_REQUEST
ARG BRANCH
FROM scratch
LET LOCAL_BENCH_FOLDER=./bench
LET BENCH_FOLDER=/usr/var/bench
COPY $LOCAL_BENCH_FOLDER $BENCH_FOLDER
SAVE ARTIFACT $BENCH_FOLDER bench

bench-comment:
# 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.
Expand All @@ -73,7 +54,7 @@ bench-comment:
ENV PULL_REQUEST=$PULL_REQUEST
ENV PR_NUMBER=$PULL_REQUEST
ENV BRANCH=$BRANCH
COPY +pack-base-benchmark/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 \
Expand Down

0 comments on commit 2ac2189

Please sign in to comment.