-
Notifications
You must be signed in to change notification settings - Fork 13
155 lines (134 loc) · 5.06 KB
/
Copy pathcmake-multi-platform.yml
File metadata and controls
155 lines (134 loc) · 5.06 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
147
148
149
150
151
152
153
154
155
name: CMake on macOS & Ubuntu
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
build_type: [Debug, Release]
c_compiler: [gcc, clang]
include:
# Ubuntu combos
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
# macOS uses Apple Clang
- os: macos-latest
c_compiler: clang
cpp_compiler: clang++
exclude:
# Prevent gcc on macOS (Apple Clang presents as gcc, but we want explicit clang)
- os: macos-latest
c_compiler: gcc
- os: ubuntu-latest
c_compiler: clang
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
# Ensure toolchain availability per-OS
- name: Install toolchain (Ubuntu/clang only)
if: matrix.os == 'ubuntu-latest' && matrix.c_compiler == 'clang'
run: |
sudo apt-get update
sudo apt-get install -y clang
- name: Ensure CMake on macOS
if: matrix.os == 'macos-latest'
run: |
if ! command -v cmake >/dev/null 2>&1; then
brew update
brew install cmake
brew install pipx
fi
- name: Show tool versions
run: |
echo "CMake: $(cmake --version | head -n1)"
echo "CC: ${{ matrix.c_compiler }} -> $(which ${{ matrix.c_compiler }})"
echo "CXX: ${{ matrix.cpp_compiler }} -> $(which ${{ matrix.cpp_compiler }})"
${{ matrix.c_compiler }} --version
${{ matrix.cpp_compiler }} --version
- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Configure CMake
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_EXPORT_COMPILE_COMMANDS=on
-DFKVS_ENABLE_WARNINGS=ON
-DFKVS_WARNINGS_AS_ERRORS=ON
-S ${{ github.workspace }}
- name: Build
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
- name: Generate compile commands json database
run: >
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=on
-B ${{ steps.strings.outputs.build-output-dir }}
- name: Install CodeChecker dependencies
if: matrix.build_type == 'Debug'
run: |
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
sudo apt-get update
sudo apt-get install -y clang clang-tidy clang-tools python3-pip
pip3 install codechecker
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
if ! command -v pipx >/dev/null 2>&1; then
brew update
brew install pipx
fi
python3 -m venv path/to/venv
source path/to/venv/bin/activate
pipx install codechecker
fi
- name: Run CodeChecker analysis
if: matrix.build_type == 'Debug'
id: codechecker
run: |
CodeChecker analyze ${{ steps.strings.outputs.build-output-dir }}/compile_commands.json --output ${{ github.workspace }}/${{ matrix.os }}/reports
CodeChecker parse ${{ github.workspace }}/${{ matrix.os }}/reports --export html --output ${{ github.workspace }}/html_reports || true
echo "result-html-dir=${{ github.workspace }}/html_reports" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v4
if: matrix.build_type == 'Debug'
with:
name: "CodeChecker Bug Reports (${{ matrix.os }})"
path: ${{ steps.codechecker.outputs.result-html-dir }}
- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: ctest -C ${{ matrix.build_type }} --output-on-failure
sanitizers:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Install sanitizer toolchain
run: |
sudo apt-get update
sudo apt-get install -y clang
- name: Configure CMake with sanitizers
run: >
cmake -B ${{ github.workspace }}/build-sanitize
-DCMAKE_C_COMPILER=clang
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_EXPORT_COMPILE_COMMANDS=on
-DFKVS_ENABLE_WARNINGS=ON
-DFKVS_WARNINGS_AS_ERRORS=ON
-DFKVS_ENABLE_SANITIZERS=ON
-S ${{ github.workspace }}
- name: Build sanitizer target
run: cmake --build ${{ github.workspace }}/build-sanitize --config Debug
- name: Test with sanitizers
working-directory: ${{ github.workspace }}/build-sanitize
run: ctest -C Debug --output-on-failure