clap/.github/workflows/benchmark.yml
2021-04-13 22:49:19 +01:00

66 lines
2 KiB
YAML

name: Benchmark
on:
pull_request:
branches: [master]
types: [opened, reopened, synchronize]
jobs:
prepare:
name: Prepare
runs-on: ubuntu-latest
steps:
- uses: styfle/cancel-workflow-action@0.9.0
with:
access_token: ${{ github.token }}
benchmark:
name: Benchmark
needs: [prepare]
runs-on: ubuntu-latest
steps:
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Checkout base
uses: actions/checkout@v2
with:
ref: master
- name: Ready cache
run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/
- name: Cache cargo
uses: actions/cache@v1
id: cache
with:
path: ~/.cargo
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
- name: Bench base
run: cargo bench -- --output-format bencher | tee output.txt
- name: Save base benchmark
uses: pksunkara/github-action-benchmark@v1
with:
tool: cargo
output-file-path: output.txt
external-data-json-path: ./benchmark-data.json
read-commit-id: true
- name: Checkout pull request
uses: actions/checkout@v2
with:
clean: false
- name: Bench pull request
run: cargo bench -- --output-format bencher | tee output.txt
- name: Compare benchmarks
uses: pksunkara/github-action-benchmark@v2
with:
tool: cargo
output-file-path: output.txt
external-data-json-path: ./benchmark-data.json
github-token: ${{ github.token }}
annotate-always: true
- name: Install cargo-cache
uses: actions-rs/install@v0.1
if: steps.cache.outputs.cache-hit != 'true'
with:
crate: cargo-cache
use-tool-cache: true
- name: Cleanup cache
if: steps.cache.outputs.cache-hit != 'true'
run: cargo cache -a