Skip to content

Commit

Permalink
Added actions to test the new C++ code.
Browse files Browse the repository at this point in the history
  • Loading branch information
LTLA committed Nov 15, 2024
1 parent b035035 commit 2114ad9
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/check-install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
on:
push:
branches:
- master
paths-ignore:
- README.md
- 'docs/**'
pull_request:
paths-ignore:
- README.md
- 'docs/**'

name: Check CMake install

jobs:
install:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Get latest CMake
uses: lukka/get-cmake@latest

- name: Configure the build
run: cmake -S . -B build -DGESEL_TESTS=OFF

- name: Install the library
run: sudo cmake --install build

- name: Test downstream usage
run: |
mkdir _downstream
touch _downstream/source.cpp
cat << EOF > _downstream/CMakeLists.txt
cmake_minimum_required(VERSION 3.24)
project(test_install)
add_executable(whee source.cpp)
find_package(gesel_gesel)
target_link_libraries(whee gesel::gesel)
EOF
cd _downstream && cmake -S . -B build
69 changes: 69 additions & 0 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
on:
push:
branches:
- master
paths-ignore:
- README.md
- 'docs/**'
pull_request:
paths-ignore:
- README.md
- 'docs/**'

name: Run unit tests

jobs:
test:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "Ubuntu Latest GCC, coverage enabled",
os: ubuntu-latest,
cov: true
}
- {
name: "macOS Latest Clang",
os: macos-latest
}

steps:
- uses: actions/checkout@v4

- name: Get latest CMake
uses: lukka/get-cmake@latest

- name: Configure the build for Mac
if: ${{ matrix.config.os == 'macos-latest' }}
run: |
cmake -S . -B build
- name: Configure the build with coverage and HDF5
if: ${{ matrix.config.os == 'ubuntu-latest' }}
run: |
cmake -S . -B build -DCODE_COVERAGE=ON
- name: Run the build
run: cmake --build build

- name: Run the tests
run: |
cd build
ctest
- name: Generate code coverage
if: ${{ matrix.config.cov }}
run: |
cd build/tests/CMakeFiles/
find -type f -name "*.gcno" -execdir gcov -abcfu {} +
- name: Upload to Codecov
if: ${{ matrix.config.cov }}
uses: codecov/codecov-action@v5
with:
directory: build/tests/CMakeFiles/
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

0 comments on commit 2114ad9

Please sign in to comment.