From 65ce6f5f8c310348baf54876b4875bdce22fd47b Mon Sep 17 00:00:00 2001 From: Tomi Jaga Date: Fri, 23 May 2025 20:03:54 -0700 Subject: [PATCH] Update github actions packages to v4 --- .github/workflows/benchmarks.yml | 90 +++++++++++++++++++++++--------- .github/workflows/makefile.yml | 18 ++----- 2 files changed, 71 insertions(+), 37 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index d9c6555..f8fbdc7 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -1,6 +1,9 @@ -name: Comment Benchmarks +name: Benchmarks on: + push: + branches: + - main pull_request: branches: - "*" @@ -11,14 +14,12 @@ jobs: name: Run Benchmarks and Comment steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: 18 - + node-version: "20" - name: Cache Node modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} @@ -26,12 +27,11 @@ jobs: ${{ runner.os }}-node- - name: Cache mops packages - uses: actions/cache@v3 + uses: actions/cache@v4 with: key: mops-packages-${{ hashFiles('mops.toml') }} path: | ~/.cache/mops - ~/mops - name: Install dfx uses: dfinity/setup-dfx@main @@ -51,25 +51,67 @@ jobs: # set moc path for dfx to use echo "DFX_MOC_PATH=$(mops toolchain bin moc)" >> $GITHUB_ENV + - name: Create benchmark-results branch if it doesn't exist + uses: peterjgrainger/action-create-branch@v2.2.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + branch: "benchmark-results" + sha: "${{ github.event.pull_request.head.sha }}" + continue-on-error: true + + - name: Checkout out the branch with benchmark results + if: github.event_name == 'pull_request' + uses: actions/checkout@v4 + with: + ref: benchmark-results + path: .benchmark-results-branch/ + - name: Move Saved Benchmarks + if: github.event_name == 'pull_request' + run: mv .benchmark-results-branch/.bench .bench 2>/dev/null || mkdir -p .bench + - name: Benchmarks + if: github.event_name == 'pull_request' id: benchmarks run: | - mops bench --gc incremental 2>&1 | tee benchmark_results.txt - - # Process the output to remove everything up to the last occurrence of \033[2K - awk '/\x1b\[2K/ { buffer = "" } { buffer = buffer $0 "\n" } END { print buffer }' benchmark_results.txt > intermediate_results.txt - sed 's/\x1b\[[0-9;]*[a-zA-Z]//g' intermediate_results.txt > processed_results.txt + mops bench --gc incremental --compare 2>&1 | tee benchmark_results.txt + echo "result<> $GITHUB_OUTPUT + cat benchmark_results.txt >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT - # Set the processed output as an environment variable - echo "BENCHMARK_OUTPUT<> $GITHUB_ENV - cat processed_results.txt >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV + - name: Find Benchmark Comment + if: github.event_name == 'pull_request' + uses: peter-evans/find-comment@v3 + id: fc + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: "github-actions[bot]" + body-includes: Benchmark Results - - name: Comment PR + - name: Create or update comment if: github.event_name == 'pull_request' - uses: unsplash/comment-on-pr@v1.3.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: peter-evans/create-or-update-comment@v4 + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + body: ${{ steps.benchmarks.outputs.result }} + edit-mode: replace + + - name: Generate Benchmark Results + if: github.event_name != 'pull_request' + run: | + set -o pipefail + mops bench --gc incremental --save 2>&1 + - name: Move Generated Results + if: github.event_name != 'pull_request' + run: | + mkdir .bench-br + mv .bench .bench-br/.bench + mv bench-results.md .bench-br/README.md + - name: Upload benchmark results + if: github.event_name != 'pull_request' + uses: JamesIves/github-pages-deploy-action@v4 with: - msg: "# Benchmark Results\n\n${{ env.BENCHMARK_OUTPUT }}\n" - check_for_duplicate_msg: false + token: ${{ secrets.GITHUB_TOKEN }} + branch: benchmark-results + folder: .bench-br diff --git a/.github/workflows/makefile.yml b/.github/workflows/makefile.yml index 529e31a..53ee6f4 100644 --- a/.github/workflows/makefile.yml +++ b/.github/workflows/makefile.yml @@ -14,27 +14,18 @@ jobs: name: Build and test steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: 18 - + node-version: "20" - name: Cache Node modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-node- - - name: Cache mops packages - uses: actions/cache@v3 - with: - key: mops-packages-${{ hashFiles('mops.toml') }} - path: | - ~/.cache/mops - ~/mops - - name: Install dfx uses: dfinity/setup-dfx@main - name: Confirm successful installation @@ -49,6 +40,7 @@ jobs: mops i mops toolchain init mops toolchain use moc latest + mops toolchain use wasmtime 14.0.4 # set moc path for dfx to use echo "DFX_MOC_PATH=$(mops toolchain bin moc)" >> $GITHUB_ENV