Skip to content

Commit

Permalink
Add coverage reporting support (#313)
Browse files Browse the repository at this point in the history
* Add coverage reporting

* No longer need to run `astyle` from within a container

* Multiple test runs seems to help catch more coverage

* Re-order renderd shutdown processes

* Move coverage job into a new workflow
  • Loading branch information
hummeltech authored Jul 20, 2023
1 parent d408481 commit 7085275
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 25 deletions.
14 changes: 1 addition & 13 deletions .github/actions/cmake/test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,7 @@ runs:
shell: bash --noprofile --norc -euxo pipefail {0}

- name: Test `mod_tile`
run: ctest -T test
shell: bash --noprofile --norc -euxo pipefail {0}
working-directory: build

- name: Process `mod_tile` coverage results
if: matrix.build_system == 'CMake' && matrix.compiler == 'GNU'
run: ctest -T coverage
shell: bash --noprofile --norc -euxo pipefail {0}
working-directory: build

- name: Retest `mod_tile` on failure
if: failure()
run: ctest --exclude-regex 'clear_dirs|remove_tile' --verbose
run: ctest --exclude-regex 'clear_dirs|remove_tile' --output-on-failure
shell: bash --noprofile --norc -euxo pipefail {0}
working-directory: build

Expand Down
4 changes: 3 additions & 1 deletion .github/actions/dependencies/install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ runs:
${{ inputs.ubuntu-test-dependencies }}
${{ matrix.build_system == 'CMake' && 'cmake' || '' }}
${{ matrix.compiler == 'LLVM' && 'clang' || 'g++ gcc' }}
if: startsWith(matrix.image, 'ubuntu:')
if: |
startsWith(matrix.image, 'ubuntu:') ||
(!matrix.image && runner.os == 'Linux')
- name: Build & Install `mapnik` (Amazon Linux 2/CentOS 7)
uses: ./.github/actions/dependencies/build-and-install/mapnik
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/dependencies/install/apt-get/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ runs:
using: composite
steps:
- name: Update package information
run: apt-get --yes update
run: ${{ !matrix.image && 'sudo' || '' }} apt-get --yes update
shell: bash --noprofile --norc -euxo pipefail {0}

- name: Install package(s)
env:
DEBIAN_FRONTEND: noninteractive
run: apt-get --yes install ${{ inputs.packages }}
run: ${{ !matrix.image && 'sudo' || '' }} apt-get --yes install ${{ inputs.packages }}
shell: bash --noprofile --norc -euxo pipefail {0}
59 changes: 59 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
name: Coverage

on:
- push

jobs:
Coverage:
name: Build, Test & Report Coverage
runs-on: ubuntu-latest
env:
CFLAGS: --coverage
CXXFLAGS: --coverage
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install dependencies
uses: ./.github/actions/dependencies/install
with:
ubuntu-test-dependencies: >-
apache2
lcov
- name: Build `mod_tile`
uses: ./.github/actions/cmake/build

- name: Test `mod_tile`
uses: ./.github/actions/cmake/test

- name: Test `mod_tile` again (to gather more coverage data)
uses: ./.github/actions/cmake/test

- name: Process `mod_tile` coverage results
run: |
ctest -T coverage
lcov \
--capture \
--directory . \
--output-file coverage.info
lcov \
--output-file coverage.info \
--remove coverage.info \
"${GITHUB_WORKSPACE}/includes/catch.hpp" \
"${GITHUB_WORKSPACE}/src/gen_tile_test.cpp" \
"/usr/*"
genhtml coverage.info --output-directory coverage
working-directory: build

- name: Upload `mod_tile` coverage results artifact
uses: actions/upload-artifact@v3
with:
name: Coverage Results
path: build/coverage

- name: Report `mod_tile` coverage results to `codecov.io`
uses: codecov/codecov-action@v3
with:
files: build/coverage.info
9 changes: 1 addition & 8 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,17 @@ on:
- master
- develop

env:
test-dependencies: >-
astyle
jobs:
astyle:
name: Lint with `astyle`
runs-on: ubuntu-latest
container:
image: ubuntu:latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Provision environment
uses: ./.github/actions/dependencies/install/apt-get
with:
packages: >-
${{ env.test-dependencies }}
packages: astyle
- name: Check if any modifications were made by `astyle`
env:
ASTYLE_CMD: >-
Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ add_test(
add_test(
NAME stop_renderd
COMMAND ${BASH} -c "
${KILL_EXECUTABLE} $(${CAT_EXECUTABLE} run/renderd.pid) && ${RM} run/renderd.pid
${KILL_EXECUTABLE} $(${CAT_EXECUTABLE} run/renderd1.pid) && ${RM} run/renderd1.pid
${KILL_EXECUTABLE} $(${CAT_EXECUTABLE} run/renderd.pid) && ${RM} run/renderd.pid
"
)
add_test(
Expand Down

0 comments on commit 7085275

Please sign in to comment.