-
Notifications
You must be signed in to change notification settings - Fork 3
164 lines (164 loc) · 5.95 KB
/
cmake.yml
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
156
157
158
159
160
161
162
163
164
---
name: CMake
"on":
push:
branches:
- "master"
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
pull_request: ~
jobs:
# Regular C build with two compilers, using the environment:
build_using_compiler_in_environment:
strategy:
matrix:
compiler:
- { cc: clang, cxx: clang++ }
- { cc: gcc, cxx: g++ }
runs-on: ubuntu-latest
# We can use cmakeflags for this, or we can just use
# regular environment variables, as they are already
# supported by github actions:
env:
CC: ${{ matrix.compiler.cc }}
CXX: ${{ matrix.compiler.cxx }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- uses: docker://lpenz/ghaction-cmake:0.19
with:
dependencies_debian: python3-pip python3-setuptools python3-wheel libpython3-dev
cmakeflags: -DPYTHON=python3 -DCMAKE_POSITION_INDEPENDENT_CODE=1
# Static analyzers:
linters:
strategy:
matrix:
preset: [cppcheck, clang-tidy]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- uses: docker://lpenz/ghaction-cmake:0.19
with:
dependencies_debian: python3-pip python3-setuptools python3-wheel libpython3-dev
cmakeflags: -DPYTHON=python3 -DCMAKE_POSITION_INDEPENDENT_CODE=1
preset: ${{ matrix.preset }}
# Tests with various sanitizers and valgrind:
test:
strategy:
matrix:
preset:
- clang-sanitize-address
# - clang-sanitize-memory
- clang-sanitize-undefined
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- uses: docker://lpenz/ghaction-cmake:0.19
with:
dependencies_debian: llvm python3-pip python3-setuptools python3-wheel libpython3-dev
cmakeflags: -Dlibsettings_ENABLE_PYTHON=0 -DCMAKE_POSITION_INDEPENDENT_CODE=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo
preset: ${{ matrix.preset }}
# Test installation:
install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- uses: docker://lpenz/ghaction-cmake:0.19
with:
dependencies_debian: python3-pip python3-setuptools python3-wheel libpython3-dev
cmakeflags: -DPYTHON=python3 -DCMAKE_POSITION_INDEPENDENT_CODE=1
preset: install
# Run SonarCloud analysis and coverage report:
coverage:
runs-on: ubuntu-latest
env:
SONAR_SCANNER_VERSION: 5.0.1.3006
SONAR_SERVER_URL: "https://sonarcloud.io"
SONAR_ORG: swift-nav
SONAR_PROJECT_KEY: swift-nav_libsettings
BUILD_WRAPPER_OUT_DIR: sonarcloud-out
ANALYSIS_CACHE_DIR: sonarcloud-cache
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: 11
- name: Set up Python for gcovr
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install gcovr
run: |
pip install gcovr==5.0
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Download and set up sonar-scanner
env:
SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip
run: |
mkdir -p $HOME/.sonar
curl -sSLo $HOME/.sonar/sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }}
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
echo "$HOME/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin" >> $GITHUB_PATH
- name: Download and set up build-wrapper
env:
BUILD_WRAPPER_DOWNLOAD_URL: ${{ env.SONAR_SERVER_URL }}/static/cpp/build-wrapper-linux-x86.zip
run: |
curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }}
unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
echo "$HOME/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH
- name: Run CMake
run: |
cmake \
-Dlibsettings_ENABLE_PYTHON=0 \
-DCMAKE_POSITION_INDEPENDENT_CODE=1 \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_FLAGS="--coverage" \
-DCMAKE_CXX_FLAGS="--coverage"
- name: Build with coverage
run: |
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} make VERBOSE=1
- name: Generate coverage report
run: |
gcovr -v --sonarqube -o coverage.xml
- name: Cache SonarCloud analysis files
uses: actions/cache@v3
with:
path: ${{ env.ANALYSIS_CACHE_DIR }}
key: ${{ runner.os }}-analysis
restore-keys: ${{ runner.os }}-analysis
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" \
--define sonar.organization="${{ env.SONAR_ORG }}" \
--define sonar.projectKey="${{ env.SONAR_PROJECT_KEY }}" \
--define sonar.sources="src,python" \
--define sonar.tests="tests" \
--define sonar.python.version="3.7,3.8,3.9,3.10,3.11" \
--define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" \
--define sonar.cfamily.cache.enabled="true" \
--define sonar.cfamily.cache.path="${{ env.ANALYSIS_CACHE_DIR }} " \
--define sonar.coverageReportPaths="coverage.xml"