.github/workflows/pythonpackage.yml
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Python package
on:
push:
pull_request:
schedule:
- cron: '37 11 * * 5'
jobs:
build-n-publish:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# see setup.py for supported versions
# here instead of having a matrix
# we only test combinations in a round-robin fashion
# make sure the versions are monotmonic increasing w.r.t. each other
# other wise e.g. an older version of a dependency may not work well with a newer version of Python
include:
- python-version: "3.7"
pandoc-version: "2.11.4"
pyyaml-version: "pyyaml>=5,<6"
numpy-version: "numpy>=1.16.6,<1.17"
yamlloader-version: "yamlloader>=1,<1.1"
- python-version: "pypy-3.7"
pandoc-version: "2.13"
pyyaml-version: "pyyaml>=5,<6"
numpy-version: "numpy>=1.18.5,<1.19"
yamlloader-version: "yamlloader>=1,<1.1"
- python-version: "3.8"
pandoc-version: "2.15"
pyyaml-version: "pyyaml>=6,<7"
numpy-version: "numpy>=1.20.3,<1.21"
yamlloader-version: "yamlloader>=1.1,<2"
- python-version: "3.9"
pandoc-version: "2.16.2"
pyyaml-version: "pyyaml>=6,<7"
numpy-version: "numpy>=1.21.4,<1.22"
yamlloader-version: "yamlloader>=1.1,<2"
- python-version: "3.10"
pandoc-version: "latest"
pyyaml-version: "pyyaml>=6,<7"
numpy-version: "numpy>=1.22,<1.23"
yamlloader-version: "yamlloader>=1.1,<2"
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies—pip
run: |
python -m pip install -U poetry setuptools "${{ matrix.pyyaml-version }}" "${{ matrix.numpy-version }}" "${{ matrix.yamlloader-version }}"
python -m pip install .[extras,tests]
# let coverage read generated setup.py instead of pyproject.toml
make setup.py
mv pyproject.toml .pyproject.toml
- name: Install dependencies—pandoc
run: |
# pandoc
[[ ${{ matrix.pandoc-version }} == "latest" ]] && url="https://github.com/jgm/pandoc/releases/latest" || url="https://github.com/jgm/pandoc/releases/tag/${{ matrix.pandoc-version }}"
downloadUrl="https://github.com$(curl -L $url | grep -o '/jgm/pandoc/releases/download/.*-amd64\.deb')"
wget --quiet "$downloadUrl"
sudo dpkg -i "${downloadUrl##*/}"
- name: Tests
run: |
make test
coverage combine || true
coverage report
coverage xml
coverage lcov
- name: Coveralls Parallel
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
flag-name: run-${{ matrix.test_number }}
parallel: true
path-to-lcov: ./coverage.lcov
- name: Coverage—Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
# c.f. https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
- name: Prepare to publish
if: ${{ startsWith(github.event.ref, 'refs/tags') && matrix.python-version == 3.10 }}
run: |
# undo the above. see "make editable" that already build the packages
rm -f setup.py
mv .pyproject.toml pyproject.toml
- name: Publish distribution 📦 to PyPI
if: ${{ startsWith(github.event.ref, 'refs/tags') && matrix.python-version == 3.10 }}
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.pypi_password }}
coveralls_finish:
needs: build-n-publish
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true