Skip to content

Commit

Permalink
Only benchmark master on push
Browse files Browse the repository at this point in the history
  • Loading branch information
epompeii committed Dec 6, 2023
1 parent 9dce159 commit 9e6c6ff
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/benches.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
on:
push:
branches: master
pull_request_target:

name: Benchmarks

jobs:
benchmarks:
if: contains(github.event.pull_request.labels.*.name, 'run-benchmarks')
if: (github.event_name == 'push' && github.ref == 'refs/heads/master') || (github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'run-benchmarks'))
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down Expand Up @@ -52,30 +54,33 @@ jobs:
uses: bencherdev/bencher@main

- name: Benchmark master
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
env:
BENCHER_BRANCH: master
BENCHER_TESTBED: ubuntu-latest-${{ matrix.backend }}
run: |
bencher run \
--token "${{ secrets.BENCHER_API_TOKEN }}" \
'cargo +stable bench --manifest-path diesel_bench/Cargo.toml --no-default-features --features "${{matrix.backend}}"'
--token '${{ secrets.BENCHER_API_TOKEN }}' \
'cargo +stable bench --manifest-path diesel_bench/Cargo.toml --no-default-features --features "${{ matrix.backend }}"'
- name: Checkout PR sources
if: github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'run-benchmarks')
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
persist-credentials: false

- name: Benchmark PR ${{ github.event.pull_request.number }}
if: github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'run-benchmarks')
env:
BENCHER_TESTBED: ubuntu-latest-${{ matrix.backend }}
run: |
bencher run \
--if-branch "${{ github.event.pull_request.head.ref }}" \
--else-if-branch "${{ github.event.pull_request.base.ref }}" \
--if-branch "$GITHUB_REF_NAME" \
--else-if-branch "$GITHUB_BASE_REF" \
--else-if-branch master \
--err \
--github-actions "${{ secrets.GITHUB_TOKEN }}" \
--token "${{ secrets.BENCHER_API_TOKEN }}" \
'cargo +stable bench --manifest-path diesel_bench/Cargo.toml --no-default-features --features "${{matrix.backend}}"'
'cargo +stable bench --manifest-path diesel_bench/Cargo.toml --no-default-features --features "${{ matrix.backend }}"'

0 comments on commit 9e6c6ff

Please sign in to comment.