Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 66 additions & 24 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Comment Benchmarks
name: Benchmarks

on:
push:
branches:
- main
pull_request:
branches:
- "*"
Expand All @@ -11,27 +14,24 @@ 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') }}
restore-keys: |
${{ 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
Expand All @@ -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<<EOF" >> $GITHUB_OUTPUT
cat benchmark_results.txt >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

# Set the processed output as an environment variable
echo "BENCHMARK_OUTPUT<<EOF" >> $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
18 changes: 5 additions & 13 deletions .github/workflows/makefile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading