-
Notifications
You must be signed in to change notification settings - Fork 0
239 lines (222 loc) · 8.42 KB
/
python-package.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
name: CI
on:
push:
pull_request:
jobs:
python:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Pre-install
run: |
python -m pip install --upgrade pip
pip install --no-deps .
python -c "import bussilab"
bussilab -h
pip uninstall --yes bussilab
- name: Install
run: |
pip install .
- name: Test with pytest
env:
BUSSILAB_TEST_NOTIFY_TOKEN: ${{ secrets.BUSSILAB_TEST_NOTIFY_TOKEN }}
BUSSILAB_TEST_NOTIFY_CHANNEL: ${{ secrets.BUSSILAB_TEST_NOTIFY_CHANNEL }}
run: |
bussilab check --import
pip install pytest pytest-cov
pytest -v
NUMBA_DISABLE_JIT=1 PYTHONPATH=$PWD pytest -v --cov=bussilab
bash <(curl -s https://codecov.io/bash)
- name: Pyflakes
run: |
pip install --upgrade pyflakes
pyflakes bussilab
- name: Pylint
run: |
pip install --upgrade pylint
pylint -E bussilab
# - name: Mypy
# run: |
# pip install --upgrade mypy
# mypy bussilab
- name: Flake8
run: |
pip install --upgrade flake8
# 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 bussilab bin --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | tee flake8_report.txt
- name: Doc
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' }}
run: |
pip install --upgrade pdoc3 jupyter nbconvert
pdoc3 -f --html -o doc/ bussilab
( cd examples && ./render.sh )
mkdir doc/examples
cp examples/*html doc/examples/
( sudo apt-get install tree && cd doc/examples && tree -H '.' -L 1 --noreport --charset utf-8 > index.html )
( sudo apt-get install pandoc texlive-xetex && pdoc3 -f --pdf bussilab > bussilab.md && pandoc --metadata=title:"Py-Bussilab Documentation" --from=markdown+abbreviations+tex_math_single_backslash --pdf-engine=xelatex --toc --toc-depth=4 --output=doc/bussilab.pdf bussilab.md )
- name: Push doc to GitHub Pages
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' && github.ref == 'refs/heads/master' }}
env:
BUSSILABBOT_TOKEN: ${{ secrets.BUSSILABBOT_TOKEN }}
run: |
.ci/pushdoc
- name: Upload doc to artifact
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' }}
uses: actions/upload-artifact@v3
with:
path: doc
name: doc
- name: Upload doc to artifact
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' }}
uses: actions/upload-artifact@v3
with:
path: flake8_report.txt
name: flake8_report
- name: Deploy PyPI
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' && startsWith(github.ref, 'refs/tags/') }}
env:
BUSSILABBOT_PYPI: ${{ secrets.BUSSILABBOT_PYPI }}
run: |
pip install twine
python setup.py sdist
python -m twine upload -u bussilabbot -p "$BUSSILABBOT_PYPI" dist/bussilab-*.tar.gz
python36:
# Mini test, to make sure we do not break python 3.6 compaibility for a while
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.6
uses: actions/setup-python@v4
with:
python-version: 3.6
- name: Install
run: |
pip install .
- name: Test with pytest
env:
BUSSILAB_TEST_NOTIFY_TOKEN: ${{ secrets.BUSSILAB_TEST_NOTIFY_TOKEN }}
BUSSILAB_TEST_NOTIFY_CHANNEL: ${{ secrets.BUSSILAB_TEST_NOTIFY_CHANNEL }}
run: |
bussilab check --import
pip install pytest pytest-cov
pytest -v
NUMBA_DISABLE_JIT=1 PYTHONPATH=$PWD pytest -v --cov=bussilab
bash <(curl -s https://codecov.io/bash)
macports:
# The type of runner that the job will run on
runs-on: macos-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# Runs a single command using the runners shell
- name: Install MacPorts
run: |
curl -LO https://raw.githubusercontent.com/GiovanniBussi/macports-ci/master/macports-ci
source ./macports-ci install
- name: Setup environment
run: |
echo MACPORTS_PY_VERSIONS="3.8 3.9 3.10 3.11" >> $GITHUB_ENV
- name: Install python
run: |
for pyver in $MACPORTS_PY_VERSIONS
do
sudo port install python${pyver//./} py${pyver//./}-{pip,setuptools}
done
- name: Install package
run: |
# the re.sub() command is necessary since site.USER_SITE seems to be incorrectly set to
# /Users/runner/Library/Python/3.9/lib/python/site-packages
# instead of the correct
# /Users/runner/Library/Python/3.9/lib/python3.9/site-packages
for pyver in $MACPORTS_PY_VERSIONS
do
# subshell not to pollute paths
(
export PATH="$(python$pyver -c 'import site; print(site.USER_BASE + "/bin")'):$PATH"
export PYTHONPATH="$(python$pyver -c 'import site; import re; print(re.sub("python/","python'$pyver'/",site.USER_SITE))'):$PYTHONPATH"
pip-$pyver install --user --no-deps .
sudo port install $(bussilab required --macports --pyver ${pyver//./})
)
done
- name: Run tests
run: |
for pyver in $MACPORTS_PY_VERSIONS
do
# subshell not to pollute paths
(
export PATH="$(python$pyver -c 'import site; print(site.USER_BASE + "/bin")'):$PATH"
export PYTHONPATH="$(python$pyver -c 'import site; import re; print(re.sub("python/","python'$pyver'/",site.USER_SITE))'):$PYTHONPATH"
bussilab check --import
sudo port install py${pyver//./}-pytest
# ignore BUSSILAB_TEST_NOTIFY_TOKEN since it does not work with macports for some reason
pytest-$pyver -v
)
done
conda:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install conda
run: |
curl -LO https://raw.githubusercontent.com/GiovanniBussi/conda-ci/master/conda-ci
source ./conda-ci install
source ./conda-ci install-conda-build
- name: Build
run: |
source activate base
python make_conda_recipe.py
export CPU_COUNT=2
conda-build -c conda-forge conda
rm -fr bussilab # make sure this is not imported by mistake in tests
- name: Test 3.7
run: |
source activate base
conda create -n py37 -c conda-forge -c local python=3.7 py-bussilab pytest
source activate py37
pytest -v
- name: Test 3.8
run: |
source activate base
conda create -n py38 -c conda-forge -c local python=3.8 py-bussilab pytest
source activate py38
pytest -v
- name: Test 3.9
run: |
source activate base
conda create -n py39 -c conda-forge -c local python=3.9 py-bussilab pytest
source activate py39
pytest -v
- name: Test 3.10
run: |
source activate base
conda create -n py310 -c conda-forge -c local python=3.10 py-bussilab pytest
source activate py310
pytest -v
- name: Test 3.11
run: |
source activate base
conda create -n py311 -c conda-forge -c local python=3.11 py-bussilab pytest
source activate py311
pytest -v
- name: Deploy conda
if: ${{ matrix.os == 'ubuntu-latest' && startsWith(github.ref, 'refs/tags/') }}
env:
CONDA_UPLOAD_TOKEN: ${{ secrets.CONDA_UPLOAD_TOKEN }}
run: |
source activate base
anaconda -t $CONDA_UPLOAD_TOKEN upload -u bussilab -l main $CONDA_PREFIX/conda-bld/*/py-bussilab*.tar.bz2 --force