napi-rs/.github/workflows/bench.yaml
2022-04-01 14:33:34 +08:00

82 lines
1.8 KiB
YAML

name: Benchmark
env:
DEBUG: 'napi:*'
on:
push:
branches:
- main
pull_request:
jobs:
bench:
name: Bench
if: "!contains(github.event.head_commit.message, 'bump')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
check-latest: true
cache: 'yarn'
- name: Install
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: default
override: true
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
key: bench-cargo-cache
- name: Cache NPM dependencies
uses: actions/cache@v3
with:
path: .yarn/cache
key: bench-yarn-cache
- name: 'Install dependencies'
run: yarn install --immutable --mode=skip-build
- name: 'Build ts'
run: yarn build
- name: 'Build bench'
run: yarn build:bench
- name: 'Run benchmark'
run: yarn bench
- name: Store benchmark result
uses: rhysd/github-action-benchmark@v1
if: github.ref == 'refs/heads/main'
with:
tool: 'benchmarkjs'
output-file-path: bench.txt
github-token: ${{ secrets.GH_TOKEN }}
auto-push: true
- name: Store benchmark result
uses: rhysd/github-action-benchmark@v1
if: github.ref != 'refs/heads/main'
with:
tool: 'benchmarkjs'
output-file-path: bench.txt
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-always: true
- name: Clear the cargo caches
run: |
cargo install cargo-cache --no-default-features --features ci-autoclean
cargo-cache