Skip to content

Fixing coverage

Fixing coverage #261

Workflow file for this run

name: GitHub CI
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
#debug_unix:
# name: Debug ${{ matrix.label }}
# runs-on: ${{ matrix.runner }}
# strategy:
# fail-fast: false
# matrix:
# include:
# - label: linux-x64
# runner: ubuntu-22.04
# with_optional: ON
# conda_pkgs: c-compiler cxx-compiler cmake ninja boost-cpp tbb tbb-devel eigen nlopt ipopt
# - label: linux-arm64
# runner: ubuntu-22.04-arm
# with_optional: OFF
# conda_pkgs: c-compiler cxx-compiler cmake ninja boost-cpp tbb tbb-devel eigen
# - label: macos-arm64
# runner: macos-latest
# with_optional: ON
# conda_pkgs: c-compiler cxx-compiler libcxx cmake ninja boost-cpp tbb tbb-devel eigen nlopt ipopt
# steps:
# - uses: actions/checkout@v4
# - uses: conda-incubator/setup-miniconda@v3
# with:
# auto-update-conda: true
# channels: conda-forge
# channel-priority: strict
# - name: Install dependencies
# shell: bash
# run: |
# set -e
# conda create -y -q -p "$HOME/local" ${{ matrix.conda_pkgs }}
# - name: Configure
# shell: bash
# run: |
# set -e
# conda run -p "$HOME/local" cmake -S . -B build -G Ninja \
# -DCMAKE_PREFIX_PATH="$HOME/local" \
# -DCMAKE_BUILD_TYPE=Debug \
# -DBoost_NO_BOOST_CMAKE=ON \
# -DPAGMO_BUILD_TESTS=ON \
# -DPAGMO_WITH_EIGEN3=ON \
# -DPAGMO_WITH_NLOPT=${{ matrix.with_optional }} \
# -DPAGMO_WITH_IPOPT=${{ matrix.with_optional }} \
# -DPAGMO_ENABLE_IPO=ON
# - name: Build
# shell: bash
# run: |
# set -e
# conda run -p "$HOME/local" cmake --build build --parallel
# - name: Test
# shell: bash
# run: |
# set -e
# conda run -p "$HOME/local" ctest --test-dir build -VV --output-on-failure -j4
#
#release_windows_x64:
# name: Release windows-x64
# runs-on: windows-2022
# steps:
# - uses: actions/checkout@v4
# - uses: conda-incubator/setup-miniconda@v3
# with:
# auto-update-conda: true
# channels: conda-forge
# channel-priority: strict
# - name: Configure
# shell: powershell
# run: |
# conda create -y -q -p $env:USERPROFILE\local cmake ninja eigen nlopt ipopt boost-cpp tbb tbb-devel
# conda run -p $env:USERPROFILE\local cmake -S . -B build -G "Visual Studio 17 2022" -A x64 `
# -DCMAKE_PREFIX_PATH=$env:USERPROFILE\local `
# -DCMAKE_INSTALL_PREFIX=$env:USERPROFILE\local `
# -DBoost_NO_BOOST_CMAKE=ON `
# -DPAGMO_BUILD_TESTS=ON `
# -DPAGMO_WITH_EIGEN3=ON `
# -DPAGMO_WITH_NLOPT=ON `
# -DPAGMO_WITH_IPOPT=ON `
# -DPAGMO_ENABLE_IPO=ON
# - name: Build
# shell: powershell
# run: conda run -p $env:USERPROFILE\local cmake --build build --config Release --parallel
# - name: Test
# shell: powershell
# run: |
# $env:PATH = "$PWD\build\Release;$env:USERPROFILE\local\Library\bin;$env:USERPROFILE\local\bin;$env:PATH"
# ctest --test-dir build -VV --output-on-failure -j4 -C Release
linux_coverage_docs:
name: Linux coverage + docs${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && ' and deploy' || '' }}
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
channels: conda-forge
channel-priority: strict
- name: Install dependencies
shell: bash
run: |
set -e
conda create -y -q -p "$HOME/local" \
c-compiler cxx-compiler gcc_linux-64 cmake ninja boost-cpp tbb tbb-devel eigen nlopt ipopt \
python=3.10 sphinx=4.5.0 sphinx-book-theme breathe "doxygen<1.13" graphviz gcovr
- name: Build and test (coverage, no torture)
shell: bash
run: |
set -e
conda run -p "$HOME/local" cmake -S . -B build -G Ninja \
-DCMAKE_PREFIX_PATH="$HOME/local" \
-DCMAKE_BUILD_TYPE=Debug \
-DBoost_NO_BOOST_CMAKE=ON \
-DPAGMO_BUILD_TESTS=ON \
-DPAGMO_WITH_EIGEN3=ON \
-DPAGMO_WITH_NLOPT=ON \
-DPAGMO_WITH_IPOPT=ON \
-DPAGMO_ENABLE_IPO=OFF \
-DCMAKE_CXX_FLAGS="--coverage" \
-DCMAKE_SHARED_LINKER_FLAGS="--coverage" \
-DCMAKE_EXE_LINKER_FLAGS="--coverage"
conda run -p "$HOME/local" cmake --build build --parallel
conda run -p "$HOME/local" ctest --test-dir build -VV --output-on-failure -j4 -E torture
- name: Generate coverage
shell: bash
run: |
set -e
# Use gcovr for report generation and force a gcov executable
# that matches the compiler used for the build.
CXX=$(grep '^CMAKE_CXX_COMPILER:FILEPATH=' build/CMakeCache.txt | cut -d= -f2-)
test -n "$CXX"
GCOV=$("$CXX" -print-prog-name=gcov)
test -n "$GCOV"
if test -x "$GCOV"; then
:
else
CXX_DIR=$(dirname "$CXX")
if test -x "$CXX_DIR/$GCOV"; then
GCOV="$CXX_DIR/$GCOV"
else
GCOV=$(command -v "$GCOV" || true)
fi
fi
test -n "$GCOV"
test -x "$GCOV"
echo "Using gcov tool: $GCOV"
"$GCOV" --version
# Work around known gcov negative-hit bug (GCC bug 68080)
# that can otherwise make gcovr fail the job.
conda run -p "$HOME/local" gcovr \
--root "$PWD" \
--object-directory build \
--gcov-executable "$GCOV" \
--gcov-ignore-parse-errors negative_hits.warn_once_per_file \
--exclude 'tests/.*' \
--exclude 'build/.*' \
--lcov coverage.info \
--xml coverage.xml \
--print-summary
test -s coverage.info
test -s coverage.xml
test "$(grep -c '^SF:' coverage.info || true)" -gt 0
- name: Upload coverage report
uses: codecov/codecov-action@v5
with:
files: coverage.info,coverage.xml
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true
- name: Upload coverage artifacts
if: always()
uses: actions/upload-artifact@v7
with:
name: coverage-reports
path: |
coverage.info
coverage.xml
if-no-files-found: warn
- name: Build Doxygen XML
shell: bash
run: |
set -e
cd doc/doxygen
conda run -p "$HOME/local" doxygen
cp images/* xml/
- name: Build Sphinx docs
shell: bash
run: |
set -e
cd doc/sphinx
conda run -p "$HOME/local" make html
if ! conda run -p "$HOME/local" make linkcheck; then
echo "Warning: Sphinx linkcheck failed (likely transient external outage); continuing."
fi
- name: Deploy to GitHub Pages
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: doc/sphinx/_build/html