Skip to content

Commit 9c8e94d

Browse files
ci: add bazel integration tests
1 parent 72fde24 commit 9c8e94d

File tree

9 files changed

+91
-117
lines changed

9 files changed

+91
-117
lines changed

.github/workflows/ci.yml

Lines changed: 88 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -10,133 +10,104 @@ jobs:
1010
tests:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- name: Checkout code
14-
uses: actions/checkout@v3
13+
- name: Checkout code
14+
uses: actions/checkout@v3
1515

16-
- name: Cache build
17-
uses: actions/cache@v3
18-
with:
19-
path: core/build-tests
20-
key: ${{ runner.os }}-build-tests-${{ hashFiles('**/CMakeLists.txt', '**/examples/google_benchmark/**') }}
16+
- name: Cache build
17+
uses: actions/cache@v3
18+
with:
19+
path: core/build-tests
20+
key: ${{ runner.os }}-build-tests-${{ hashFiles('**/CMakeLists.txt') }}
2121

22-
- name: Create build directory
23-
run: mkdir -p core/build-tests
22+
- name: Create build directory
23+
run: mkdir -p core/build-tests
2424

25-
- name: Build tests
26-
run: |
27-
cd core/build-tests
28-
cmake .. -DENABLE_TESTS=ON
29-
make -j
30-
31-
- name: Run tests
32-
run: |
33-
cd core/build-tests
34-
GTEST_OUTPUT=json:test-results/ ctest
35-
36-
- name: Upload test results
37-
uses: actions/upload-artifact@v4
38-
if: failure()
39-
with:
40-
name: test_results
41-
path: ${{runner.workspace}}/core/build-tests/test/test-results/**/*.json
25+
- name: Build tests
26+
run: |
27+
cd core/build-tests
28+
cmake .. -DENABLE_TESTS=ON
29+
make -j
30+
31+
- name: Run tests
32+
run: |
33+
cd core/build-tests
34+
GTEST_OUTPUT=json:test-results/ ctest
35+
36+
- name: Upload test results
37+
uses: actions/upload-artifact@v4
38+
if: failure()
39+
with:
40+
name: test_results
41+
path: ${{runner.workspace}}/core/build-tests/test/test-results/**/*.json
4242

4343
cmake-integration-tests:
4444
strategy:
4545
matrix:
46-
codspeed-mode:
47-
- "instrumentation"
48-
- "off"
49-
runs-on: ubuntu-latest
50-
46+
include:
47+
- codspeed-mode: "instrumentation"
48+
runner: "ubuntu-latest"
49+
- codspeed-mode: "walltime"
50+
runner: "codspeed-macro"
51+
- codspeed-mode: "off"
52+
runner: "ubuntu-latest"
53+
runs-on: ${{ matrix.runner }}
5154
steps:
52-
- name: Checkout code
53-
uses: actions/checkout@v3
55+
- name: Checkout code
56+
uses: actions/checkout@v3
5457

