Skip to content

Commit

Permalink
Added test workflow to ensure package is installable through pip
Browse files Browse the repository at this point in the history
  • Loading branch information
jreniel committed Feb 23, 2021
1 parent 054b15c commit 8c61496
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 2 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: tests

on: [ push ]

jobs:
tests:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version: [ 3.6, 3.7, 3.8 ]

steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Restore cached dependencies
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
restore-keys: ${{ runner.os }}-pip-${{ matrix.python-version }}-
- name: Install dependencies
run: |
apt-get update -y && apt-get install -y libnetcdf-dev libnetcdff-dev udunits-bin
pip install wheel
pip install -e ".[dev]"
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
# - name: Test with coverage
# run: coverage run --source pyschism -m nose --nologcapture --verbose
# - name: Generate coverage report
# run: coverage report -m
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ build/
dist/
*.egg*
__pycache__
*_env

12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
default: error

coverage:
@coverage run --source pyschism -m nose --rednose --nologcapture --verbose && coverage report -m && coverage-badge -f -o tests/coverage.svg && rm -rf .coverage

badge:
@$(shell git diff --exit-code -s tests/coverage.svg)
@if ! [ $(.SHELLSTATUS) = 0 ]; then git add tests/coverage.svg && git commit -m "Updated coverage badge."; fi

error:
@echo -e "ERROR: Argument required."
@exit 2
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ hgrid.write("/path/to/output/file.2dm", fmt='2dm')
```
---
Questions, comments and suggestions are welcome. Please follow the instructions on the `CONTRIBUTING.md` file for contributions. For bug reports and feature requests, please open an issue using the issue tracker.
Author contact: Jaime.Calzada@noaa.gov
Author contact: jrcalzada@wm.edu

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
long_description_content_type="text/markdown",
url=meta['url'],
packages=setuptools.find_packages(),
python_requires='>=3.6, <=3.8',
python_requires='>=3.6, <3.9',
setup_requires=['wheel', 'setuptools_scm', 'setuptools>=41.2'],
include_package_data=True,
extras_require={'dev': ['coverage', 'flake8', 'nose']},
Expand Down

0 comments on commit 8c61496

Please sign in to comment.