From 797115b82ae595be16d8ad887a0c310e7b53afa4 Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Tue, 21 May 2024 10:49:20 -0300 Subject: [PATCH] chore: Do not rebuild yarn-projects on bench-comment (#6396) 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. --- .github/workflows/ci.yml | 24 +++++++++++++++++++----- scripts/logs/Earthfile | 19 +++++++++++++++++++ yarn-project/scripts/Earthfile | 13 ++++--------- 3 files changed, 42 insertions(+), 14 deletions(-) create mode 100644 scripts/logs/Earthfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b4db3a4d53..26f0d0c093e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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) diff --git a/scripts/logs/Earthfile b/scripts/logs/Earthfile new file mode 100644 index 00000000000..1e073bcad37 --- /dev/null +++ b/scripts/logs/Earthfile @@ -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 diff --git a/yarn-project/scripts/Earthfile b/yarn-project/scripts/Earthfile index 5f26109d9ad..d648de1a782 100644 --- a/yarn-project/scripts/Earthfile +++ b/yarn-project/scripts/Earthfile @@ -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 @@ -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 @@ -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 ] \