Skip to content

Commit 84fb260

Browse files
committed
refactor: refactor the way benchmarks run on the main branch vs a PR
1 parent 7aec4b3 commit 84fb260

File tree

2 files changed

+51
-13
lines changed

2 files changed

+51
-13
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ on:
1010

1111
permissions:
1212
contents: read
13-
pull-requests: write
1413

1514
jobs:
1615
checks:
@@ -93,23 +92,15 @@ jobs:
9392
fail_ci_if_error: true
9493

9594
- name: Install benchmarking tools
96-
if: ${{ startsWith(matrix.os, 'ubuntu-') }}
95+
if: ${{ github.ref == 'refs/heads/main' && startsWith(matrix.os, 'ubuntu-') }}
9796
uses: bencherdev/bencher@main
9897

9998
- name: Run benchmarks
100-
if: ${{ startsWith(matrix.os, 'ubuntu-') }}
99+
if: ${{ github.ref == 'refs/heads/main' && startsWith(matrix.os, 'ubuntu-') }}
101100
env:
102101
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
103102
BENCHER_PROJECT: theseus-rs-postgresql-embedded
104103
BENCHER_ADAPTER: rust_criterion
105104
run: |
106-
cargo bench --bench archive --features blocking -- --output-format criterion | \
107-
bencher run \
108-
--ci-number "${{ github.event.number }}" \
109-
--github-actions "${{ secrets.GITHUB_TOKEN }}" \
110-
--err
111-
cargo bench --bench embedded --features blocking -- --output-format criterion | \
112-
bencher run \
113-
--ci-number "${{ github.event.number }}" \
114-
--github-actions "${{ secrets.GITHUB_TOKEN }}" \
115-
--err
105+
cargo bench --bench archive --features blocking -- --output-format criterion | bencher run
106+
cargo bench --bench embedded --features blocking -- --output-format criterion | bencher run
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Run and Cache Benchmarks
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize]
6+
7+
permissions:
8+
pull-requests: write
9+
10+
jobs:
11+
benchmark:
12+
name: Run Benchmarks
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout source code
16+
uses: actions/checkout@v4
17+
18+
- name: Install Rust
19+
uses: dtolnay/rust-toolchain@master
20+
with:
21+
components: 'llvm-tools-preview'
22+
toolchain: stable
23+
24+
- name: Enable caching
25+
uses: Swatinem/rust-cache@v2
26+
27+
- name: Install benchmarking tools
28+
if: ${{ startsWith(matrix.os, 'ubuntu-') }}
29+
uses: bencherdev/bencher@main
30+
31+
- name: Run benchmarks
32+
if: ${{ startsWith(matrix.os, 'ubuntu-') }}
33+
env:
34+
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
35+
BENCHER_PROJECT: theseus-rs-postgresql-embedded
36+
BENCHER_ADAPTER: rust_criterion
37+
run: |
38+
cargo bench --bench archive --features blocking -- --output-format criterion | \
39+
bencher run \
40+
--ci-number "${{ github.event.number }}" \
41+
--github-actions "${{ secrets.GITHUB_TOKEN }}" \
42+
--err
43+
cargo bench --bench embedded --features blocking -- --output-format criterion | \
44+
bencher run \
45+
--ci-number "${{ github.event.number }}" \
46+
--github-actions "${{ secrets.GITHUB_TOKEN }}" \
47+
--err

0 commit comments

Comments
 (0)