From 006498b03b2f60140a44a729d7033ad501e28e16 Mon Sep 17 00:00:00 2001 From: Ardavan Oskooi Date: Fri, 9 Jul 2021 07:22:56 -0700 Subject: [PATCH] Add code coverage to CI (#1651) * 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 --- .github/workflows/build-ci.yml | 39 ++++++++++++++++++++++++++++++++-- codecov.yml | 14 ++++++++++++ python/Makefile.am | 2 +- 3 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 codecov.yml diff --git a/.github/workflows/build-ci.yml b/.github/workflows/build-ci.yml index 51753aa09..246e295de 100644 --- a/.github/workflows/build-ci.yml +++ b/.github/workflows/build-ci.yml @@ -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 @@ -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 diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 000000000..26c20c6ed --- /dev/null +++ b/codecov.yml @@ -0,0 +1,14 @@ +coverage: + status: + project: + default: + informational: true + patch: + default: + informational: true + +comment: + layout: "reach, diff, files" + +fixes: + - "meep/::python/" diff --git a/python/Makefile.am b/python/Makefile.am index 0cd832c63..1870a70ef 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -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