-
Notifications
You must be signed in to change notification settings - Fork 1
190 lines (169 loc) · 7.12 KB
/
ci.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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# Copyright 2025 Torsten Knodt
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http: //www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: C++ CI
on:
push:
# branches: Disabled Because of #25
# - "*" Disabled Because of #25
tags:
- "*"
pull_request:
branches:
- "*"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref || github.run_id}}
cancel-in-progress: true
permissions: {}
jobs:
build:
permissions:
actions: read
checks: write
contents: read
packages: write
# pages: write
pull-requests: write # Needed for test results comments
security-events: write
strategy:
matrix:
CMAKE_C_COMPILER:
- x86_64-linux-gnu-gcc-14
- clang-18
include:
- CMAKE_C_COMPILER: x86_64-linux-gnu-gcc-14
CMAKE_CXX_COMPILER: x86_64-linux-gnu-g++-14
GCOV_EXECUTABLE: x86_64-linux-gnu-gcov-14
CMAKE_CXX_COMPILER_OFFLOAD:
- default
- disable
- CMAKE_C_COMPILER: clang-18
CMAKE_CXX_COMPILER: clang++-18
runs-on: ubuntu-24.04
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e
with:
egress-policy: block
allowed-endpoints: >
github.com:443
api.github.com:443
objects.githubusercontent.com:443
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Set up apt cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
with:
path: |
/var/lib/apt/lists
/var/lib/apt/swcatalog
/var/cache/apt
key: ${{ runner.os }}-apt-${{ hashFiles('.github/workflows/ci.yml') }}
- name: Cache APT Packages
uses: torsknod2/cache-apt-pkgs-action@17ab10b5acb112df5c8f8fe83a91a4d5019eb41d # FallBack2InstallAndCachePkgIfRestorePkgFails
with:
packages: clang-18-doc clang-18-examples clang-format-18 clang-tidy-18 clangd-18 cpp-14-doc dia dia-shapes doxygen doxygen-doc doxygen-gui doxygen-latex fonts-freefont-ttf fonts-freefont-otf fonts-texgyre fonts-urw-base35 g++-14 gcc-14-doc gcc-14-locales gcc-14-multilib gcc-14-offload-amdgcn gcc-14-offload-nvptx gcovr graphviz graphviz-doc gsfonts lcov llvm-18-doc llvm-18-examples llvm-18-tools mmv mscgen nsight-compute nsight-systems nvidia-cuda-gdb nvidia-cuda-toolkit nvidia-cuda-toolkit-doc nvidia-profiler wasi-libc
execute_install_scripts: true
- name: get-cmake
uses: lukka/get-cmake@5f6e04f5267c8133f1273bf2103583fc72c46b17
with:
cmakeVersion: latest
ninjaVersion: latest
useCloudCache: true
useLocalCache: true
- name: Initialize CodeQL
uses: github/codeql-action/init@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0
if: success() || failure()
with:
languages: c-cpp # TODO Get (experimenta-l)actions working
build-mode: manual
queries: security-extended,security-and-quality
- name: Configure CMake
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/${{matrix.CMAKE_C_COMPILER}} -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/${{matrix.CMAKE_CXX_COMPILER}} ${{ matrix.CMAKE_CXX_COMPILER_OFFLOAD && format('-DCMAKE_CXX_COMPILER_OFFLOAD:STRING={0}', matrix.CMAKE_CXX_COMPILER_OFFLOAD) || '' }}
- name: Build
run: cmake --build build --verbose --parallel
- name: Run Tests
working-directory: build
run: ctest --output-on-failure --output-log ctest.log.txt --output-junit ctest.junit.xml -j -R MDSpanTest
- name: Move Test Results to Target Location
if: success() || failure()
working-directory: build
run: |
find GTestOutputDir -type d -exec mmv -r "{}/*.xml" "#1.junit.xml" \;
mv ctest.log.txt ctest.junit.xml GTestOutputDir
- name: Check Test Coverage
uses: torsknod2/gcovr-action@742bc7c9ccf227bad1f53c59a8d5c42c79ed2b81
if: (success() || failure()) && ${{matrix.GCOV_EXECUTABLE}}
with:
force_install: true
root: ..
gcov-executable: ${{matrix.GCOV_EXECUTABLE}}
working-directory: build
filter: _deps
fail-under-line: 100
fail-under-branch: 100
fail-under-decision: 100
fail-under-function: 100
decisions: true
calls: true
j: true
cobertura-out: GTestOutputDir/coverage.cobertura.xml
cobertura-pretty: true
html-out: GTestOutputDir/coverage.html
html-details: true
jacoco-out: GTestOutputDir/coverage.jacoco.xml
json-out: GTestOutputDir/coverage.json
json-pretty: true
json-summary-out: GTestOutputDir/coverage.summary.json
json-summary-pretty: true
lcov-out: GTestOutputDir/coverage.lcov
sonarqube-out: GTestOutputDir/coverage.sonarqube
txt-out: GTestOutputDir/coverage.txt
print-summary: true
# TODO Add test step for benchmark using RelWithDebInfo once implemented: ./BenchmarkMain
- name: Perform CodeQL Analysis
if: success() || failure()
uses: github/codeql-action/analyze@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0
continue-on-error: true
with:
category: "/language:c-cpp"
- name: Convert JUnit to HTML
uses: mikepenz/action-junit-report@ee6b445351cd81e2f73a16a0e52d598aeac2197f
if: success() || failure()
with:
comment: true
report_paths: build/GTestOutputDir/**/*.junit.xml
fail_on_failure: true
include_passed: true
- name: Test Report
uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5
if: success() || failure()
with:
name: Test Results
working-directory: build
path: GTestOutputDir/**/*.junit.xml
reporter: java-junit
- name: Upload reports/ results
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1
if: success() || failure()
with:
name: ${{ matrix.CMAKE_C_COMPILER }}-${{ matrix.CMAKE_CXX_COMPILER }}-${{ matrix.GCOV_EXECUTABLE || 'nocov' }}-${{ matrix.CMAKE_CXX_COMPILER_OFFLOAD || 'nooffload' }}
path: build/GTestOutputDir
# - name: Upload GitHub Pages Artifact
# uses: actions/upload-pages-artifact@v3
# with:
# path: build/GTestOutputDir
# - name: Deploy to GitHub Pages
# if: github.ref == 'refs/heads/main'
# uses: actions/deploy-pages@v4