Skip to content

Commit 407b6cc

Browse files
committed
ci: update build to run benchmarks
1 parent 2b47f62 commit 407b6cc

File tree

1 file changed

+114
-0
lines changed

1 file changed

+114
-0
lines changed

.github/workflows/build.yml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: Build & Test
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
ref:
7+
default: ${{ github.ref }}
8+
type: string
9+
10+
jobs:
11+
build:
12+
name: ${{ matrix.platform }} (${{ matrix.target }}) (${{ matrix.os }})
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
platform:
18+
- linux-x64
19+
- macos-arm64
20+
- macos-x64
21+
#- windows-x64
22+
23+
include:
24+
- platform: linux-x64
25+
os: ubuntu-22.04
26+
- platform: macos-arm64
27+
os: macos-14
28+
- platform: macos-x64
29+
os: macos-13
30+
#- platform: windows-x64
31+
# os: windows-2022
32+
33+
steps:
34+
- name: Checkout source code
35+
uses: actions/checkout@v4
36+
with:
37+
ref: ${{ inputs.ref }}
38+
39+
- name: Install Rust
40+
uses: dtolnay/rust-toolchain@master
41+
with:
42+
components: 'llvm-tools-preview'
43+
toolchain: stable
44+
45+
- name: Install grcov
46+
uses: taiki-e/install-action@main
47+
with:
48+
tool: grcov
49+
50+
- name: Enable caching
51+
uses: Swatinem/rust-cache@v2
52+
53+
- name: Tests
54+
env:
55+
CARGO_TERM_COLOR: always
56+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
57+
LLVM_PROFILE_FILE: postgresql-%p-%m.profraw
58+
RUST_LOG: "info,postgresql_archive=debug,postgresql_embedded=debug"
59+
RUST_LOG_SPAN_EVENTS: full
60+
RUSTFLAGS: -Cinstrument-coverage
61+
RUSTDOCFLAGS: -Cinstrument-coverage
62+
run: |
63+
cargo test --workspace --all-features
64+
65+
- name: Produce coverage info
66+
if: ${{ startsWith(matrix.os, 'ubuntu-') }}
67+
run: |
68+
grcov $(find . -name "postgresql-*.profraw" -print) \
69+
-s . \
70+
--branch \
71+
--ignore-not-existing \
72+
--ignore='target/*' \
73+
--ignore='benches/*' \
74+
--ignore='/*' \
75+
--binary-path ./target/debug/ \
76+
--excl-line='#\[derive' \
77+
-t lcov \
78+
-o lcov.info
79+
80+
- name: Upload to codecov.io
81+
if: ${{ startsWith(matrix.os, 'ubuntu-') }}
82+
uses: codecov/codecov-action@v3
83+
with:
84+
files: lcov.info
85+
fail_ci_if_error: true
86+
87+
- name: Install benchmarking tools
88+
if: ${{ startsWith(matrix.os, 'ubuntu-') }}
89+
uses: bencherdev/bencher@main
90+
91+
- name: Run benchmarks
92+
if: ${{ startsWith(matrix.os, 'ubuntu-') }}
93+
env:
94+
BENCHER_PROJECT: theseus-rs-postgresql-embedded
95+
BENCHER_ADAPTER: rust_criterion
96+
run: |
97+
cargo bench --bench archive --features blocking -- --output-format criterion | \
98+
bencher run
99+
--if-branch '${{ env.PR_HEAD }}' \
100+
--else-if-branch '${{ env.PR_BASE }}' \
101+
--else-if-branch '${{ env.PR_DEFAULT }}' \
102+
--ci-number '${{ env.PR_NUMBER }}' \
103+
--github-actions "${{ secrets.GITHUB_TOKEN }}" \
104+
--token "${{ secrets.BENCHER_API_TOKEN }}" \
105+
--err
106+
cargo bench --bench embedded --features blocking -- --output-format criterion | \
107+
bencher run
108+
--if-branch '${{ env.PR_HEAD }}' \
109+
--else-if-branch '${{ env.PR_BASE }}' \
110+
--else-if-branch '${{ env.PR_DEFAULT }}' \
111+
--ci-number '${{ env.PR_NUMBER }}' \
112+
--github-actions "${{ secrets.GITHUB_TOKEN }}" \
113+
--token "${{ secrets.BENCHER_API_TOKEN }}" \
114+
--err

0 commit comments

Comments
 (0)