Skip to content

Commit a9efaaf

Browse files
ci: add bazel integration tests
1 parent 7723cd9 commit a9efaaf

File tree

9 files changed

+47
-51
lines changed

9 files changed

+47
-51
lines changed

.github/workflows/ci.yml

Lines changed: 44 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
uses: actions/cache@v3
1818
with:
1919
path: core/build-tests
20-
key: ${{ runner.os }}-build-tests-${{ hashFiles('**/CMakeLists.txt', '**/examples/google_benchmark/**') }}
20+
key: ${{ runner.os }}-build-tests-${{ hashFiles('**/CMakeLists.txt') }}
2121

2222
- name: Create build directory
2323
run: mkdir -p core/build-tests
@@ -58,39 +58,28 @@ jobs:
5858
path: examples/google_benchmark_cmake/build
5959
key: ${{ runner.os }}-build-${{ matrix.codspeed-mode }}-${{ hashFiles('**/CMakeLists.txt', '**/examples/google_benchmark_cmake/**') }}
6060

61-
- name: Build and run benchmarks
62-
run: |
63-
bazel run //examples/google_benchmark:my_benchmark
64-
65-
instrumentation:
66-
runs-on: ubuntu-latest
67-
68-
steps:
69-
- name: Checkout code
70-
uses: actions/checkout@v3
71-
72-
- name: Cache build
73-
uses: actions/cache@v3
74-
with:
75-
path: examples/google_benchmark/build-instrumentation
76-
key: ${{ runner.os }}-build-instrumentation-${{ hashFiles('**/CMakeLists.txt', '**/examples/google_benchmark/**') }}
77-
7861
- name: Create build directory
79-
run: mkdir -p examples/google_benchmark/build-instrumentation
62+
run: mkdir -p examples/google_benchmark_cmake/build
8063

81-
- name: Build instrumentation benchmark example
64+
- name: Build benchmark example
8265
run: |
83-
cd examples/google_benchmark/build-instrumentation
84-
cmake -DCODSPEED_MODE=instrumentation ..
66+
cd examples/google_benchmark_cmake/build
67+
cmake -DCODSPEED_MODE=${{ matrix.codspeed-mode }} ..
8568
make -j
8669
8770
- name: Run the benchmarks
8871
uses: CodSpeedHQ/action@main
72+
if: matrix.codspeed-mode != 'off'
8973
with:
90-
run: examples/google_benchmark/build-instrumentation/benchmark_example
74+
run: examples/google_benchmark_cmake/build/benchmark_example
9175
token: ${{ secrets.CODSPEED_TOKEN }}
9276

93-
walltime:
77+
# This cannot be part of the same matrix because it needs a different runner
78+
cmake-integration-tests-walltime:
79+
strategy:
80+
matrix:
81+
codspeed-mode:
82+
- "walltime"
9483
runs-on: codspeed-macro
9584

9685
steps:
@@ -100,43 +89,47 @@ jobs:
10089
- name: Cache build
10190
uses: actions/cache@v3
10291
with:
103-
path: examples/google_benchmark/build-walltime
104-
key: ${{ runner.os }}-build-walltime-${{ hashFiles('**/CMakeLists.txt', '**/examples/google_benchmark/**') }}
92+
path: examples/google_benchmark_cmake/build
93+
key: ${{ runner.os }}-build-${{ matrix.codspeed-mode }}-${{ hashFiles('**/CMakeLists.txt', '**/examples/google_benchmark_cmake/**') }}
10594

10695
- name: Create build directory
107-
run: mkdir -p examples/google_benchmark/build-walltime
96+
run: mkdir -p examples/google_benchmark_cmake/build
10897

109-
- name: Build walltime benchmark example
98+
- name: Build benchmark example
11099
run: |
111-
cd examples/google_benchmark/build-walltime
112-
cmake -DCODSPEED_MODE=walltime ..
100+
cd examples/google_benchmark_cmake/build
101+
cmake -DCODSPEED_MODE=${{ matrix.codspeed-mode }} ..
113102
make -j
114103
115104
- name: Run the benchmarks
116105
uses: CodSpeedHQ/action@main
106+
if: matrix.codspeed-mode != 'off'
117107
with:
118-
run: examples/google_benchmark/build-walltime/benchmark_example
108+
run: examples/google_benchmark_cmake/build/benchmark_example
119109
token: ${{ secrets.CODSPEED_TOKEN }}
120-
121-
122-
build-no-codspeed:
110+
111+
112+
bazel-integration-tests:
123113
runs-on: ubuntu-latest
124-
114+
strategy:
115+
matrix:
116+
codspeed-mode:
117+
- "instrumentation"
118+
- "off"
125119
steps:
126-
- name: Checkout code
127-
uses: actions/checkout@v3
128-
129-
- name: Cache build
130-
uses: actions/cache@v3
131-
with:
132-
path: examples/google_benchmark/build-no-codspeed
133-
key: ${{ runner.os }}-build-no-codspeed-${{ hashFiles('**/CMakeLists.txt', '**/examples/google_benchmark/**') }}
134-
135-
- name: Create build directory
136-
run: mkdir -p examples/google_benchmark/build-no-codspeed
120+
- uses: actions/checkout@v4
121+
122+
- name: Set up Bazel
123+
uses: bazel-contrib/setup-bazel@0.14.0
124+
with:
125+
# Avoid downloading Bazel every time.
126+
bazelisk-cache: true
127+
# Store build cache per workflow.
128+
disk-cache: ${{ github.workflow }}
129+
# Share repository cache between workflows.
130+
repository-cache: true
137131

138-
- name: Build benchmark example without codspeed
139-
run: |
140-
cd examples/google_benchmark/build-no-codspeed
141-
cmake ..
142-
make -j
132+
- name: Build and run benchmarks
133+
run: |
134+
bazel run //examples/google_benchmark_bazel:my_benchmark --//core:codspeed_mode=${{ matrix.codspeed-mode }}
135+
File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../google_benchmark_cmake/fixture_bench.hpp
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../google_benchmark_cmake/main.cpp
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../google_benchmark_cmake/template_bench.hpp
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)