-
Notifications
You must be signed in to change notification settings - Fork 74
174 lines (165 loc) · 4.94 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
name: Python package
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
release:
types: [ created ]
jobs:
lint:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.11]
name: "lint | Python ${{ matrix.python-version }}"
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
pip install .
- name: Setup flake8 annotations
uses: rbialon/flake8-annotations@v1
- name: Run flake8
run: |
flake8 clifford --show-source --statistics
test:
defaults:
run:
# conda needs this to activate environments properly
shell: bash -l {0}
needs: lint
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
# fastest jobs first
- python-version: 3.11
name: without JIT
disable_jit: 1
- python-version: 3.11
name: doctests
mode: doctests
# really slow job next, so it runs in parallel with the others
- python-version: 3.11
name: slow tests
mode: very_slow
- python-version: 3.8
name: default
- python-version: 3.11
name: default
- python-version: 3.12
name: default
- python-version: 3.11
name: conda
conda: true
- python-version: 3.11
name: benchmarks
mode: bench
name: "build | ${{ matrix.name }} | Python ${{matrix.python-version}}"
steps:
- uses: actions/checkout@v4
# python / pip
- name: Set up Python ${{ matrix.python-version }}
if: "!matrix.conda"
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
if: "!matrix.conda"
run: |
python -m pip install --upgrade pip;
pip install . --prefer-binary;
# test dependencies
pip install --upgrade pytest pytest-cov pytest-benchmark IPython
# conda
- name: Set up Python ${{ matrix.python-version }} (conda)
if: matrix.conda
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
- name: Install dependencies (conda)
if: matrix.conda
run: |
echo $CONDA/bin >> $GITHUB_PATH;
conda install \
"numpy>=1.17.0" \
scipy \
pip \
IPython \
h5py;
conda install -c conda-forge sparse;
conda install -c numba "numba>=0.45.1";
# make sure in conda we do not overwrite dependencies with pip
python setup.py develop --no-deps;
# test dependencies
python -m pip install --upgrade pytest pytest-cov pytest-benchmark;
- name: Test with pytest
env:
MODE: ${{ matrix.mode }}
NUMBA_DISABLE_JIT: ${{ matrix.disable_jit }}
run: |
PYTEST_ARGS=();
if [[ "${MODE}" == "bench" ]]; then
PYTEST_ARGS+=(--benchmark-only);
else
PYTEST_ARGS+=(--benchmark-skip);
fi;
if [[ "${MODE}" == "very_slow" ]]; then
PYTEST_ARGS+=(-m "veryslow");
else
PYTEST_ARGS+=(-m "not veryslow");
fi;
if [[ "${MODE}" == "doctests" ]]; then
PYTEST_ARGS+=(--doctest-modules --ignore clifford/test);
fi;
# `python -m` ensures we dispatch to conda if appropriate
python -m pytest \
--pyargs clifford \
"${PYTEST_ARGS[@]}" \
--color=yes \
-o junit_family=legacy \
--junitxml=junit/test-results.xml \
--durations=25 \
--cov=clifford \
--cov-branch;
# This only publishes result for the last run right now
# - name: Publish Test Report
# uses: mikepenz/action-junit-report@v2
# if: ${{ always() }}
# with:
# report_paths: 'junit/test-results.xml'
- uses: codecov/codecov-action@v5
deploy:
needs: test
runs-on: ubuntu-latest
name: deploy
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: "Install"
run: |
python -m pip install --upgrade pip;
python -m pip install build
python -m build --sdist --wheel --outdir dist/
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
if: startsWith(github.ref, 'refs/tags/v')
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}