Skip to content

Commit

Permalink
Fix gcov/coveralls submission
Browse files Browse the repository at this point in the history
  • Loading branch information
ludocode committed Jul 14, 2021
1 parent 142047e commit 591ba52
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 13 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/unit.yml
Expand Up @@ -42,6 +42,14 @@ jobs:
if: contains(matrix.cc, 'tcc')
run: sudo apt-get install -y tcc

- name: Install lcov (Ubuntu+gcc)
if: contains(matrix.cc, 'gcc')
run: |
curl -LO https://github.com/linux-test-project/lcov/releases/download/v1.15/lcov-1.15.tar.gz
tar xzf lcov-1.15.tar.gz
cd lcov-1.15
sudo make install
- name: Run ci-unix (Ubuntu, macOS)
if: ${{ !contains(matrix.os, 'windows') }}
run: test/unit/ci-unix.sh
Expand All @@ -52,3 +60,14 @@ jobs:
if: contains(matrix.os, 'windows')
shell: cmd
run: test\\unit\\ci-windows.bat

- name: Submit coverage to Coveralls
id: coverage
if: contains(matrix.cc, 'gcc')
uses: coverallsapp/github-action@1.1.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Print Coveralls submission result
if: contains(matrix.cc, 'gcc')
run: echo ${{ steps.coverage.outputs['coveralls-api-result'] }}
16 changes: 7 additions & 9 deletions test/unit/ci-unix.sh
Expand Up @@ -27,15 +27,13 @@ if [[ "$CC" == "scan-build" ]]; then
exit $?
fi

if [ "$CC" = "gcov" ]; then
# Run the "more" variant of unit tests
tools/unit.sh more

if [ "$CC" = "gcc" ]; then
# Collect coverage info.
# This is submitted to Coveralls as a separate GitHub Action.
unset CC
unset CXX
tools/gcov.sh
pip install --user idna==2.5 # below packages conflict with idna-2.6 (not sure if this is still necessary on bionic)
pip install --user cpp-coveralls urllib3[secure]
coveralls --no-gcov --include src
exit $?
tools/coverage.sh
fi

# Run the "more" variant of unit tests
tools/unit.sh more
21 changes: 21 additions & 0 deletions tools/coverage.sh
@@ -0,0 +1,21 @@
#!/bin/sh
set -e

# run unit tests with coverage
tools/unit.sh run-coverage

# run gcov for traditional text-based coverage output
rm -rf coverage
mkdir -p coverage
gcov --object-directory test/.build/coverage/objs/src/mpack `find src -name '*.c'` || exit $?
mv *.gcov coverage

# run lcov
lcov --capture --directory test/.build/coverage/objs/src --output-file coverage/lcov.info

# generate HTML coverage
genhtml coverage/lcov.info --output-directory coverage/html

echo
echo "Done. Results written in coverage/"
echo "View HTML results in: file://$(pwd)/coverage/index.html"
4 changes: 0 additions & 4 deletions tools/gcov.sh

This file was deleted.

0 comments on commit 591ba52

Please sign in to comment.