-
Notifications
You must be signed in to change notification settings - Fork 5
135 lines (108 loc) · 4.07 KB
/
ci.yml
File metadata and controls
135 lines (108 loc) · 4.07 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
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: dprint
uses: dprint/check@9cb3a2b17a8e606d37aae341e49df3654933fc23 # v2.3
- name: Install uv
uses: astral-sh/setup-uv@803947b9bd8e9f986429fa0c5a41c367cd732b41 # v7.2.1
- 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install uv
uses: astral-sh/setup-uv@803947b9bd8e9f986429fa0c5a41c367cd732b41 # v7.2.1
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@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: astral-sh/setup-uv@803947b9bd8e9f986429fa0c5a41c367cd732b41 # v7.2.1
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: install deps
run: |
uv sync --no-editable --group=mypy
uv pip install numpy==${{ matrix.numpy-version }}
# NOTE: `uv run --with=...` will be ignored by mypy (and `--isolated` does not help)
- name: mypy
run: |
major="${{ steps.numpy-version.outputs.major }}"
minor="${{ steps.numpy-version.outputs.minor }}"
# Directory containing versioned test files
prefix="tests/integration"
files=""
# Find all test files matching the current major version
for path in $(find "$prefix" -name "test_numpy${major}p*.pyi"); do
# Extract file name
fname=$(basename "$path")
# Parse the minor version from the filename
fminor=$(echo "$fname" | sed -E "s/test_numpy${major}p([0-9]+)\.pyi/\1/")
# Include files where minor version ≤ NumPy's minor
if [ "$fminor" -le "$minor" ]; then
files="$files $path"
fi
done
uv run --no-sync --active \
mypy --tb --no-incremental --cache-dir=/dev/null \
$files
# TODO: (based)pyright
# TODO: integration tests for array-api-strict
# TODO: integration tests for 3rd party libs such as cupy, pytorch, tensorflow, dask, etc.