Skip to content

Commit 3993b98

Browse files
committed
Add coverage report to actions
Modify Coverage.py calls for ubuntu. Signed-off-by: Henry Cox <[email protected]>
1 parent 5bdf2f5 commit 3993b98

File tree

5 files changed

+92
-11
lines changed

5 files changed

+92
-11
lines changed

.github/workflows/run_test_suite.yml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,38 @@ jobs:
9090
path: tests/test.log
9191
if-no-files-found: error
9292

93-
- name: Upload test directory shrapnel as an artifact
93+
- name: Upload test directory shrapnel as an artifact
9494
uses: actions/upload-artifact@v4
9595
with:
9696
name: "lcov-${{ github.sha }}-${{ runner.os }}-shrapnel" # .zip
9797
path: tests
9898
#if-no-files-found: error
99+
100+
- name: coverage build
101+
run: |-
102+
set -x -o pipefail
103+
COVERAGE_COMMAND=python3-coverage make COVERAGE=1 check
104+
105+
- name: Upload coverage report as an artifact
106+
uses: actions/upload-artifact@v4
107+
with:
108+
name: "lcov-${{ github.sha }}-${{ runner.os }}-coverage" # .zip
109+
path: lcov_coverage
110+
#if-no-files-found: error
111+
112+
- name: Upload coverage directory (static HTML)
113+
id: deployment
114+
uses: actions/upload-pages-artifact@v1
115+
with:
116+
path: lcov_coverage
117+
118+
deploy:
119+
environment:
120+
name: github-pages
121+
url: ${{ steps.deployment.outputs.page_url }}
122+
runs-on: ubuntu-24.04
123+
needs: test_suite
124+
steps:
125+
- name: Deploy to GitHub Pages
126+
id: deployment
127+
uses: actions/deploy-pages@v4

tests/common.mak

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ endif
3939
ifneq ($(COVER_DB),)
4040
export PERL_COVER_ARGS := -MDevel::Cover=-db,$(COVER_DB),-coverage,statement,branch,condition,subroutine,-silent,1
4141
EXEC_COVER := perl ${PERL_COVER_ARGS}
42-
PYCOVER = COVERAGE_FILE=$(PYCOV_DB) coverage run --branch --append
42+
export COVERAGE_COMMAND = $(shell which coverage 2>&1 > /dev/null ; if [ 0 -eq $$? ] ; then echo coverage ; else echo python3-coverage ; fi )
43+
PYCOVER = COVERAGE_FILE=$(PYCOV_DB) ${COVERAGE_COMMAND} run --branch --append
44+
#$(warning assigned PYCOVER='$(PYCOVER)')
4345
endif
4446

45-
4647
export TOPDIR TESTDIR
4748
export PARENTDIR := $(dir $(patsubst %/,%,$(TOPDIR)))
4849
export RELDIR := $(TESTDIR:$(PARENTDIR)%=%)

tests/gendiffcov/simple/script.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,24 @@ while [ $# -gt 0 ] ; do
3939
fi
4040
export PYCOV_DB="${COVER_DB}_py"
4141
COVER="perl -MDevel::Cover=-db,${COVER_DB},-coverage,statement,branch,condition,subroutine,-silent,1 "
42-
PYCOVER="COVERAGE_FILE=$PYCOV_DB coverage run --branch --append"
42+
43+
if [ '' != "${COVERAGE_COMMAND}" ] ; then
44+
CMD=${COVERAGE_COMMAND}
45+
else
46+
CMD='coverage'
47+
which $CMD
48+
if [ 0 != $? ] ; then
49+
CMD='python3-coverage' # ubuntu?
50+
fi
51+
fi
52+
which $CMD
53+
if [ 0 != $? ] ; then
54+
echo "cannot find 'coverage' or 'python3-coverage'"
55+
echo "unable to run py2lcov - please install python Coverage.py package"
56+
exit 1
57+
fi
58+
59+
PYCOVER="COVERAGE_FILE=$PYCOV_DB $CMD run --branch --append"
4360
;;
4461

4562
--home | -home )

tests/py2lcov/py2lcov.sh

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,22 @@ while [ $# -gt 0 ] ; do
4040
shift
4141
fi
4242
COVER="perl -MDevel::Cover=-db,${COVER_DB},-coverage,statement,branch,condition,subroutine,-silent,1 "
43-
PYCOV="COVERAGE_FILE=${PYCOV_DB} coverage run --branch --append"
43+
if [ '' != "${COVERAGE_COMMAND}" ] ; then
44+
CMD=${COVERAGE_COMMAND}
45+
else
46+
CMD='coverage'
47+
which $CMD
48+
if [ 0 != $? ] ; then
49+
CMD='python3-coverage' # ubuntu?
50+
fi
51+
fi
52+
which $CMD
53+
if [ 0 != $? ] ; then
54+
echo "cannot find 'coverage' or 'python3-coverage'"
55+
echo "unable to run py2lcov - please install python Coverage.py package"
56+
exit 1
57+
fi
58+
PYCOV="COVERAGE_FILE=${PYCOV_DB} $CMD run --branch --append"
4459
#PYCOV="coverage run --data-file=${PYCOV_DB} --branch --append"
4560
;;
4661

@@ -141,10 +156,14 @@ if [[ 1 == $CLEAN_ONLY ]] ; then
141156
exit 0
142157
fi
143158

144-
CMD='coverage'
145-
which $CMD
146-
if [ 0 != $? ] ; then
147-
CMD='python3-coverage' # ubuntu?
159+
if [ '' != "${COVERAGE_COMMAND}" ] ; then
160+
CMD=${COVERAGE_COMMAND}
161+
else
162+
CMD='coverage'
163+
which $CMD
164+
if [ 0 != $? ] ; then
165+
CMD='python3-coverage' # ubuntu?
166+
fi
148167
fi
149168
which $CMD
150169
if [ 0 != $? ] ; then
@@ -161,7 +180,7 @@ if [ 0 != $? ] ; then
161180
exit 1
162181
fi
163182
fi
164-
eval ${PYCOV} ${PY2LCOV_TOOL} -o functions.info --cmd $CMD functions.dat $VERSION
183+
eval COVERAGE_COMMAND=$CMD ${PYCOV} ${PY2LCOV_TOOL} -o functions.info --cmd $CMD functions.dat $VERSION
165184
if [ 0 != $? ] ; then
166185
echo "py2lcov failed function example"
167186
if [ 0 == $KEEP_GOING ] ; then

tests/xml2lcov/xml2lcov.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,22 @@ while [ $# -gt 0 ] ; do
4040
shift
4141
fi
4242
COVER="perl -MDevel::Cover=-db,${COVER_DB},-coverage,statement,branch,condition,subroutine,-silent,1 "
43-
PYCOV="COVERAGE_FILE=${PYCOV_DB} coverage run --branch --append"
43+
if [ '' != "${COVERAGE_COMMAND}" ] ; then
44+
CMD=${COVERAGE_COMMAND}
45+
else
46+
CMD='coverage'
47+
which $CMD
48+
if [ 0 != $? ] ; then
49+
CMD='python3-coverage' # ubuntu?
50+
fi
51+
fi
52+
which $CMD
53+
if [ 0 != $? ] ; then
54+
echo "cannot find 'coverage' or 'python3-coverage'"
55+
echo "unable to run py2lcov - please install python Coverage.py package"
56+
exit 1
57+
fi
58+
PYCOV="COVERAGE_FILE=${PYCOV_DB} $CMD run --branch --append"
4459
#PYCOV="coverage run --data-file=${PYCOV_DB} --branch --append"
4560
;;
4661

0 commit comments

Comments
 (0)