-
-
Notifications
You must be signed in to change notification settings - Fork 11
279 lines (274 loc) · 8.95 KB
/
main.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
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
name: CI
on: [push, pull_request]
jobs:
lint:
name: Lint (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements/**') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements/dev.txt
python setup.py build
- name: Lint with ruff
run: |
ruff coredis tests
- name: Lint with black
run: |
black --check coredis tests
- name: Check imports
run: |
isort -c --profile=black coredis tests
- name: Check types
run: |
mypy coredis
- name: Check auto generated sources
run: |
make templated-sources
if [ ! -z "$(git diff coredis)" ];
then
echo "Auto-generated source are not up to date"
git diff
exit 1
fi;
test:
name: Test (Python ${{ matrix.python-version }}, Redis ${{ matrix.redis-version }}${{ matrix.uvloop == 'True' && ', uvloop' || ''}}${{ matrix.orjson == 'True' && ', orjson' || ''}}${{ matrix.extensions == 'True' && ', compiled' || ''}}${{ matrix.label && format(', {0}', matrix.label) || '' }})
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.redis-version == 'next' }}
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
redis-version: ["6.2", "7.0", "7.2", "latest"]
test_params: ["-m '(not (keydb or dragonfly or valkey or redict))'"]
uvloop: ["True", "False"]
orjson: ["False"]
runtime_type_checks: ["True"]
extensions: ["True"]
label: [""]
include:
- python-version: "3.11"
redis-version: "latest"
test_params: "-m '(not (keydb or dragonfly or valkey or redict))'"
runtime_type_checks: "True"
extensions: "False"
- python-version: "3.11"
redis-version: "7.0"
test_params: "-m keydb"
label: "KeyDB"
- python-version: "3.11"
redis-version: "7.0"
test_params: "-m dragonfly"
label: "Dragonfly"
- python-version: "3.11"
redis-version: "7.0"
test_params: "-m valkey"
label: "Valkey"
- python-version: "3.11"
redis-version: "7.0"
test_params: "-m redict"
label: "Redict"
- python-version: "pypy-3.9"
redis-version: "7.0"
test_params: "-m '(not (keydb or dragonfly or valkey or redict))' tests/commands tests/test_tracking_cache.py"
runtime_type_checks: "False"
extensions: "False"
uvloop: "False"
label: ""
steps:
- uses: actions/checkout@v3
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('requirements/**') }}
restore-keys: |
${{ runner.os }}-${{ matrix.python-version }}-pip-
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements/ci.txt
python setup.py build
- name: Compile extensions
if: ${{ matrix.extensions == 'True' }}
run: python setup.py build_ext --inplace --use-mypyc
- name: Install uvloop
if: ${{ matrix.uvloop == 'True' }}
run:
pip install uvloop
- name: Install orjson
if: ${{ matrix.orjson == 'True' }}
run:
pip install orjson
- name: Tests
env:
COREDIS_UVLOOP: ${{ matrix.uvloop }}
HOST_OS: linux
CI: "True"
COREDIS_REDIS_VERSION: ${{matrix.redis-version}}
COREDIS_RUNTIME_CHECKS: ${{matrix.runtime_type_checks}}
PYTEST_SENTRY_DSN: ${{ matrix.extensions != 'True' && secrets.SENTRY_DSN || ''}}
run: |
echo "Runtime checks: $COREDIS_RUNTIME_CHECKS"
echo "UVLoop: $COREDIS_UVLOOP"
echo "CI: $CI"
pytest -q --reverse --reruns 2 --cov=coredis --cov-report=xml ${{ matrix.test_params }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4.2.0
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
generate_wheels_matrix:
name: Generate wheels matrix
runs-on: ubuntu-latest
outputs:
include: ${{ steps.set-matrix.outputs.include }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install cibuildwheel and pypyp
run: |
pipx install cibuildwheel==2.16.2
pipx install pypyp==1
- id: set-matrix
run: |
MATRIX=$(
{
cibuildwheel --print-build-identifiers --platform linux . \
| pyp 'json.dumps({"only": x, "os": "ubuntu-latest"})' \
&& cibuildwheel --print-build-identifiers --platform macos . \
| pyp 'json.dumps({"only": x, "os": "macos-latest"})'
} | pyp 'json.dumps(list(map(json.loads, lines)))'
)
echo "include=$MATRIX" | tee -a $GITHUB_OUTPUT
env:
CIBW_ARCHS_LINUX: auto aarch64
CIBW_ARCHS_MACOS: auto arm64
CIBW_SKIP: '*musllinux* pp*'
build_wheels:
needs: [generate_wheels_matrix]
name: Build wheel on ${{ matrix.only }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
${{ fromJson(needs.generate_wheels_matrix.outputs.include) }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v2
- name: Build wheel
uses: pypa/cibuildwheel@v2.16.2
with:
only: ${{ matrix.only }}
env:
CIBW_BUILD_VERBOSITY: 3
CIBW_BUILD_FRONTEND: "build"
CIBW_CONFIG_SETTINGS: "--build-option=--use-mypyc"
CIBW_TEST_COMMAND: "python -c 'import coredis'"
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
build_pure_wheel:
needs: [lint]
name: Build pure python wheel
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Build wheels
run: |
python -m pip install build
PURE_PYTHON=1 python -m build --wheel
- uses: actions/upload-artifact@v3
with:
path: ./dist/*.whl
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Build sdist
run: |
pipx run build --sdist
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
upload_pypi:
needs: [test, build_wheels, build_pure_wheel, build_sdist]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/download-artifact@v2
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
upload_pypi_release:
needs: [test, build_wheels, build_sdist]
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v2
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
github_release:
needs: [upload_pypi_release]
name: Create Release
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: artifact
path: dist
- name: Generate release notes
run: |
./scripts/github_release_notes.sh > release_notes.md
- name: Create Release
uses: ncipollo/release-action@v1
with:
artifacts: "dist/*"
bodyFile: release_notes.md
token: ${{ secrets.GITHUB_TOKEN }}