Skip to content

Refactor TestMain.cpp into Static and Dynamic Test Files #160

Refactor TestMain.cpp into Static and Dynamic Test Files

Refactor TestMain.cpp into Static and Dynamic Test Files #160

Workflow file for this run

# 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:
- "*"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref || github.run_id}}
cancel-in-progress: true
permissions:
actions: read
checks: write
contents: read
id-token: write
packages: write
pages: write
security-events: write
jobs:
build:
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@acb35cf920333f4dc3fc4f424f1b30d5e7d561b4
with:
cmakeVersion: latest
ninjaVersion: latest
useCloudCache: true
useLocalCache: true
- name: Initialize CodeQL
uses: github/codeql-action/init@f6091c0113d1dcf9b98e269ee48e8a7e51b7bdd4
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@f6091c0113d1dcf9b98e269ee48e8a7e51b7bdd4
continue-on-error: true
with:
category: "/language:c-cpp"
- name: Convert JUnit to HTML
uses: mikepenz/action-junit-report@62516aa379bff6370c95fd5894d5a27fb6619d9b
if: success() || failure()
with:
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@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
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