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

Feature/covbadge #35

Merged
merged 6 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,28 @@ jobs:
run: |
source $CONDA/etc/profile.d/conda.sh
conda activate env_hydrodiy
pytest --cov=hydrodiy --cov-config=.coveragerc --junitxml=junit/test-results.xml --cov-report=xml --cov-report=html src/hydrodiy
pytest --cov=hydrodiy --cov-report=xml --cov-report=html --cov-report=term-missing src/hydrodiy

- name: Upload pytest test results
uses: actions/upload-artifact@v3
- name: Parse coverage report and create badge
run: |
source $CONDA/etc/profile.d/conda.sh
conda activate env_hydrodiy
python -c "import xml.etree.ElementTree as ET; from anybadge import Badge; cov = float(ET.parse('coverage.xml').getroot().get('line-rate')) * 100; covbadge = Badge('Coverage', value=f'{cov:0.0f}%', thresholds={60:'red', 70:'orange', 80:'lightgreen', 90:'green'}); covbadge.write_badge('coverage_badge.svg', True)"

- name: Update gist badge
run: |
sed 's/\"/\\\"/g' coverage_badge.svg > coverage_badge.txt
echo "{\"files\": {\"coverage_badge.svg\": {\"content\": \"$(cat coverage_badge.txt)\"}}}" > coverage_badge.json
curl -X PATCH -H "Authorization: token ${{ secrets.COVERAGE_GIST_TOKEN }}" \
-d @coverage_badge.json \
"https://api.github.com/gists/${{ secrets.COVERAGE_GIST_ID }}"

- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: pytest-results
path: junit/test-results.xml

# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
name: pytest-coverage
path: htmlcov/*.*

- name: Upload to codecov
uses: codecov/codecov-action@v3

- name: Run examples
run: |
source $CONDA/etc/profile.d/conda.sh
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# hydrodiy
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10065114.svg)](https://doi.org/10.5281/zenodo.10065114) [![CI](https://github.com/csiro-hydroinformatics/hydrodiy/actions/workflows/python-package-conda.yml/badge.svg)](https://github.com/csiro-hydroinformatics/hydrodiy/actions/workflows/python-package-conda.yml) [![codecov](https://codecov.io/gh/csiro-hydroinformatics/hydrodiy/graph/badge.svg?token=ARBFW69TI3)](https://codecov.io/gh/csiro-hydroinformatics/hydrodiy)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.14460151.svg)](https://doi.org/10.5281/zenodo.14460151)
[![CI](https://github.com/csiro-hydroinformatics/hydrodiy/actions/workflows/python-package-conda.yml/badge.svg)](https://github.com/csiro-hydroinformatics/hydrodiy/actions/workflows/python-package-conda.yml)
![Coverage](https://gist.githubusercontent.com/jlerat/47c5eaf5c4ac8375b92a548c057d5c24/raw/coverage_badge.svg)


Python toolbox for hydrological data processing.

Expand Down
1 change: 1 addition & 0 deletions env_hydrodiy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ channels:
- conda-forge
- defaults
dependencies:
- anybadge
- cython=3.0.10
- flake8=7.1.1
- matplotlib=3.8.4
Expand Down