55-
- name: Cache build
56-
uses: actions/cache@v3
57-
with:
58-
path: examples/google_benchmark_cmake/build
59-
key: ${{ runner.os }}-build-${{ matrix.codspeed-mode }}-${{ hashFiles('**/CMakeLists.txt', '**/examples/google_benchmark_cmake/**') }}
58+
- name: Cache build
59+
uses: actions/cache@v3
60+
with:
61+
path: examples/google_benchmark_cmake/build
62+
key: ${{ runner.os }}-build-${{ matrix.codspeed-mode }}-${{ hashFiles('**/CMakeLists.txt', '**/examples/google_benchmark_cmake/**') }}
6063

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-
78-
- name: Create build directory
79-
run: mkdir -p examples/google_benchmark/build-instrumentation
80-
81-
- name: Build instrumentation benchmark example
82-
run: |
83-
cd examples/google_benchmark/build-instrumentation
84-
cmake -DCODSPEED_MODE=instrumentation ..
85-
make -j
86-
87-
- name: Run the benchmarks
88-
uses: CodSpeedHQ/action@main
89-
with:
90-
run: examples/google_benchmark/build-instrumentation/benchmark_example
91-
token: ${{ secrets.CODSPEED_TOKEN }}
92-
93-
walltime:
94-
runs-on: codspeed-macro
95-
96-
steps:
97-
- name: Checkout code
98-
uses: actions/checkout@v3
99-
100-
- name: Cache build
101-
uses: actions/cache@v3
102-
with:
103-
path: examples/google_benchmark/build-walltime
104-
key: ${{ runner.os }}-build-walltime-${{ hashFiles('**/CMakeLists.txt', '**/examples/google_benchmark/**') }}
105-
106-
- name: Create build directory
107-
run: mkdir -p examples/google_benchmark/build-walltime
108-
109-
- name: Build walltime benchmark example
110-
run: |
111-
cd examples/google_benchmark/build-walltime
112-
cmake -DCODSPEED_MODE=walltime ..
113-
make -j
114-
115-
- name: Run the benchmarks
116-
uses: CodSpeedHQ/action@main
117-
with:
118-
run: examples/google_benchmark/build-walltime/benchmark_example
119-
token: ${{ secrets.CODSPEED_TOKEN }}
120-
121-
122-
build-no-codspeed:
123-
runs-on: ubuntu-latest
64+
- name: Create build directory
65+
run: mkdir -p examples/google_benchmark_cmake/build
12466

67+
- name: Build benchmark example
68+
run: |
69+
cd examples/google_benchmark_cmake/build
70+
cmake -DCODSPEED_MODE=${{ matrix.codspeed-mode }} ..
71+
make -j
72+
73+
- name: Run the benchmarks
74+
uses: CodSpeedHQ/action@main
75+
if: matrix.codspeed-mode != 'off'
76+
with:
77+
run: examples/google_benchmark_cmake/build/benchmark_example
78+
token: ${{ secrets.CODSPEED_TOKEN }}
79+
80+
bazel-integration-tests:
81+
strategy:
82+
matrix:
83+
include:
84+
- codspeed-mode: "instrumentation"
85+
runner: "ubuntu-latest"
86+
- codspeed-mode: "walltime"
87+
runner: "codspeed-macro"
88+
- codspeed-mode: "off"
89+
runner: "ubuntu-latest"
90+
runs-on: ${{ matrix.runner }}
12591
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/**') }}
92+
- uses: actions/checkout@v4
93+
94+
- name: Set up Bazel
95+
uses: bazel-contrib/setup-bazel@0.14.0
96+
with:
97+
# Avoid downloading Bazel every time.
98+
bazelisk-cache: true
99+
# Store build cache per workflow.
100+
disk-cache: ${{ github.workflow }}
101+
# Share repository cache between workflows.
102+
repository-cache: true
134103

135-
- name: Create build directory
136-
run: mkdir -p examples/google_benchmark/build-no-codspeed
137-
138-
- name: Build benchmark example without codspeed
139-
run: |
140-
cd examples/google_benchmark/build-no-codspeed
141-
cmake ..
142-
make -j
104+
- name: Build and run benchmarks
105+
run: |
106+
bazel build //examples/google_benchmark_bazel:my_benchmark --//core:codspeed_mode=${{ matrix.codspeed-mode }} --compilation_mode=dbg --copt=-O2
107+
108+
- name: Run the benchmarks
109+
uses: CodSpeedHQ/action@main
110+
if: matrix.codspeed-mode != 'off'
111+
with:
112+
run: bazel run //examples/google_benchmark_bazel:my_benchmark --//core:codspeed_mode=${{ matrix.codspeed-mode }} --compilation_mode=dbg --copt=-O2
113+
token: ${{ secrets.CODSPEED_TOKEN }}
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

0 commit comments

Comments
 (0)