From 708527591a7134dcef97cb0350778182fc872e35 Mon Sep 17 00:00:00 2001 From: Hummeltech <6109326+hummeltech@users.noreply.github.com> Date: Thu, 20 Jul 2023 02:28:53 -0700 Subject: [PATCH] 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 --- .github/actions/cmake/test/action.yml | 14 +---- .../actions/dependencies/install/action.yml | 4 +- .../dependencies/install/apt-get/action.yml | 4 +- .github/workflows/coverage.yml | 59 +++++++++++++++++++ .github/workflows/lint.yml | 9 +-- tests/CMakeLists.txt | 2 +- 6 files changed, 67 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/actions/cmake/test/action.yml b/.github/actions/cmake/test/action.yml index 30dbdee3..6711f4cb 100644 --- a/.github/actions/cmake/test/action.yml +++ b/.github/actions/cmake/test/action.yml @@ -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 diff --git a/.github/actions/dependencies/install/action.yml b/.github/actions/dependencies/install/action.yml index a833679e..10e4ebc8 100644 --- a/.github/actions/dependencies/install/action.yml +++ b/.github/actions/dependencies/install/action.yml @@ -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 diff --git a/.github/actions/dependencies/install/apt-get/action.yml b/.github/actions/dependencies/install/apt-get/action.yml index a0c8d223..a5b3917b 100644 --- a/.github/actions/dependencies/install/apt-get/action.yml +++ b/.github/actions/dependencies/install/apt-get/action.yml @@ -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} diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 00000000..afadb466 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -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 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index db59e7fe..dea0466b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -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: >- diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 560e868e..9ce53965 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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(