8

Measure docstring coverage of Python packages with GitHub Actions

 2 years ago
source link: https://dev.to/epassaro/measure-docstring-coverage-of-python-packages-with-github-actions-1cp8
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
epassaro

Posted on Nov 19

Measure docstring coverage of Python packages with GitHub Actions

My Workflow

Maintainers should enforce collaborators to document their changes.

This workflow fails when the docstring coverage is lower than the score of the base branch (on pull requests) or the previous commit (on push), and files that made the job fail are blamed.

Pushing changes to the main branch should update the current coverage of the project by creating a dynamic badge through the shields.io endpoint.

Also, it's possible to define the range of the badge color based on the coverage results.

Submission Category:

Maintainer Must-Haves

Yaml File or Link to Code

GitHub logo epassaro / docstr-cov-workflow

Measure docstring coverage of Python packages with GitHub Actions

docstr-cov-workflow

Measure docstring coverage of Python packages with GitHub Actions

Usage

  1. Copy .github/workflows/docstr-cov.yml and .docstr.yaml to your repository.
  2. Tweak the configuration file following the package documentation.
  3. Login to https://jsonbin.org and store the API key as a repository secret named JSONBIN_APIKEY.
  4. The workflow will fail if the coverage is lower than the score of the base branch (on pull_request) or the previous commit (on push), and files that made the job fail will be blamed.
  5. Pushing to main branch updates the current coverage of the project by updating a nice badge.
  6. You can change the color range of the badge by tweaking the RANGE variable at the top of the workflow. For example, 50..75 means that coverage below 50 will display a red badge, and above 75 a green one.
  7. Remember to add the badge to your README.md

Example

Make changes to example/base.py and see the workflow…

Additional Resources / Info

An older version of this workflow is currently used by TARDIS-SN, a Montecarlo radiative transfer code that creates synthetic spectra for supernovae.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK