name: Benchmark on: pull_request: branches: [master] types: [opened, reopened, synchronize] jobs: Benchmark: 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 -- -R 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 -- -R 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