From 2a52317321e2948f57c793a22e7992260150dcb2 Mon Sep 17 00:00:00 2001 From: Mitya Selivanov <0x7fffff@guattari.ru> Date: Sun, 21 Aug 2022 18:31:23 +0400 Subject: Separate code coverage reporting to another CI script --- .github/workflows/build_and_test.yml | 40 ------------------ .github/workflows/code_coverage.yml | 82 ++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/code_coverage.yml diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 040efe4..c4fd60d 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -23,18 +23,6 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Install gcovr - if: runner.os != 'Windows' - run: | - python3 -m pip install gcovr==5.0 - - - name: Install OpenCppCoverage - if: runner.os == 'Windows' - shell: bash - run: | - choco install opencppcoverage - echo "C:/Program Files/OpenCppCoverage" >> $GITHUB_PATH - - name: Build if: runner.os != 'Windows' run: | @@ -49,38 +37,10 @@ jobs: cmake --build build --config $BUILD_TYPE - name: Run tests - if: runner.os != 'Windows' working-directory: ${{ github.workspace }}/build run: | ctest -V -C $BUILD_TYPE - - name: Generate coverage on Linux - if: runner.os == 'Linux' - working-directory: ${{ github.workspace }}/build - run: | - gcovr -j $(nproc) --delete --root ../source/ --exclude '\.\./source/test/' --print-summary --xml-pretty --xml coverage.xml . - - - name: Generate coverage on macOS - if: runner.os == 'macOS' - working-directory: ${{ github.workspace }}/build - run: | - gcovr -j 2 --delete --root ../source/ --exclude '\.\./source/test/' --print-summary --xml-pretty --xml coverage.xml . - - - name: Run tests & generate coverage on Windows - if: runner.os == 'Windows' - shell: bash - working-directory: ${{ github.workspace }}/build - run: | - OpenCppCoverage.exe --sources source\\* --excluded_sources source\\test\\* --export_type cobertura:coverage.xml --cover_children -- ctest -V -C $BUILD_TYPE - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v2 - with: - files: ./build/coverage.xml - flags: ${{ runner.os }} - name: ${{ runner.os }} build - fail_ci_if_error: false - integration: strategy: matrix: diff --git a/.github/workflows/code_coverage.yml b/.github/workflows/code_coverage.yml new file mode 100644 index 0000000..5c84fb5 --- /dev/null +++ b/.github/workflows/code_coverage.yml @@ -0,0 +1,82 @@ +name: Code coverage + +on: + push: + branches: [ stable ] + pull_request: + branches: [ stable ] + schedule: + - cron: '0 0 */16 * *' + workflow_dispatch: + +env: + BUILD_TYPE: Debug + +jobs: + build: + strategy: + matrix: + os: [ ubuntu-latest, macos-latest, windows-2019 ] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v2 + + - name: Install gcovr + if: runner.os != 'Windows' + run: | + python3 -m pip install gcovr==5.0 + + - name: Install OpenCppCoverage + if: runner.os == 'Windows' + shell: bash + run: | + choco install opencppcoverage + echo "C:/Program Files/OpenCppCoverage" >> $GITHUB_PATH + + - name: Build + if: runner.os != 'Windows' + run: | + cmake -D CMAKE_BUILD_TYPE=$BUILD_TYPE -B build -S . + cmake --build build --config $BUILD_TYPE + + - name: Build with Visual Studio + if: runner.os == 'Windows' + shell: bash + run: | + cmake -B build -S . + cmake --build build --config $BUILD_TYPE + + - name: Run tests + if: runner.os != 'Windows' + working-directory: ${{ github.workspace }}/build + run: | + ctest -V -C $BUILD_TYPE + + - name: Generate coverage on Linux + if: runner.os == 'Linux' + working-directory: ${{ github.workspace }}/build + run: | + gcovr -j $(nproc) --delete --root ../source/ --exclude '\.\./source/test/' --print-summary --xml-pretty --xml coverage.xml . + + - name: Generate coverage on macOS + if: runner.os == 'macOS' + working-directory: ${{ github.workspace }}/build + run: | + gcovr -j 2 --delete --root ../source/ --exclude '\.\./source/test/' --print-summary --xml-pretty --xml coverage.xml . + + - name: Run tests & generate coverage on Windows + if: runner.os == 'Windows' + shell: bash + working-directory: ${{ github.workspace }}/build + run: | + OpenCppCoverage.exe --sources source\\* --excluded_sources source\\test\\* --export_type cobertura:coverage.xml --cover_children -- ctest -V -C $BUILD_TYPE + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 + with: + files: ./build/coverage.xml + flags: ${{ runner.os }} + name: ${{ runner.os }} build + fail_ci_if_error: false -- cgit v1.2.3