Skip to content

Commit

Permalink
Merge pull request #40 from FormingWorlds/coverage
Browse files Browse the repository at this point in the history
Set up coverage testing
  • Loading branch information
stefsmeets authored Jul 23, 2024
2 parents 0cac47a + 943d161 commit b7e357f
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 3 deletions.
30 changes: 27 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}


17 changes: 17 additions & 0 deletions CONTRIBUTING.md
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
```
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
![Coverage](https://gist.githubusercontent.com/stefsmeets/99391a66bb9229771504c3a4db611d05/raw/covbadge.svg)

## JANUS (1D convective atmosphere model)

Generates a temperature profile using the generalised moist pseudoadiabat and a prescribed stratosphere. Calculates radiative fluxes using SOCRATES.
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ homepage = "https://github.com/FormingWorlds/JANUS"
[project.optional-dependencies]
develop = [
"bump-my-version",
"coverage[toml]",
"pytest"
]
publishing = [
Expand All @@ -59,6 +60,10 @@ publishing = [
package-dir = {"janus" = "src/janus"}
include-package-data = true

[tool.coverage.run]
branch = true
source = ["janus"]

[tool.pytest.ini_options]
testpaths = ["tests"]

Expand Down

0 comments on commit b7e357f

Please sign in to comment.