Skip to content

Commit f8881e3

Browse files
committed
CI: add tests for macos, windows, and sanitizers
1 parent 6464cd7 commit f8881e3

File tree

2 files changed

+120
-21
lines changed

2 files changed

+120
-21
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Build cppdap
2+
description: builds the cppdap project
3+
inputs:
4+
msan:
5+
description: 'Enable Memory Sanitizer'
6+
required: false
7+
default: false
8+
tsan:
9+
description: 'Enable Thread Sanitizer'
10+
required: false
11+
default: false
12+
asan:
13+
description: 'Enable Address Sanitizer'
14+
required: false
15+
default: false
16+
config:
17+
description: 'Build configuration'
18+
required: false
19+
default: "Debug"
20+
tests:
21+
description: 'Build tests'
22+
required: false
23+
default: false
24+
fuzzer:
25+
description: 'Build fuzzer'
26+
required: false
27+
default: false
28+
CXX:
29+
description: 'C++ Compiler to use'
30+
required: false
31+
default: ''
32+
CC:
33+
description: 'C Compiler to use'
34+
required: false
35+
default: ''
36+
install:
37+
description: 'Install the build'
38+
required: false
39+
default: false
40+
install_prefix:
41+
description: 'Install prefix'
42+
required: false
43+
default: 'out/usr/local'
44+
45+
runs:
46+
using: "composite"
47+
steps:
48+
- name: Build source
49+
shell: bash
50+
run: |
51+
mkdir -p build
52+
cd build
53+
CC="${{ inputs.CC }}" CXX="${{ inputs.CXX }}" cmake .. -DCPPDAP_BUILD_TESTS=${{ inputs.tests }} -DCPPDAP_BUILD_FUZZER=${{ inputs.fuzzer }} -DCPPDAP_MSAN=${{ inputs.msan }} -DCPPDAP_TSAN=${{ inputs.tsan }} -DCPPDAP_ASAN=${{ inputs.asan }} -DCMAKE_BUILD_TYPE=${{ inputs.config }}
54+
cmake --build . --config ${{ inputs.config }}
55+
- name: Install
56+
shell: bash
57+
if: inputs.install == 'true'
58+
run: |
59+
cmake --install ./build --config ${{ inputs.config }} --prefix ${{ inputs.install_prefix }}

.github/workflows/main.yml

Lines changed: 61 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,88 @@
1+
name: Test
12
on:
23
push:
34
pull_request:
45

56
jobs:
6-
linux:
7-
name: ci
8-
runs-on: ubuntu-latest
9-
10-
container:
11-
image: ubuntu:22.04
12-
7+
non-linux-tests:
8+
name: ${{ matrix.os.name }} tests ( ${{ matrix.config }} )
9+
runs-on: ${{ matrix.os.runner }}
1310
strategy:
1411
matrix:
15-
include:
16-
- CC: gcc
17-
CXX: g++
18-
- CC: clang
19-
CXX: clang++
12+
os: [{ name: "MacOS", runner: "macos-latest"}, { name: "Windows", runner: "windows-latest"}]
13+
config: ["Debug", "Release"]
14+
steps:
2015

21-
# don't run pull requests from local branches twice
22-
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
16+
- uses: actions/checkout@v3
17+
with:
18+
submodules: 'true'
19+
- name: Build source
20+
uses: ./.github/actions/build-cppdap
21+
with:
22+
config: ${{ matrix.config }}
23+
tests: true
24+
install: true
2325

26+
- name: Run tests
27+
run: |
28+
cd build
29+
ctest --output-on-failure -C ${{ matrix.config }}
30+
31+
- uses: actions/upload-artifact@v3
32+
with:
33+
# if flags are not empty, append them to the name
34+
name: cppdap-${{ matrix.os.name }}-${{ matrix.config }}
35+
path: out/usr/local/
36+
37+
linux-tests:
38+
name: Linux tests ( ${{ matrix.config }} ${{ matrix.compiler.CC }} ${{ matrix.sanitizer }} )
39+
runs-on: ${{ matrix.os }}
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
os: ["ubuntu-22.04"] #[ubuntu-22.04, ubuntu-24.04]
44+
config: ["Debug", "Release"]
45+
compiler: [ {CXX: g++, CC: gcc}, {CXX: clang++, CC: clang} ]
46+
sanitizer: ["", "asan", "tsan"]
47+
exclude:
48+
- config: "Release"
49+
sanitizer: "asan"
50+
- config: "Release"
51+
sanitizer: "tsan"
2452
env:
2553
DEBIAN_FRONTEND: noninteractive
2654

2755
steps:
2856
- name: Install packages
2957
run: |
30-
apt-get -q -y update
31-
apt-get -q -y install build-essential cmake git clang
58+
sudo apt-get -q -y update
59+
sudo apt-get -q -y install build-essential cmake git clang
3260
3361
- uses: actions/checkout@v3
3462
with:
3563
submodules: 'true'
3664

3765
- name: Build source
66+
uses: ./.github/actions/build-cppdap
67+
with:
68+
msan: ${{ contains(matrix.sanitizer, 'msan') }}
69+
tsan: ${{ contains(matrix.sanitizer, 'tsan') }}
70+
asan: ${{ contains(matrix.sanitizer, 'asan') }}
71+
config: ${{ matrix.config }}
72+
tests: true
73+
fuzzer: false
74+
CC: ${{ matrix.compiler.CC }}
75+
CXX: ${{ matrix.compiler.CXX }}
76+
install: true
77+
78+
- name: Run tests
79+
shell: bash
3880
run: |
39-
mkdir -p build
4081
cd build
41-
CC=${{ matrix.CC }} CXX=${{ matrix.CXX }} cmake ..
42-
cmake --build .
43-
DESTDIR=../out cmake --install .
82+
./cppdap-unittests
4483
4584
- uses: actions/upload-artifact@v4
4685
with:
47-
name: cppdap-${{ matrix.CC }}
86+
# if flags are not empty, append them to the name
87+
name: cppdap-Linux-${{ matrix.compiler.CC }}-${{ matrix.config }}${{ matrix.sanitizer != '' && '-' || '' }}${{ matrix.sanitizer }}
4888
path: out/usr/local/

0 commit comments

Comments
 (0)