|
6 | 6 | - master |
7 | 7 | pull_request: |
8 | 8 | types: [opened, synchronize, reopened] |
| 9 | + workflow_dispatch: |
9 | 10 |
|
10 | 11 | env: |
11 | | - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) |
12 | 12 | BUILD_TYPE: Release |
13 | 13 |
|
14 | 14 | jobs: |
15 | 15 | build: |
16 | | - # The CMake configure and build commands are platform agnostic and should work equally |
17 | | - # well on Windows or Mac. You can convert this to a matrix build if you need |
18 | | - # cross-platform coverage. |
19 | | - # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix |
20 | 16 | runs-on: ${{ matrix.os }} |
21 | 17 | strategy: |
22 | 18 | matrix: |
|
37 | 33 |
|
38 | 34 | - name: Normalize build type |
39 | 35 | shell: bash |
40 | | - # The build type is Capitalized, e.g. Release, but the preset is all lowercase, e.g. release. |
41 | | - # There is no built in way to do string manipulations on GHA as far as I know.` |
42 | 36 | run: echo "BUILD_TYPE_LOWERCASE=$(echo "${BUILD_TYPE}" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV |
43 | 37 |
|
44 | 38 | - name: Configure CMake |
|
52 | 46 | - name: run test (Linux) |
53 | 47 | run: ctest --test-dir build/${{env.BUILD_TYPE}} |
54 | 48 |
|
| 49 | + coverage: |
| 50 | + runs-on: ubuntu-22.04 |
| 51 | + |
| 52 | + steps: |
| 53 | + - uses: actions/checkout@v6 |
| 54 | + |
| 55 | + - name: Install lcov |
| 56 | + run: sudo apt-get update && sudo apt-get install -y lcov |
| 57 | + |
| 58 | + - name: Install Conan |
| 59 | + id: conan |
| 60 | + uses: turtlebrowser/get-conan@main |
| 61 | + |
| 62 | + - name: Create default profile |
| 63 | + run: conan profile detect |
| 64 | + |
| 65 | + - name: Install conan dependencies |
| 66 | + run: conan install conanfile.py -s build_type=Debug --build=missing |
| 67 | + |
| 68 | + - name: Configure CMake with coverage |
| 69 | + shell: bash |
| 70 | + run: | |
| 71 | + cmake --preset conan-debug \ |
| 72 | + -DCMAKE_C_FLAGS="--coverage" \ |
| 73 | + -DCMAKE_CXX_FLAGS="--coverage" |
| 74 | +
|
| 75 | + - name: Build |
| 76 | + shell: bash |
| 77 | + run: cmake --build --preset conan-debug |
| 78 | + |
| 79 | + - name: Run tests |
| 80 | + run: ctest --test-dir build/Debug --output-on-failure |
| 81 | + |
| 82 | + - name: Collect coverage |
| 83 | + run: | |
| 84 | + lcov --capture --directory build/Debug \ |
| 85 | + --output-file coverage.info \ |
| 86 | + --ignore-errors mismatch |
| 87 | + lcov --remove coverage.info \ |
| 88 | + '/usr/*' \ |
| 89 | + '*/3rdparty/*' \ |
| 90 | + '*/tests/*' \ |
| 91 | + '*/examples/*' \ |
| 92 | + '*/sample_nodes/*' \ |
| 93 | + '*/tools/*' \ |
| 94 | + --output-file coverage.info \ |
| 95 | + --ignore-errors unused |
| 96 | + lcov --list coverage.info |
| 97 | +
|
55 | 98 | - name: Upload coverage reports to Codecov |
56 | 99 | uses: codecov/codecov-action@v5 |
| 100 | + with: |
| 101 | + files: coverage.info |
| 102 | + token: ${{ secrets.CODECOV_TOKEN }} |
0 commit comments