diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3d0c7a3f305..45b15c30816 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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' }} 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 e63227cc321..dc8d34361b4 100644 --- a/yarn-project/scripts/Earthfile +++ b/yarn-project/scripts/Earthfile @@ -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. @@ -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 \