name: Benchmark on: pull_request: paths: - 'crates/oxc_parser/**' - 'crates/oxc_ast/**' - 'tasks/coverage/**' - 'Cargo.toml' - 'Cargo.lock' - 'rust-toolchain.toml' - '!**/*.md' permissions: pull-requests: write # For comment # cancel previous job runs for the same workflow + pr concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true env: RUST_LOG: info RUST_BACKTRACE: 1 CARGO_INCREMENTAL: 0 jobs: benchmark: name: Run benchmark strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] runs-on: ${{ matrix.os }} steps: - name: Checkout uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.sha }} submodules: false - name: Install toolchain run: rustup show - name: Cache uses: Swatinem/rust-cache@v2 with: shared-key: benchmark - name: Install critcmp run: cargo install critcmp - name: Compile run: cargo build --release -p oxc_benchmark - name: Run Bench on PR Branch run: cargo benchmark --save-baseline pr - name: Checkout Main Branch uses: actions/checkout@v3 with: clean: false ref: main - name: Compile run: cargo build --release -p oxc_benchmark - name: Run Bench on Main Branch run: cargo benchmark --save-baseline main - name: Compare Bench Results id: bench_comparison shell: bash run: | echo "### Parser Benchmark Results - ${{ matrix.os }}" > output.md echo "\`\`\`" >> output.md critcmp main pr >> output.md echo "\`\`\`" >> output.md cat output.md - name: Find Comment # Check if the event is not triggered by a fork if: github.event.pull_request.head.repo.full_name == github.repository uses: peter-evans/find-comment@v2 id: fc with: issue-number: ${{ github.event.pull_request.number }} comment-author: 'github-actions[bot]' body-includes: Parser Benchmark Results - ${{ matrix.os }} - name: Write a new comment # Check if the event is not triggered by a fork if: github.event.pull_request.head.repo.full_name == github.repository uses: peter-evans/create-or-update-comment@v2 with: issue-number: ${{ github.event.pull_request.number }} edit-mode: replace comment-id: ${{ steps.fc.outputs.comment-id }} body-file: 'output.md' - name: Remove Criterion Artifact uses: JesseTG/rm@v1.0.3 with: path: ./target/criterion