-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (126 loc) · 4.63 KB
/
ci.yml
File metadata and controls
146 lines (126 loc) · 4.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build_test:
name: Build & Test Matrix
runs-on: ubuntu-latest
strategy:
matrix:
compiler: [gcc-13, clang-17]
build_type: [Debug, Release]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build ccache
if [ "${{ matrix.compiler }}" = "gcc-13" ]; then
sudo apt-get install -y gcc-13 g++-13
else
sudo apt-get install -y clang-17
fi
- name: Cache ccache
uses: actions/cache@v4
with:
path: ~/.ccache
key: ${{ runner.os }}-ccache-${{ matrix.compiler }}-${{ matrix.build_type }}-${{ hashFiles('**/CMakeLists.txt') }}
restore-keys: |
${{ runner.os }}-ccache-${{ matrix.compiler }}-${{ matrix.build_type }}-
${{ runner.os }}-ccache-${{ matrix.compiler }}-
- name: Configure
run: |
mkdir -p build
if [ "${{ matrix.compiler }}" = "gcc-13" ]; then
cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCPUSCOPE_BUILD_TESTS=ON \
-DCPUSCOPE_WERROR=ON \
-DCMAKE_C_COMPILER=gcc-13 \
-DCMAKE_CXX_COMPILER=g++-13 \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
else
cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCPUSCOPE_BUILD_TESTS=ON \
-DCPUSCOPE_WERROR=ON \
-DCMAKE_C_COMPILER=clang-17 \
-DCMAKE_CXX_COMPILER=clang++-17 \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
fi
- name: Build
run: cmake --build build --parallel
- name: Run tests
run: ctest --test-dir build --output-on-failure
- name: Smoke test
if: matrix.build_type == 'Release'
run: ./build/cpuscope_cli --version
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install lint dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build ccache clang-format-18 clang-tidy clang-17
- name: Check clang-format version
run: clang-format --version
- name: Configure compile commands
run: |
mkdir -p build
cmake -S . -B build -G Ninja \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCPUSCOPE_BUILD_TESTS=ON \
-DCMAKE_C_COMPILER=clang-17 \
-DCMAKE_CXX_COMPILER=clang++-17 \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
- name: Check formatting
run: scripts/check-format.sh
- name: Run static analysis
run: scripts/lint.sh
sanitizer:
name: Sanitizer Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build ccache clang-17
- name: Cache ccache
uses: actions/cache@v4
with:
path: ~/.ccache
key: ${{ runner.os }}-ccache-clang-17-Release-${{ hashFiles('**/CMakeLists.txt') }}
restore-keys: |
${{ runner.os }}-ccache-clang-17-Release-
${{ runner.os }}-ccache-clang-17-
- name: Configure sanitizer build
run: |
mkdir -p build-sanitizer
cmake -S . -B build-sanitizer -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCPUSCOPE_BUILD_TESTS=ON \
-DCPUSCOPE_WERROR=ON \
-DCMAKE_C_COMPILER=clang-17 \
-DCMAKE_CXX_COMPILER=clang++-17 \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_FLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer -fno-sanitize-recover=all" \
-DCMAKE_CXX_FLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer -fno-sanitize-recover=all" \
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address,undefined"
- name: Build sanitizer build
run: cmake --build build-sanitizer --parallel
- name: Run sanitizer tests
run: |
export ASAN_OPTIONS=halt_on_error=1:detect_leaks=0
export UBSAN_OPTIONS=halt_on_error=1
ctest --test-dir build-sanitizer --output-on-failure