Skip to content

Take linking the tests from a subproject into account correctly #80

Take linking the tests from a subproject into account correctly

Take linking the tests from a subproject into account correctly #80

Workflow file for this run

name: Build Linux
on:
push:
branches-ignore:
- 'coverityScan'
pull_request:
branches:
- 'main'
concurrency:
group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-linux:
name: '${{ matrix.os.id }} (${{ matrix.compiler }}, ${{ matrix.cpp_std }})'
runs-on: ${{ matrix.os.id }}
strategy:
matrix:
os:
- { id: ubuntu-20.04, name: focal }
- { id: ubuntu-22.04, name: jammy }
compiler:
- 'clang-9'
- 'clang-10'
- 'clang-11'
- 'clang-12'
- 'clang-13'
- 'clang-14'
- 'clang-15'
- 'clang-16'
- 'clang-17'
- 'gcc-7'
- 'gcc-8'
- 'gcc-9'
- 'gcc-10'
- 'gcc-11'
- 'gcc-12'
- 'gcc-13'
cpp_std:
- 'c++11'
- 'c++14'
- 'c++17'
exclude:
# These versions are not supported by the toolchain PPA
- { os: { id: ubuntu-20.04 }, compiler: gcc-12 }
- { os: { id: ubuntu-22.04 }, compiler: gcc-7 }
- { os: { id: ubuntu-22.04 }, compiler: gcc-8 }
- { os: { id: ubuntu-22.04 }, compiler: clang-9 }
- { os: { id: ubuntu-22.04 }, compiler: clang-10 }
- { os: { id: ubuntu-22.04 }, compiler: clang-11 }
- { os: { id: ubuntu-22.04 }, compiler: clang-12 }
fail-fast: false
steps:
- name: Runtime environment
shell: bash
env:
WORKSPACE: ${{ github.workspace }}
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH
echo "GITHUB_WORKSPACE=`pwd`" >> $GITHUB_ENV
- name: Setup GCC
if: startsWith(matrix.compiler, 'gcc')
shell: bash
run: |
CXX=${CC/#gcc/g++}
sudo apt-add-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install $CC $CXX
echo "CC=$CC" >> $GITHUB_ENV
echo "CXX=$CXX" >> $GITHUB_ENV
echo "GCOV=${CC/#gcc/gcov}" >> $GITHUB_ENV
env:
CC: ${{ matrix.compiler }}
- name: Setup Clang
if: startsWith(matrix.compiler, 'clang')
shell: bash
run: |
wget https://apt.llvm.org/llvm-snapshot.gpg.key
sudo apt-key add llvm-snapshot.gpg.key
rm llvm-snapshot.gpg.key
sudo apt-add-repository "deb https://apt.llvm.org/${{ matrix.os.name }}/ llvm-toolchain-${{ matrix.os.name }}${CC/#clang/} main"
sudo apt-get update
sudo apt-get install $CC
CXX=${CC/#clang/clang++}
echo "CC=$CC" >> $GITHUB_ENV
echo "CXX=$CXX" >> $GITHUB_ENV
echo "GCOV=/usr/lib/${CC/#clang/llvm}/bin/llvm-cov gcov" >> $GITHUB_ENV
env:
CC: ${{ matrix.compiler }}
working-directory: ${{ runner.temp }}
- name: Add coverage dependency
if: matrix.compiler == 'clang-14'
run: |
apt download libclang-rt-14-dev
PACKAGE=$(find . -name 'libclang-rt-14*.deb')
sudo dpkg --install --force-breaks $PACKAGE
working-directory: ${{ runner.temp }}
- name: Checkout
uses: actions/checkout@v3
with:
lfs: true
submodules: true
- name: Setup Meson + Ninja + gcovr
shell: bash
run: |
sudo python3 -m pip install --upgrade pip setuptools wheel
sudo python3 -m pip install meson ninja gcovr
working-directory: ${{ runner.temp }}
- name: Version tools
shell: bash
run: |
$CC --version
$CXX --version
$GCOV --version
meson --version
ninja --version
- name: Configure
run: meson setup build --prefix=$HOME/.local -Dcpp_std=${{ matrix.cpp_std }} $BUILD_OPTS
- name: Build
run: meson compile -C build
- name: Test
run: meson test -C build
- name: Install
run: meson install -C build
- name: Run coverage build
if: github.repository == 'dragonmux/crunch'
# Codecov no longer parses gcov files automatically
run: |
rm -rf build
meson setup build --prefix=$HOME/.local -Dcpp_std=${{ matrix.cpp_std }} -Db_coverage=true --buildtype=debug
meson compile -C build
meson test -C build
cd build
find . -type f -name '*.gcda' -exec $GCOV -p {} + > /dev/null
gcovr -r .. -x coverage.xml --gcov-executable "$GCOV" -e ../deps -e ../test
- name: Upload failure logs
if: failure()
uses: actions/upload-artifact@v3
with:
name: logs-${{ matrix.os.id }}-${{ matrix.cpp_std }}
path: ${{ github.workspace }}/build
retention-days: 5
- name: Codecov
if: success()
uses: codecov/codecov-action@v3