-
Notifications
You must be signed in to change notification settings - Fork 6
205 lines (165 loc) · 6.38 KB
/
ci.yml
File metadata and controls
205 lines (165 loc) · 6.38 KB
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
name: CI
permissions: read-all
on:
workflow_dispatch:
pull_request:
push:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
UV_LOCKED: 1
# Many color libraries just need this to be set to any value, but at least
# one distinguishes color depth, where "3" -> "256-bit color".
FORCE_COLOR: 3
jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: dprint
uses: dprint/check@9cb3a2b17a8e606d37aae341e49df3654933fc23 # v2.3
- name: Install uv
uses: astral-sh/setup-uv@d9e0f98d3fc6adb07d1e3d37f3043649ddad06a1 # v6.5.0
- name: ruff
run: |
uv run ruff check --output-format=github
uv run ruff format --check
# TODO: Fail if lefthook changes any files:
# https://github.com/data-apis/array-api-typing/pull/35/files#r2179941334
- name: lefthook
run: uv run lefthook run pre-commit
- name: mypy
run: uv run mypy --tb --no-incremental --cache-dir=/dev/null src
# TODO: (based)pyright
test_runtime:
name: runtime tests
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13"]
runs-on: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Install uv
uses: astral-sh/setup-uv@d9e0f98d3fc6adb07d1e3d37f3043649ddad06a1 # v6.5.0
with:
python-version: ${{ matrix.python-version }}
- name: Test package
run: >-
uv run --group=test_runtime
pytest --cov --cov-report=xml --cov-report=term --durations=20
- name: Upload coverage report
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
with:
token: ${{ secrets.CODECOV_TOKEN }}
test_integration_numpy:
name: integration tests (numpy)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
numpy-version: ["1.25.0", "1.26.4", "2.0.2", "2.1.3", "2.2.6", "2.3.1"]
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: astral-sh/setup-uv@d9e0f98d3fc6adb07d1e3d37f3043649ddad06a1 # v6.5.0
with:
python-version: "3.11"
activate-environment: true
- name: get major.minor numpy version
id: numpy-version
run: |
version="${{ matrix.numpy-version }}"
major=$(echo "$version" | cut -d. -f1)
minor=$(echo "$version" | cut -d. -f2)
echo "major=$major" >> $GITHUB_OUTPUT
echo "minor=$minor" >> $GITHUB_OUTPUT
- name: collect test files
id: collect-files
run: |
major="${{ steps.numpy-version.outputs.major }}"
minor="${{ steps.numpy-version.outputs.minor }}"
prefix="tests/integration"
files=""
while IFS= read -r -d '' path; do
fname=$(basename "$path")
fminor=$(echo "$fname" | sed -E "s/test_numpy${major}p([0-9]+)\.pyi/\1/")
if [ "$fminor" -le "$minor" ]; then
files="$files $path"
fi
done < <(find "$prefix" -name "test_numpy${major}p*.pyi" -print0)
files="${files# }"
echo "files=$files" >> "$GITHUB_OUTPUT"
# NOTE: `uv run --with=...` will be ignored by mypy (and `--isolated` does not help)
- name: mypy
run: |
uv sync --no-editable --group=test_numpy --group=mypy
uv pip install numpy==${{ matrix.numpy-version }}
uv run --no-sync --active \
mypy --tb --no-incremental --cache-dir=/dev/null \
${{ steps.collect-files.outputs.files }}
- name: basedmypy
run: |
uv sync --no-editable --group=test_numpy --group=basedmypy
uv pip install numpy==${{ matrix.numpy-version }}
uv run --no-sync --active \
mypy --tb --no-incremental --cache-dir=/dev/null \
${{ steps.collect-files.outputs.files }}
- name: pyright
run: |
uv sync --no-editable --group=test_numpy --group=pyright
uv pip install numpy==${{ matrix.numpy-version }}
uv run --no-sync --active \
pyright ${{ steps.collect-files.outputs.files }}
# TODO: (based)pyright
test_integration_jax:
name: integration tests (jax)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
jax-version: ["0.6.2", "0.7.0"]
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: astral-sh/setup-uv@d9e0f98d3fc6adb07d1e3d37f3043649ddad06a1 # v6.5.0
with:
python-version: "3.11"
activate-environment: true
- name: get major.minor jax version
id: jax-version
run: |
version="${{ matrix.jax-version }}"
major=$(echo "$version" | cut -d. -f1)
minor=$(echo "$version" | cut -d. -f2)
echo "major=$major" >> $GITHUB_OUTPUT
echo "minor=$minor" >> $GITHUB_OUTPUT
- name: collect test files
id: collect-files
run: |
major="${{ steps.jax-version.outputs.major }}"
minor="${{ steps.jax-version.outputs.minor }}"
prefix="tests/integration"
files=""
while IFS= read -r -d '' path; do
fname=$(basename "$path")
fminor=$(echo "$fname" | sed -E "s/test_jax${major}p([0-9]+)\.pyi/\1/")
if [ "$fminor" -le "$minor" ]; then
files="$files $path"
fi
done < <(find "$prefix" -name "test_jax${major}p*.pyi" -print0)
files="${files# }"
echo "files=$files" >> "$GITHUB_OUTPUT"
# NOTE: `uv run --with=...` will be ignored by mypy (and `--isolated` does not help)
- name: mypy
run: |
uv sync --no-editable --group=test_jax --group=mypy
uv pip install jax==${{ matrix.jax-version }}
uv run --no-sync --active \
mypy --tb --no-incremental --cache-dir=/dev/null \
${{ steps.collect-files.outputs.files }}
# TODO: basedmypy/(based)pyright
# TODO: integration tests for array-api-strict
# TODO: integration tests for 3rd party libs such as cupy, pytorch, tensorflow, dask, etc.