chore: included extensions in pyproject #131
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
name: Build hydrodiy | |
on: [push] | |
jobs: | |
build-linux: | |
runs-on: ubuntu-latest | |
strategy: | |
max-parallel: 5 | |
defaults: | |
run: | |
shell: bash -l {0} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.10' | |
- name: Add conda to system path | |
run: | | |
# $CONDA is an environment variable pointing to the root of the miniconda directory | |
echo $CONDA/bin >> $GITHUB_PATH | |
- name: Create conda environment if needed | |
run: | | |
source $CONDA/etc/profile.d/conda.sh | |
conda env create -f env_hydrodiy.yml | |
- name : Install hydrodiy package in conda env | |
run: | | |
source $CONDA/etc/profile.d/conda.sh | |
conda activate env_hydrodiy | |
pip install -e . | |
- name: Lint with flake8 | |
run: | | |
source $CONDA/etc/profile.d/conda.sh | |
conda activate env_hydrodiy | |
cd $GITHUB_WORKSPACE | |
flake8 --exclude src/hydrodiy/data/tests src/hydrodiy/data | |
flake8 --exclude src/hydrodiy/gis/tests,src/hydrodiy/gis/data src/hydrodiy/gis | |
flake8 --exclude src/hydrodiy/io/tests,src/hydrodiy/io/script_template_plot.py,src/hydrodiy/io/script_template_simple.py src/hydrodiy/io | |
flake8 --exclude src/hydrodiy/plot/tests src/hydrodiy/plot | |
flake8 --exclude src/hydrodiy/stat/tests,src/hydrodiy/stat/data src/hydrodiy/stat | |
- name: Run tests | |
run: | | |
source $CONDA/etc/profile.d/conda.sh | |
conda activate env_hydrodiy | |
pytest --cov=hydrodiy --cov-report=xml --cov-report=html --cov-report=term-missing src/hydrodiy | |
- 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-coverage | |
path: htmlcov/*.* | |
- name: Run examples | |
run: | | |
source $CONDA/etc/profile.d/conda.sh | |
conda activate env_hydrodiy | |
python examples/run_all_examples.py | |