Skip to content

Fix clang-format (#107) #737

Fix clang-format (#107)

Fix clang-format (#107) #737

Workflow file for this run

name: coverage
on:
push:
branches:
- '*'
paths:
- '.github/**'
- 'cmake/**'
- 'CMakeLists.txt'
- '*.cpp'
- '*.hpp'
- '*.ipp'
- '.codecov.yml'
jobs:
coverage:
runs-on:
group: intel-runners
container: libfn/ci-build-gcc:14
strategy:
fail-fast: false
env:
CC: /usr/local/bin/gcc
CXX: /usr/local/bin/g++
GCOV: /usr/local/bin/gcov
steps:
- uses: actions/checkout@v4
- name: Verify compiler compatibility
env:
SOURCE: |
#include <optional>
#include <expected>
#include <cstdio>
int main() {
using type1=std::expected<int, const char*>;
using type2=std::optional<int>;
return type1{1}.and_then([](int i) -> type1 { std::puts("OK expected"); return {i-1}; }).value()
+ type2{2}.and_then([](int i) -> type2 { std::puts("OK optional"); return {i-2}; }).value();
}
run: |
FILE=$(mktemp --tmpdir XXXXXX.cpp)
printf "$SOURCE\n" > $FILE
OUT=$(mktemp --tmpdir XXXXXX)
$CXX -std=c++23 -Wall $FILE -o $OUT
$OUT
- name: Prepare build
shell: bash
env:
CMAKE_GENERATOR: Ninja
CMAKE_BUILD_TYPE: Debug
COVERAGE_OPTS: "-g --coverage -fprofile-abs-path -fno-early-inlining"
run: |
mkdir .build
cd .build
cmake -DCMAKE_C_FLAGS="$COVERAGE_OPTS" -DCMAKE_CXX_FLAGS="$COVERAGE_OPTS" ..
COMPILER=$( grep "CMAKE_CXX_COMPILER:FILEPATH" CMakeCache.txt | sed "s|CMAKE_CXX_COMPILER:FILEPATH=/|/|" )
[[ "$( realpath $CXX )" == "$( realpath $COMPILER )" ]] || exit 13
printf "C++ compiler: %s\n" "$COMPILER"
printf "C++ compiler version: %s\n" "$( $COMPILER --version | head -1 )"
printf "gcov version: %s\n" "$( $GCOV --version | head -1 )"
- name: Run coverage target
shell: bash
run: |
cd .build
cmake --build .
tests/tests/tests -a # generate .gcda files
$GCOV -pbc -r -s $( realpath .. ) $( find tests/tests/ -type f -name '*.gcno' ) # generate .gcov files
- name: Upload .gcov files
if: ${{ github.event_name == 'push' }}
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
disable_search: false
verbose: true
plugin: noop
token: ${{ secrets.CODECOV_TOKEN }}