-
Notifications
You must be signed in to change notification settings - Fork 2
325 lines (271 loc) · 9.06 KB
/
ci.yaml
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
name: ci
on:
- push
- pull_request
jobs:
# Main CI: this will test the library against all target versions on Linux and
# one version on Mac OS (3.8) to mirror development environment.
check:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python:
- 3.5
- 3.6
- 3.7
- 3.8
- pypy3
os:
- ubuntu-latest
- macos-latest
exclude:
- os: macos-latest
python: 3.5
- os: macos-latest
python: 3.6
- os: macos-latest
python: 3.7
- os: macos-latest
python: pypy3
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python }}
- name: Cache deps
uses: actions/cache@v1
with:
path: .pip-cache
key: ${{ runner.os }}-python-${{ matrix.python }}-${{ hashFiles('requirements*.txt') }}
restore-keys: |
${{ runner.os }}-python-${{ matrix.python }}-
${{ runner.os }}-python-
${{ runner.os }}-
- name: Dependencies
if: matrix.python != 'pypy3'
run: |
mkdir -p .pip-cache
pip install --cache-dir .pip-cache --upgrade -r requirements-dev.txt
pip install -e .
# Some dev dependencies don't build under pypy but testing deps and py-gql
# should work.
- name: Dependencies (PyPy)
if: matrix.python == 'pypy3'
run: |
mkdir -p .pip-cache
pip install --cache-dir .pip-cache --upgrade invoke -r requirements-tests.txt
pip install -e .
- name: (Debug) dependency versions
run: |
python --version
pip --version
pip freeze
- name: Lint (Flake 8)
if: matrix.python != 'pypy3'
run: |
inv flake8 --junit
- name: Lint (Mypy)
if: matrix.python != 'pypy3'
run: |
inv mypy --junit
- name: Test & Coverage
if: matrix.python != 'pypy3'
run: |
inv test -v --coverage --junit --no-bail
- name: Test - No Coverage
if: matrix.python == 'pypy3'
run: |
inv test -v --junit --no-bail
- name: Check benchmarks run
if: matrix.python != 'pypy3'
run: |
inv benchmark
- name: Test with Cython
if: matrix.python != 'pypy3' && matrix.os != 'macos-latest'
run: |
PY_GQL_USE_CYTHON=1 pip install --no-build-isolation -e .
PY_IGNORE_IMPORTMISMATCH=1 inv test -v --no-bail
- name: Build docs
if: matrix.python == '3.8' && matrix.os != 'macos-latest'
run: |
inv docs
- uses: codecov/codecov-action@v1
if: matrix.python != 'pypy3' && matrix.os != 'macos-latest'
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
# Build wheels and source distribution, upload them as build artifacts.
build_universal:
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || contains(github.ref, 'tags/v')
runs-on: ubuntu-latest
needs: [check]
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Cache deps
uses: actions/cache@v1
with:
path: .pip-cache
key: ${{ runner.os }}-python-build-deps
- name: Dependencies
run: |
mkdir -p .pip-cache
pip install --cache-dir .pip-cache --upgrade pip wheel setuptools 'invoke~=1.1'
- name: Build base wheel and source distribution
run: inv build
- name: Upload dist
uses: actions/upload-artifact@v1
with:
name: dist.any
path: dist
build_wheels:
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || contains(github.ref, 'tags/v')
runs-on: ubuntu-latest
needs: [check]
strategy:
fail-fast: false
matrix:
version:
- 3.5
- 3.6
- 3.7
- 3.8
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Cache deps
uses: actions/cache@v1
with:
path: .pip-cache
key: ${{ runner.os }}-python-build-deps
- name: Dependencies
run: |
mkdir -p .pip-cache
pip install --cache-dir .pip-cache --upgrade pip wheel setuptools 'cython<3' 'invoke~=1.1'
- name: Build manylinux wheel
run: inv build-manylinux-wheels --cythonize-module --python ${{ matrix.version }}
- name: Upload dist
uses: actions/upload-artifact@v1
with:
name: dist.${{ matrix.version }}
path: dist
collect_dist:
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || contains(github.ref, 'tags/v')
runs-on: ubuntu-latest
needs: [build_universal, build_wheels]
steps:
- name: Download build artifacts (any)
uses: actions/download-artifact@v1
with:
name: dist.any
- name: Download build artifacts (3.5)
uses: actions/download-artifact@v1
with:
name: dist.3.5
- name: Download build artifacts (3.6)
uses: actions/download-artifact@v1
with:
name: dist.3.6
- name: Download build artifacts (3.7)
uses: actions/download-artifact@v1
with:
name: dist.3.7
- name: Download build artifacts (3.8)
uses: actions/download-artifact@v1
with:
name: dist.3.8
- name: Collect
run: |
mkdir -p dist
mv dist.*/*.tar.gz dist
mv dist.*/*.whl dist
touch dist/checksums.txt
find dist -name "py_gql*" -type f -exec sha256sum "{}" + >> dist/checksums.txt
- name: Upload dist
uses: actions/upload-artifact@v1
with:
name: dist
path: dist
# On tag this should create a Github release with the same tag and upload the
# artifacts from the `build` step.
# TODO: Upload to PyPI?
release:
if: success() && contains(github.ref, 'tags/v')
runs-on: ubuntu-latest
needs: [collect_dist]
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Inspect and check version
id: version
run: |
version_str=$(echo ${{ github.ref }} | sed 's/refs\/tags\/v//')
package_version=$(grep __version__ py_gql/_pkg.py | sed 's/__version__ = //; s/\"//g')
if ! grep -q -P '^\d+\.\d+\.\d+(?:\.(?:dev|a|b|rc)\d+)?$' <<< "$version_str"; then
echo "::error::Invalid version string $version_str"
exit 1
fi
if [ "$version_str" != "$package_version" ]; then
echo "::error::Tag ($version_str) should match package version ($package_version)"
exit 1
fi
prerelease=$(grep -q -P '\.(?:dev|a|b|rc)\d+$' <<< "$version_str" && echo true || echo false)
echo "::set-output name=version::${version_str}"
echo "::set-output name=prerelease::${prerelease}"
- name: Download build artifacts
uses: actions/download-artifact@v1
with:
name: dist
- name: Create body
id: body
run: |
body=$(cat <<EOF
Release ${{ steps.version.outputs.version }} ($(date -I))
\`\`\`
$(cat dist/checksums.txt)
\`\`\`
EOF
)
escaped="${body//$'\n'/%0A}"
echo "::set-output name=value::$escaped"
- name: Create Release
id: create_release
uses: actions/create-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.version.outputs.version }}
release_name: Release ${{ steps.version.outputs.version }}
body: ${{ steps.body.outputs.value }}
prerelease: ${{ steps.version.outputs.prerelease }}
draft: true # Let a human promote releases for now
# I'd like to use actions/upload-release-asset but it doesn't support
# globs/dynamic file lists at the moment.
- name: Upload release artifacts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
AUTH="Authorization: token $GITHUB_TOKEN"
URL="https://uploads.github.com/repos/${{ github.repository }}/releases/${{ steps.create_release.outputs.id }}/assets"
for file in dist/*; do
echo "Uploading $file...\n"
curl \
--verbose \
--fail \
-H "$AUTH" \
-H "Content-Type: $(file -b --mime-type "$file")" \
-H "Content-Length: $(stat -c%s "$file")" \
--data-binary @"$file" \
"$URL?name=$(basename "$file")"
done