Skip to content

WIP

WIP #4

Workflow file for this run

name: Check
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
defaults:
run:
shell: bash -ileo pipefail {0}
jobs:
check:
strategy:
fail-fast: false
matrix:
include:
- address_check: ON
undefined_check: ON
thread_check: OFF
coverage: OFF
- address_check: OFF
undefined_check: OFF
thread_check: ON
coverage: OFF
- address_check: OFF
undefined_check: OFF
thread_check: OFF
coverage: ON
name: "Check - Address: ${{ matrix.address_check }} Thread: ${{ matrix.thread_check }} Coverage: ${{ matrix.coverage }}"
runs-on: ubuntu-latest
container:
image: mayjojo/cxx-cmake-project-template:main
steps:
- uses: actions/checkout@v4
- name: Build
run: |
set -eux
CPUS=$(grep -c ^processor /proc/cpuinfo)
mkdir ${GITHUB_WORKSPACE}/build && cd ${GITHUB_WORKSPACE}/build
cmake -DCMAKE_TOOLCHAIN_FILE=/opt/rh/gcc-toolset-13/devel-toolchain.cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DDEMO_ENABLE_TEST=ON \
-DDEMO_ENABLE_EXAMPLE=ON \
-DDEMO_ENABLE_CLANG_TIDY=ON \
-DDEMO_ENABLE_COVERAGE=${{ matrix.coverage }} \
-DDEMO_ENABLE_SANITIZERS=ON \
-DSANITIZE_ADDRESS=${{ matrix.address_check }} \
-DSANITIZE_UNDEFINED=${{ matrix.undefined_check }} \
-DSANITIZE_THREAD=${{ matrix.thread_check }} \
${GITHUB_WORKSPACE}
make -j ${CPUS}
make check_public_header
make install
- name: Package
run: |
set -eux
cpack -G RPM
cpack -G DEB
- name: Test
run: |
set -eux
CPUS=$(grep -c ^processor /proc/cpuinfo)
cd ${GITHUB_WORKSPACE}/build
ctest --force-new-ctest-process --verbose -j ${CPUS}
- name: Generate Code Coverage
if: matrix.coverage == 'ON'
run: |
set -eux
make coverage-xml
- name: Code Coverage Summary Report
if: matrix.coverage == 'ON'
uses: irongut/[email protected]
with:
filename: build/coverage-xml.xml
badge: true
format: markdown
output: both
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: ${{ (github.event_name == 'pull_request') && (matrix.coverage == 'ON') }}
with:
recreate: true
path: code-coverage-results.md
- name: Set Git Safe Directory
if: matrix.coverage == 'ON'
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
if: matrix.coverage == 'ON'
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: wangzw/cxx-cmake-project-template
files: build/coverage-xml.xml