Skip to content

Commit

Permalink
ci: coverage workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
alandefreitas committed Oct 17, 2024
1 parent 8d8a007 commit 543ec61
Showing 1 changed file with 45 additions and 8 deletions.
53 changes: 45 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
standards: '20'
latest-factors: |
msvc Optimized-Debug
gcc Coverage
factors: ''
runs-on: |
apple-clang: macos-15
Expand All @@ -56,6 +57,7 @@ jobs:
msvc Optimized-Debug: /Ob1 /O2 /Zi
install: |
gcc: git build-essential pkg-config python3 curl openjdk-11-jdk pkg-config libncurses-dev libxml2-utils libxml2-dev
gcc Coverage: git build-essential pkg-config python3 curl openjdk-11-jdk pkg-config libncurses-dev libxml2-utils libxml2-dev lcov
clang: git build-essential pkg-config python3 curl openjdk-11-jdk pkg-config libncurses-dev libxml2-utils libxml2-dev
msvc: ''
extra-values: |
Expand Down Expand Up @@ -404,13 +406,48 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Codecov
if: ${{ matrix.coverage }}
uses: codecov/[email protected]
with:
directory: './build'
fail_ci_if_error: true
gcov: true
verbose: true
if: matrix.coverage
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: |
set -x
if [ -z "$CODECOV_TOKEN" ]; then
echo "CODECOV_TOKEN is not set. Skipping coverage report."
exit 0
fi
# Find gcov
gcov_tool="gcov"
for version in "${{steps.setup-cpp.outputs.version-major}}.${{steps.setup-cpp.outputs.version-minor}}" "${{steps.setup-cpp.outputs.version-major}}"; do
if command -v "gcov-$version" &> /dev/null; then
gcov_tool="gcov-$version"
break
fi
done
for dir in "./build"; do
# Generate reports
echo "Generate report: $dir"
lcov --rc lcov_branch_coverage=0 --gcov-tool "$gcov_tool" --directory "$dir" --capture --output-file "$dir/all.info"
lcov --rc lcov_branch_coverage=0 --list "$dir/all.info"
# Upload to codecov
echo "Upload to codecov: $dir"
bash <(curl -s https://codecov.io/bash) -f "$dir/all.info"
done
# Summary
echo "# Coverage" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "[![codecov](https://codecov.io/github/$GITHUB_REPOSITORY/commit/$GITHUB_SHA/graphs/sunburst.svg)](https://codecov.io/github/$GITHUB_REPOSITORY/commit/$GITHUB_SHA)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Commit: [![codecov](https://codecov.io/github/$GITHUB_REPOSITORY/commit/$GITHUB_SHA/graph/badge.svg)](https://codecov.io/github/$GITHUB_REPOSITORY/commit/$GITHUB_SHA)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Branch: [![codecov](https://codecov.io/github/$GITHUB_REPOSITORY/branch/$GITHUB_REF_NAME/graph/badge.svg)](https://codecov.io/github/$GITHUB_REPOSITORY/commit/$GITHUB_SHA)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
releases:
needs: [ cpp-matrix, build ]
Expand Down Expand Up @@ -764,7 +801,7 @@ jobs:
uses: alandefreitas/cpp-actions/[email protected]
id: package-install
with:
apt-get: build-essential asciidoctor cmake bzip2 git curl
apt-get: ${{ matrix.install }}

- name: Check website releases
id: website-releases
Expand Down

0 comments on commit 543ec61

Please sign in to comment.