Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code coverage to CI #1651

Merged
merged 7 commits into from
Jul 9, 2021
Merged

Add code coverage to CI #1651

merged 7 commits into from
Jul 9, 2021

Conversation

oskooi
Copy link
Collaborator

@oskooi oskooi commented Jul 1, 2021

Adds code coverage using Coverage.py to the CI via CodeCov. Setting this up requires activating CodeCov for the NanoComp organization on GitHub (the link to the badge will also need to be updated). Coverage is only run for serial Python 3.6. This setup is similar to the previous coveralls feature added in #550.

See this link for a sample of what the output looks like. The current coverage for the entire Python API is 65.66%. For a breakdown by file for just the adjoint-solver module, see here.

@oskooi
Copy link
Collaborator Author

oskooi commented Jul 4, 2021

I modified the coverage to collect statistics only for the files in the python directory since previously statistics for other Python modules including NumPy, etc. were being shown. Also, for some reason, the coverage report that was being uploaded to CodeCov from GitHub Actions was only displaying statistics for the python/adjoint subdirectory and skipping the python directory containing simulation.py, source.py, geom.py, etc. I was not able to resolve this by either modifying the settings in codecov.yml or removing this file completely in order to force CodeCov to use the default values. As a workaround, I just included the coverage report as part of the output:

Name                                   Stmts   Miss  Cover
----------------------------------------------------------
meep/__init__.py                        2719    919    66%
meep/adjoint/__init__.py                  10      2    80%
meep/adjoint/basis.py                    121    102    16%
meep/adjoint/filter_source.py             68     10    85%
meep/adjoint/filters.py                  163     82    50%
meep/adjoint/objective.py                160     40    75%
meep/adjoint/optimization_problem.py     261     80    69%
meep/adjoint/utils.py                     61      4    93%
meep/adjoint/wrapper.py                  117     10    91%
meep/geom.py                             582     35    94%
meep/materials.py                        694      0   100%
meep/mpb/__init__.py                     245     40    84%
meep/mpb/mpb_data.py                     179     12    93%
meep/mpb/solver.py                       827     79    90%
meep/simulation.py                      2228    519    77%
meep/source.py                           131     10    92%
meep/verbosity_mgr.py                     60     14    77%
meep/visualization.py                    526    280    47%
----------------------------------------------------------
TOTAL                                   9152   2238    76%

Not sure why the materials library in materials.py is showing 100% coverage. Perhaps we should just remove this file?

@stevengj
Copy link
Collaborator

stevengj commented Jul 7, 2021

This feature seems mostly useful if it is integrated with the PRs (so that CodeCov posts the coverage info to the PR) — if the result is just part of the CI output then I'm worried no one will look at it.

@codecov-commenter
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@3936d35). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1651   +/-   ##
=========================================
  Coverage          ?   73.52%           
=========================================
  Files             ?       13           
  Lines             ?     4488           
  Branches          ?        0           
=========================================
  Hits              ?     3300           
  Misses            ?     1188           
  Partials          ?        0           

@oskooi
Copy link
Collaborator Author

oskooi commented Jul 9, 2021

The coverage report from Codecov for the commit is now being displayed as a comment in the PR. We can make additional customizations as described here. The full report now includes the files in the base directory python/as well as those in python/adjoint/.

@stevengj stevengj merged commit efefa01 into NanoComp:master Jul 9, 2021
@oskooi oskooi deleted the ci_codecov branch July 9, 2021 15:07
bencbartlett pushed a commit to bencbartlett/meep that referenced this pull request Sep 9, 2021
* 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
mawc2019 pushed a commit to mawc2019/meep that referenced this pull request Nov 3, 2021
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants