Skip to content

Add additional tests #6

Add additional tests

Add additional tests #6

Workflow file for this run

name: "Build|Test"
on:
# always run on main branch
push:
branches: [ main ]
paths-ignore:
- 'README.md'
- 'CONTRIBUTING.md'
- 'LICENSE'
# run on PR to main branch if relevant files changed
pull_request:
branches: [ main ]
paths:
- 'src/**'
- 'include/**'
- 'test/**'
- 'examples/**'
- 'CMakeLists.txt'
- '.github/workflows/cpp-build.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
name: "build"
runs-on: ubuntu-latest
strategy:
matrix:
include:
- cpp_compiler: "g++"
alpine_version: "v3.20"
cpp_version: "cpp17"
- cpp_compiler: "clang++"
alpine_version: "v3.19"
cpp_version: "cpp17"
- cpp_compiler: "g++"
alpine_version: "v3.19"
cpp_version: "cpp20"
- cpp_compiler: "clang++"
alpine_version: "v3.20"
cpp_version: "cpp20"
steps:
- uses: actions/checkout@v3
- uses: jirutka/setup-alpine@v1
with:
branch: ${{ matrix.alpine_version }}
packages: >
cmake
ninja-build
g++
clang
boost-dev
boost-filesystem
boost-python3
lua5.2-dev
python3-dev
fmt-dev
gtest-dev
- name: Fixup environment
run: |
ln -s liblua-5.2.so.0 /usr/lib/liblua-5.2.so
ln -s /usr/lib/ninja-build/bin/ninja /usr/bin/ninja
shell: alpine.sh --root {0}
- name: Prepare
run: |
CXX=/usr/bin/${{ matrix.cpp_compiler }} \
cmake . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DPPPLUGIN_SHARED=ON \
-DPPPLUGIN_ENABLE_EXAMPLES=ON \
-DPPPLUGIN_ENABLE_TESTS=ON \
-DPPPLUGIN_ENABLE_COVERAGE=${{ matrix.cpp_compiler == 'g++' && 'ON' || 'OFF' }} \
-DPPPLUGIN_ENABLE_CPP17_COMPATIBILITY=${{ matrix.cpp_version == 'cpp17' && 'ON' || 'OFF' }}
shell: alpine.sh {0}
- name: Build
run: |
cmake --build build -j
shell: alpine.sh {0}
- name: Install
run: |
cmake --install build
shell: alpine.sh --root {0}
- uses: actions/upload-artifact@v4
with:
name: build_alpine-${{ matrix.alpine_version }}_${{ matrix.cpp_compiler }}_${{ matrix.cpp_version }}
path: build
retention-days: 5
unittest:
name: "unittest"
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
cpp_version: [ "cpp17", "cpp20" ]
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v4
with:
pattern: build_alpine-*_g++_${{ matrix.cpp_version }}
path: build
merge-multiple: true
- name: Fix artifact permissions
run: chmod +x build/test/tests
- uses: jirutka/setup-alpine@v1
with:
branch: v3.20
packages: >
g++
gtest-dev
lcov
gzip
- name: Execute tests
run: |
lcov --capture --initial \
--directory . \
--ignore-errors mismatch,source \
--output-file baseline_coverage
build/test/tests || echo $?
lcov --capture \
--directory . \
--ignore-errors mismatch,source \
--output-file total_coverage
lcov \
--add-tracefile baseline_coverage \
--add-tracefile total_coverage \
--ignore-errors mismatch,source \
--output-file measured_coverage
lcov --remove measured_coverage "/usr*" \
--ignore-errors mismatch,source \
--output-file coverage_without_system_files
lcov --remove coverage_without_system_files "*/test/*" \
--ignore-errors mismatch,source \
--output-file coverage_without_system_and_test_files
genhtml \
--output-directory coverage \
--legend coverage_without_system_and_test_files
lcov --list coverage_without_system_and_test_files
shell: alpine.sh {0}
- uses: actions/upload-artifact@v4
with:
name: coverage_${{ matrix.cpp_version }}
path: coverage
retention-days: 3
ctest:
name: "ctest"
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v4
with:
name: build_alpine-v3.20_g++_cpp17
path: build
- name: Fix artifact permissions
run: chmod +x build/test/tests
- uses: jirutka/setup-alpine@v1
with:
branch: v3.20
packages: >
cmake
ninja-build
g++
boost-dev
boost-filesystem
boost-python3
lua5.2-dev
python3-dev
fmt-dev
gtest-dev
- name: Fixup environment
run: |
ln -s /usr/lib/ninja-build/bin/ninja /usr/bin/ninja
ln -s liblua-5.2.so.0 /usr/lib/liblua-5.2.so
shell: alpine.sh --root {0}
- name: Run cmake tests
run: |
cd build
ctest -R cmake_ --output-on-failure
env:
CMAKE_GENERATOR: Ninja
shell: alpine.sh {0}
- uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: cmake_tests_results
path: build/Testing/Temporary
retention-days: 2