Skip to content

Commit 0c173d8

Browse files
author
zacharyburnett
committed
build and test CMake project in CI
1 parent 0fb1b8a commit 0c173d8

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

.github/workflows/build.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: build
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
release:
9+
types:
10+
- released
11+
workflow_dispatch:
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
15+
cancel-in-progress: true
16+
17+
permissions: read-all
18+
19+
jobs:
20+
cmake:
21+
strategy:
22+
matrix:
23+
runs-on:
24+
- ubuntu-latest
25+
# macos-13 is an intel runner, macos-14 is apple silicon
26+
- macos-13
27+
- macos-latest
28+
fail-fast: false
29+
runs-on: ${{ matrix.runs-on }}
30+
timeout-minutes: 30
31+
steps:
32+
- uses: zacharyburnett/setup-abseil-cpp@de39f445295c887839e30c864ffbbb1c0231bc83 # 1.0.5
33+
with:
34+
cmake-build-args: "-DCMAKE_CXX_STANDARD=17 -DABSL_PROPAGATE_CXX_STD=ON -DABSL_ENABLE_INSTALL=ON -DBUILD_TESTING=off -DCMAKE_POSITION_INDEPENDENT_CODE=ON"
35+
abseil-version: "20240722.0"
36+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
37+
- run: mkdir build
38+
- run: cmake -DCMAKE_CXX_STANDARD=17 -DCMAKE_PREFIX_PATH=/usr/local/ -DBUILD_TESTS=OFF ..
39+
working-directory: build/
40+
- run: sudo cmake --build . --parallel --target=install
41+
working-directory: build/

.github/workflows/test.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: test
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
12+
cancel-in-progress: true
13+
14+
permissions: read-all
15+
16+
env:
17+
GOOGLETEST_VERSION: "1.15.2"
18+
19+
jobs:
20+
ctest:
21+
strategy:
22+
matrix:
23+
runs-on:
24+
- ubuntu-latest
25+
# macos-13 is an intel runner, macos-14 is apple silicon
26+
- macos-13
27+
- macos-latest
28+
fail-fast: false
29+
runs-on: ${{ matrix.runs-on }}
30+
timeout-minutes: 30
31+
env:
32+
CTEST_OUTPUT_ON_FAILURE: ON
33+
steps:
34+
- uses: zacharyburnett/setup-abseil-cpp@de39f445295c887839e30c864ffbbb1c0231bc83 # 1.0.5
35+
with:
36+
cmake-build-args: "-DCMAKE_CXX_STANDARD=17 -DABSL_PROPAGATE_CXX_STD=ON -DABSL_ENABLE_INSTALL=ON -DBUILD_TESTING=off -DCMAKE_POSITION_INDEPENDENT_CODE=ON"
37+
abseil-version: "20240722.0"
38+
- name: retrieve googletest v${{ env.GOOGLETEST_VERSION }}
39+
run: |
40+
wget https://github.com/google/googletest/releases/download/v${{ env.GOOGLETEST_VERSION }}/googletest-${{ env.GOOGLETEST_VERSION }}.tar.gz
41+
tar -xzvf googletest-${{ env.GOOGLETEST_VERSION }}.tar.gz
42+
echo GOOGLETEST_ROOT=${{ runner.temp }}/googletest-${{ env.GOOGLETEST_VERSION }} >> $GITHUB_ENV
43+
working-directory: ${{ runner.temp }}
44+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
45+
- run: mkdir build
46+
- run: cmake -DCMAKE_CXX_STANDARD=17 -DCMAKE_PREFIX_PATH=/usr/local/ -DGOOGLETEST_ROOT=${{ env.GOOGLETEST_ROOT }} -DGOOGLETEST_VERSION=${{ env.GOOGLETEST_VERSION }} ..
47+
working-directory: build/
48+
- run: cmake --build . ${{ runner.os == 'macOS' && '--parallel' || '' }}
49+
# building tests with `--parallel` is disabled on Linux because GitHub seems to automatically cancel the job due to resource limits(?)
50+
working-directory: build/
51+
- if: always()
52+
run: cmake --build . --parallel --target=test
53+
working-directory: build/

0 commit comments

Comments
 (0)