-
-
Notifications
You must be signed in to change notification settings - Fork 15
118 lines (112 loc) · 4.52 KB
/
pythonpackage.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# 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
python-version:
# - 3.6
- 3.7
- 3.8
- 3.9
- pypy3
# should test sparingly across API breaking boundaries
pandoc-version:
# - 2.0.6
# - 2.1.3
# - 2.2.3.2
# - 2.3.1
# - 2.4
# - 2.5
# - 2.6
# panflute only support at or above this
# - 2.7.3
# no major API change between 2.7 to 2.9
# - 2.8.1
# - 2.9.2.1
# as of writing, panflute only support pandoc<= 2.9. But GitHub workflow does not support "allow failure" yet. See https://github.com/actions/toolkit/issues/399
# 2.10 has breaking change
# - 2.10.1
# 2.11 has minor breaking change, fixing some quirks in 2.10
# - 2.11.0.4
- 2.11.4
# - 2.12
- latest
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: |
# TODO cleanup when pypy 3.7 and numpy for pypy 3.7 stable release
if [[ ${{ matrix.python-version }} == pypy3 ]]; then
# install our own pypy37
mkdir -p ~/.local
wget -qO- https://downloads.python.org/pypy/pypy3.7-v7.3.3-linux64.tar.bz2 | tar -xjf - -C ~/.local --strip-components=1
export PATH="$HOME/.local/bin:$PATH"
pypy -m ensurepip
pypy -m pip install -U 'numpy==1.20.0rc1' poetry setuptools
make editable EXTRAS=[extras,tests] python=pypy
else
pip install -U poetry setuptools
make editable EXTRAS=[extras,tests]
fi
# make editable generated setup.py, let coverage read this instead of pyproject.toml
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: |
# TODO cleanup when pypy 3.7 and numpy for pypy 3.7 stable release
if [[ ${{ matrix.python-version }} == pypy3 ]]; then
export PATH="$HOME/.local/bin:$PATH"
make test COVHTML='--cov-report=xml' python=pypy
else
# TODO cleanup when pytest-parallel support python 3.9 and runs sucessfully
[[ ${{ matrix.python-version }} == 3.9 ]] && make test COVHTML='--cov-report=xml' PYTESTPARALLEL= || make test COVHTML='--cov-report=xml'
fi
- name: Coverage—Coveralls
uses: AndreMiras/coveralls-python-action@develop
with:
parallel: true
flag-name: python-${{ matrix.python-version }}_pandoc-${{ matrix.pandoc-version }}
- 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.9 && matrix.pandoc-version == 'latest' }}
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.9 && matrix.pandoc-version == 'latest' }}
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.pypi_password }}
coveralls_finish:
needs: build-n-publish
runs-on: ubuntu-latest
steps:
- name: Coverage—Coveralls finishing
uses: AndreMiras/coveralls-python-action@develop
with:
parallel-finished: true