Skip to content

Added more tests

Added more tests #117

Workflow file for this run

name: CMake Build Matrix
on:
push:
paths-ignore:
- "**/README.md"
pull_request:
release:
branches:
- main
workflow_dispatch:
env:
CMAKE_VERSION: 3.22
jobs:
build-linux:
name: ${{ matrix.os }} ${{ matrix.build_type }} ${{ matrix.cxx }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
build_type: [Debug, Release]
cxx: [g++, clang++-15]
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get install ${{ matrix.cxx }} ninja-build lcov doxygen
- name: Check Coverage
run: |
if [[ ${{ matrix.build_type }} == 'Debug' && ${{ matrix.cxx }} == 'g++' ]]; then
echo "COVERAGE=ON" >> "$GITHUB_ENV"
echo "Running with coverage"
else
echo "COVERAGE=OFF" >> "$GITHUB_ENV"
fi
- name: Configure
env:
CXX: ${{ matrix.cxx }}
run: mkdir build && cd build && cmake -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCOVERAGE=${{ env.COVERAGE }} ..
- name: Build
run: cmake --build build
- name: Test
run: cd build && ctest --output-on-failure
- name: Coverage
if: ${{ env.COVERAGE == 'ON' }}
run: |
files=`find . -name "*.gcda" | xargs`
gcov -f -b $files
- name: lcov-action
if: ${{ env.COVERAGE == 'ON' }}
uses: imciner2/run-lcov@v1
with:
input_directory: "."
exclude: '"*test/*" "*_deps/*" "*/usr/include/*"'
output_file: "./coverage.info"
- name: Generate coverage report
if: ${{ env.COVERAGE == 'ON' }}
run: |
cat coverage.info | c++filt >coverage_filtered.info
genhtml coverage_filtered.info --output-directory html
- name: Archive code coverage results
if: ${{ env.COVERAGE == 'ON' }}
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: html
- name: Coveralls
if: ${{ env.COVERAGE == 'ON' }}
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: coverage_filtered.info
- name: Build documentation and create distribution zip
if: ${{ matrix.build_type == 'Release' && matrix.cxx == 'g++' }}
run: |
cmake --build build --target docs
cd build && cpack --config CPackConfig.cmake
- name: Get package name
if: ${{ matrix.build_type == 'Release' && matrix.cxx == 'g++' }}
run: |
version=$(grep "project(" CMakeLists.txt | cut -d ' ' -f3)
echo "VERSION=$version" >> "$GITHUB_ENV"
- name: Upload rexsapi package
if: ${{ matrix.build_type == 'Release' && matrix.cxx == 'g++' }}
uses: actions/upload-artifact@v4
with:
name: rexsapi-linux-${{env.VERSION}}
path: build/rexsapi-linux-*.zip
build-macos:
name: ${{ matrix.os }} ${{ matrix.build_type }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-12]
build_type: [Debug, Release]
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: brew install doxygen
- name: Configure
run: mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ..
- name: Build
run: cmake --build build --config ${{ matrix.build_type }}
- name: Test
run: cd build && ctest --output-on-failure -C ${{ matrix.build_type }}
- name: Create distribution zip
if: ${{ matrix.build_type == 'Release' }}
run: |
cmake --build build --target docs
cd build && cpack --config CPackConfig.cmake
- name: Get package name
if: ${{ matrix.build_type == 'Release' }}
run: |
version=$(grep "project(" CMakeLists.txt | cut -d ' ' -f3)
echo "VERSION=$version" >> "$GITHUB_ENV"
- name: Upload rexsapi package
if: ${{ matrix.build_type == 'Release' }}
uses: actions/upload-artifact@v4
with:
name: rexsapi-darwin-${{env.VERSION}}
path: build/rexsapi-darwin-*.zip
build-windows:
name: ${{ matrix.os }} ${{ matrix.build_type }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-2022]
build_type: [Debug, Release]
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: choco install doxygen.install
- name: Configure
run: mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ..
- name: Build
run: cmake --build build --config ${{ matrix.build_type }}
- name: Test
run: cd build && ctest --output-on-failure -C ${{ matrix.build_type }}
- name: Create distribution zip
if: ${{ matrix.build_type == 'Release'}}
run: |
cmake --build build --target docs
cd build
cpack --config CPackConfig.cmake
- name: Get package name
if: ${{ matrix.build_type == 'Release'}}
run: |
import os
import re
p = re.compile(r"project\(rexsapi VERSION (\d+.\d+.\d+) LANGUAGES CXX\)")
env_file = os.getenv('GITHUB_ENV')
entry = "VERSION={}"
with open(env_file, "a") as env:
with open('CMakeLists.txt') as f:
for line in f:
m = p.match(line)
if m:
env.write(entry.format(m.group(1)))
shell: python
- name: Upload rexsapi package
if: ${{ matrix.build_type == 'Release' }}
uses: actions/upload-artifact@v4
with:
name: rexsapi-windows-${{env.VERSION}}
path: build/rexsapi-*.zip
create_release:
permissions: write-all
name: Create release
if: startsWith( github.ref, 'refs/tags/')
runs-on: ubuntu-22.04
needs: [build-linux, build-windows, build-macos]
steps:
- uses: actions/checkout@v4
- name: Extract release notes
id: extract-release-notes
uses: ffurrer2/extract-release-notes@v2
with:
changelog_file: CHANGELOG.md
- name: Get release name
run: |
version=$(grep "project(" CMakeLists.txt | cut -d ' ' -f3)
echo "VERSION=$version" >> "$GITHUB_ENV"
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create release
id: create_release
uses: ncipollo/release-action@v1
with:
name: ${{ github.ref_name }}
body: ${{ steps.extract-release-notes.outputs.release_notes }}
artifacts: "./artifacts/rexsapi-*/rexsapi-*.zip"
removeArtifacts: true