Skip to content

Commit

Permalink
Add code coverage to CI (NanoComp#1651)
Browse files Browse the repository at this point in the history
* Add code coverage to CI

* remove ignore from codecov.yml

* misssing brace

* specify source files and show coverage report in output

* remove badge

* fix path of coverage.xml to match git file structure

* show Codecov report in PR
  • Loading branch information
oskooi authored Jul 9, 2021
1 parent 015c80b commit 57f0256
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 3 deletions.
39 changes: 37 additions & 2 deletions .github/workflows/build-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ jobs:
- name: Install Python dependencies
run: pip install -r python/requirements.txt

- name: Install coverage
if: ${{ matrix.enable-mpi == false && matrix.python-version == 3.6 }}
run: pip install coverage==4.5.4

- name: Install mpi4py
if: ${{ matrix.enable-mpi && steps.cache.outputs.cache-hit != true }}
run: pip install mpi4py
Expand All @@ -136,28 +140,59 @@ jobs:
echo "MEEP_VERSION=${MEEP_VERSION}" >> $GITHUB_ENV
- name: Run configure
if: ${{ !(matrix.enable-mpi == false && matrix.python-version == 3.6) }}
run: |
mkdir -p build &&
pushd build &&
../configure --enable-maintainer-mode --prefix=${HOME}/local --with-libctl=${HOME}/local/share/libctl ${MPICONF} &&
popd
- name: Run configure
if: ${{ matrix.enable-mpi == false && matrix.python-version == 3.6 }}
run: ./configure --enable-maintainer-mode --prefix=${HOME}/local --with-libctl=${HOME}/local/share/libctl ${MPICONF}

- name: Run make
if: ${{ matrix.enable-mpi == false && matrix.python-version == 3.6 }}
run: make ${MKCHECKFLAGS}

- name: Run make check
if: ${{ matrix.enable-mpi == false && matrix.python-version == 3.6 }}
run: |
pushd python/ &&
make ${MKCHECKFLAGS} check &&
popd
- name: Run make distcheck
if: ${{ !(matrix.enable-mpi == false && matrix.python-version == 3.6) }}
run: |
pushd build &&
make ${MKCHECKFLAGS} distcheck DISTCHECK_CONFIGURE_FLAGS="--with-libctl=${HOME}/local/share/libctl ${MPICONF}" &&
popd
- name: Generate coverage report
if: ${{ matrix.enable-mpi == false && matrix.python-version == 3.6 }}
run: |
pushd python/ &&
coverage report -i &&
coverage xml -i &&
popd
- name: Upload coverage to Codecov
if: ${{ matrix.enable-mpi == false && matrix.python-version == 3.6 }}
uses: codecov/codecov-action@v1
with:
files: ${{ github.workspace }}/python/coverage.xml

- name: Archive C++ test logs
if: ${{ failure() && !(matrix.enable-mpi == false && matrix.python-version == 3.6) }}
uses: actions/upload-artifact@v2
if: failure()
with:
name: cpp-tests-mpi-${{ matrix.enable-mpi }}-log
path: ${{ github.workspace }}/build/meep-${{ env.MEEP_VERSION }}/_build/sub/tests/test-suite.log

- name: Archive Python test logs
if: ${{ failure() && !(matrix.enable-mpi == false && matrix.python-version == 3.6) }}
uses: actions/upload-artifact@v2
if: failure()
with:
name: py${{ matrix.python-version }}-tests-mpi-${{ matrix.enable-mpi }}-log
path: ${{ github.workspace }}/build/meep-${{ env.MEEP_VERSION }}/_build/sub/python/test-suite.log
14 changes: 14 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
coverage:
status:
project:
default:
informational: true
patch:
default:
informational: true

comment:
layout: "reach, diff, files"

fixes:
- "meep/::python/"
2 changes: 1 addition & 1 deletion python/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ TESTS = \
$(WVG_SRC_TEST)

if WITH_COVERAGE
PY_LOG_COMPILER = coverage run -a --omit=$(top_srcdir)/python/tests/*,${HOME}/virtualenv/*,$(top_srcdir)/python/examples/*
PY_LOG_COMPILER = coverage run -a --source=$(top_srcdir)/python/meep --omit=$(top_srcdir)/python/tests/*,$(top_srcdir)/python/examples/*,$(top_srcdir)/python/meep/materials.py
else
PY_LOG_COMPILER = $(RUNCODE) $(PYTHON)
endif
Expand Down

0 comments on commit 57f0256

Please sign in to comment.