-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from FormingWorlds/coverage
Set up coverage testing
- Loading branch information
Showing
4 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,11 +43,35 @@ jobs: | |
- name: Build JANUS | ||
run: | | ||
pip install -e . | ||
python -m pip install -e .[develop] | ||
- name: Test with pytest | ||
run: | | ||
pip install pytest | ||
export FWL_DATA="./fwl_data" | ||
source SOCRATES/set_rad_env | ||
pytest | ||
coverage run -m pytest | ||
- name: Report coverage | ||
run: | | ||
coverage json | ||
export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])") | ||
echo "total=$TOTAL" >> $GITHUB_ENV | ||
echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY | ||
echo $'\n```' >> $GITHUB_STEP_SUMMARY | ||
coverage report >> $GITHUB_STEP_SUMMARY | ||
echo $'\n```' >> $GITHUB_STEP_SUMMARY | ||
- name: Make coverage badge | ||
if: ${{ github.ref == 'refs/heads/master' && matrix.python-version == '3.10' }} | ||
uses: schneegans/[email protected] | ||
with: | ||
auth: ${{ secrets.GIST_TOKEN }} | ||
gistID: 99391a66bb9229771504c3a4db611d05 | ||
filename: covbadge.svg | ||
label: Coverage | ||
message: ${{ env.total }}% | ||
minColorRange: 50 | ||
maxColorRange: 90 | ||
valColorRange: ${{ env.total }} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Contributing guidelines | ||
|
||
### Running tests | ||
|
||
JANUS uses [pytest](https://docs.pytest.org/en/latest/) to run the tests. You can run the tests for yourself using: | ||
|
||
```console | ||
pytest | ||
``` | ||
|
||
To check coverage: | ||
|
||
```console | ||
coverage run -m pytest | ||
coverage report # to output to terminal | ||
coverage html # to generate html report | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters