Skip to content

Commit 7085275

Browse files
authored
Add coverage reporting support (#313)
* 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
1 parent d408481 commit 7085275

6 files changed

Lines changed: 67 additions & 25 deletions

File tree

.github/actions/cmake/test/action.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,7 @@ runs:
1010
shell: bash --noprofile --norc -euxo pipefail {0}
1111

1212
- name: Test `mod_tile`
13-
run: ctest -T test
14-
shell: bash --noprofile --norc -euxo pipefail {0}
15-
working-directory: build
16-
17-
- name: Process `mod_tile` coverage results
18-
if: matrix.build_system == 'CMake' && matrix.compiler == 'GNU'
19-
run: ctest -T coverage
20-
shell: bash --noprofile --norc -euxo pipefail {0}
21-
working-directory: build
22-
23-
- name: Retest `mod_tile` on failure
24-
if: failure()
25-
run: ctest --exclude-regex 'clear_dirs|remove_tile' --verbose
13+
run: ctest --exclude-regex 'clear_dirs|remove_tile' --output-on-failure
2614
shell: bash --noprofile --norc -euxo pipefail {0}
2715
working-directory: build
2816

.github/actions/dependencies/install/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ runs:
185185
${{ inputs.ubuntu-test-dependencies }}
186186
${{ matrix.build_system == 'CMake' && 'cmake' || '' }}
187187
${{ matrix.compiler == 'LLVM' && 'clang' || 'g++ gcc' }}
188-
if: startsWith(matrix.image, 'ubuntu:')
188+
if: |
189+
startsWith(matrix.image, 'ubuntu:') ||
190+
(!matrix.image && runner.os == 'Linux')
189191
190192
- name: Build & Install `mapnik` (Amazon Linux 2/CentOS 7)
191193
uses: ./.github/actions/dependencies/build-and-install/mapnik

.github/actions/dependencies/install/apt-get/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ runs:
88
using: composite
99
steps:
1010
- name: Update package information
11-
run: apt-get --yes update
11+
run: ${{ !matrix.image && 'sudo' || '' }} apt-get --yes update
1212
shell: bash --noprofile --norc -euxo pipefail {0}
1313

1414
- name: Install package(s)
1515
env:
1616
DEBIAN_FRONTEND: noninteractive
17-
run: apt-get --yes install ${{ inputs.packages }}
17+
run: ${{ !matrix.image && 'sudo' || '' }} apt-get --yes install ${{ inputs.packages }}
1818
shell: bash --noprofile --norc -euxo pipefail {0}

.github/workflows/coverage.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
name: Coverage
3+
4+
on:
5+
- push
6+
7+
jobs:
8+
Coverage:
9+
name: Build, Test & Report Coverage
10+
runs-on: ubuntu-latest
11+
env:
12+
CFLAGS: --coverage
13+
CXXFLAGS: --coverage
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
18+
- name: Install dependencies
19+
uses: ./.github/actions/dependencies/install
20+
with:
21+
ubuntu-test-dependencies: >-
22+
apache2
23+
lcov
24+
25+
- name: Build `mod_tile`
26+
uses: ./.github/actions/cmake/build
27+
28+
- name: Test `mod_tile`
29+
uses: ./.github/actions/cmake/test
30+
31+
- name: Test `mod_tile` again (to gather more coverage data)
32+
uses: ./.github/actions/cmake/test
33+
34+
- name: Process `mod_tile` coverage results
35+
run: |
36+
ctest -T coverage
37+
lcov \
38+
--capture \
39+
--directory . \
40+
--output-file coverage.info
41+
lcov \
42+
--output-file coverage.info \
43+
--remove coverage.info \
44+
"${GITHUB_WORKSPACE}/includes/catch.hpp" \
45+
"${GITHUB_WORKSPACE}/src/gen_tile_test.cpp" \
46+
"/usr/*"
47+
genhtml coverage.info --output-directory coverage
48+
working-directory: build
49+
50+
- name: Upload `mod_tile` coverage results artifact
51+
uses: actions/upload-artifact@v3
52+
with:
53+
name: Coverage Results
54+
path: build/coverage
55+
56+
- name: Report `mod_tile` coverage results to `codecov.io`
57+
uses: codecov/codecov-action@v3
58+
with:
59+
files: build/coverage.info

.github/workflows/lint.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,17 @@ on:
88
- master
99
- develop
1010

11-
env:
12-
test-dependencies: >-
13-
astyle
14-
1511
jobs:
1612
astyle:
1713
name: Lint with `astyle`
1814
runs-on: ubuntu-latest
19-
container:
20-
image: ubuntu:latest
2115
steps:
2216
- name: Checkout code
2317
uses: actions/checkout@v3
2418
- name: Provision environment
2519
uses: ./.github/actions/dependencies/install/apt-get
2620
with:
27-
packages: >-
28-
${{ env.test-dependencies }}
21+
packages: astyle
2922
- name: Check if any modifications were made by `astyle`
3023
env:
3124
ASTYLE_CMD: >-

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ add_test(
198198
add_test(
199199
NAME stop_renderd
200200
COMMAND ${BASH} -c "
201-
${KILL_EXECUTABLE} $(${CAT_EXECUTABLE} run/renderd.pid) && ${RM} run/renderd.pid
202201
${KILL_EXECUTABLE} $(${CAT_EXECUTABLE} run/renderd1.pid) && ${RM} run/renderd1.pid
202+
${KILL_EXECUTABLE} $(${CAT_EXECUTABLE} run/renderd.pid) && ${RM} run/renderd.pid
203203
"
204204
)
205205
add_test(

0 commit comments

Comments
 (0)