Fix mypy checks #4
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: Cascade Python Package | |
# see https://stackoverflow.com/a/56422603/179520 | |
env: | |
PY_IGNORE_IMPORTMISMATCH: 1 | |
on: [push] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.9, "3.10"] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
# https://docs.github.com/en/actions/guides/building-and-testing-python#caching-dependencies | |
# caching of pip files | |
- name: Cache pip | |
uses: actions/cache@v2 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
${{ runner.os }}- | |
- name: Install project and dependencies | |
run: | | |
python -m pip install --upgrade pip | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
pip install . | |
- name: Lint with flake8 | |
run: | | |
flake8 . | |
- name: Check types with mypy | |
run: | | |
mypy cascade tests docs/examples | |
#- name: Test doctests with pytest | |
# run: | | |
# PYTHONPATH=. pytest --doctest-modules | |
- name: Test with pytest | |
run: | | |
PYTHONPATH=. pytest --doctest-modules --cov cascade --cov-report= tests/ | |
- name: Upload coverage data to coveralls.io | |
run: | | |
coveralls | |
env: | |
COVERALLS_FLAG_NAME: ${{ matrix.test-name }} | |
COVERALLS_PARALLEL: true | |
# get token from https://coveralls.io/github/compassinformatics/cascade | |
# and then add to https://github.com/compassinformatics/cascade/settings/secrets/actions | |
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build wheel and source distributions | |
run: | | |
pip install wheel | |
pip install build | |
python -m build --wheel | |
python -m build --sdist | |
- name: Build docs | |
run: | | |
sphinx-build -b html docs build/html/ | |
- name: Deploy gh-pages | |
uses: peaceiris/actions-gh-pages@v3 | |
if: github.ref == 'refs/heads/main' | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./build/html | |
destination_dir: . | |
- name: Publish package | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
# see https://github.com/marketplace/actions/coveralls-github-action | |
# we can't use coveralls-github-action as it doesn't support xml output | |
# see https://coveralls-python.readthedocs.io/en/latest/usage/configuration.html#github-actions-support | |
coveralls: | |
name: Indicate completion to coveralls.io | |
needs: test | |
runs-on: ubuntu-latest | |
container: python:3-slim | |
steps: | |
- name: Finished | |
run: | | |
pip3 install --upgrade coveralls | |
coveralls --finish | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |