Skip to content

Commit f7d7156

Browse files
committed
add test matrix with uv
1 parent 70d2c60 commit f7d7156

File tree

1 file changed

+30
-52
lines changed

1 file changed

+30
-52
lines changed

.github/workflows/main.yml

Lines changed: 30 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -26,62 +26,40 @@ jobs:
2626
- run: uv run --frozen pyright
2727
if: success() || failure()
2828

29+
##
30+
31+
get-pytorch-versions:
32+
runs-on: ubuntu-latest
33+
outputs:
34+
versions: ${{ steps.get-pytorch-versions.outputs.versions }}
35+
steps:
36+
- name: Get PyTorch versions
37+
id: get-pytorch-versions
38+
run: |
39+
VERSIONS=$(
40+
curl -s https://pypi.org/pypi/torch/json | jq -r '.releases | keys[]' |
41+
# remove versions <2.0; strip "patch" from versions
42+
grep -v '^1\.' | grep -E '\.[0]+$' | sort -V | sed 's/\.0$//' |
43+
# to JSON array
44+
jq -R . | jq -sc .
45+
)
46+
echo "versions=$VERSIONS" >> $GITHUB_OUTPUT
47+
# e.g. ["2.0","2.1","2.2","2.3","2.4"]
48+
2949
test:
3050
runs-on: ubuntu-latest
51+
needs: get-pytorch-versions
52+
strategy:
53+
fail-fast: false
54+
matrix:
55+
python: ["3.9", "3.10", "3.11", "3.12"]
56+
pytorch: ${{fromJson(needs.get-pytorch-versions.outputs.versions)}}
57+
3158
steps:
3259
- uses: actions/checkout@v4
3360
- uses: astral-sh/[email protected]
3461
with:
3562
version: "0.5.0"
36-
python-version-file: ".python-version"
37-
enable-cache: true
38-
- run: uv sync
39-
- run: uv run --frozen pytest tests/test_ci.py
40-
if: success() || failure()
41-
42-
##
43-
44-
# get-pytorch-versions:
45-
# runs-on: ubuntu-latest
46-
# outputs:
47-
# versions: ${{ steps.get-pytorch-versions.outputs.versions }}
48-
# steps:
49-
# - name: Get PyTorch versions
50-
# id: get-pytorch-versions
51-
# run: |
52-
# VERSIONS=$(
53-
# curl -s https://pypi.org/pypi/torch/json | jq -r '.releases | keys[]' |
54-
# # remove versions <2.0; strip "patch" from versions
55-
# grep -v '^1\.' | grep -E '\.[0]+$' | sort -V | sed 's/\.0$//' |
56-
# # to JSON array
57-
# jq -R . | jq -sc .
58-
# )
59-
# echo "versions=$VERSIONS" >> $GITHUB_OUTPUT
60-
# # e.g. ["2.0","2.1","2.2","2.3","2.4"]
61-
62-
# test:
63-
# runs-on: ubuntu-latest
64-
# needs: get-pytorch-versions
65-
# strategy:
66-
# fail-fast: false
67-
# matrix:
68-
# python: ["3.9", "3.10", "3.11", "3.12"]
69-
# pytorch: ${{fromJson(needs.get-pytorch-versions.outputs.versions)}}
70-
71-
# steps:
72-
# - uses: actions/checkout@v4
73-
74-
# - name: Inject (python / pytorch) test deps into pixi.toml / pyproject.toml
75-
# run: |
76-
# sed -i 's/python = "3.9"/python = "${{ matrix.python }}.*"/' pixi.toml
77-
# sed -i 's/torch>=2.0.0/torch~=${{ matrix.pytorch }}/' pyproject.toml
78-
79-
# - uses: prefix-dev/[email protected]
80-
# with:
81-
# pixi-version: v0.27.1
82-
# locked: false
83-
# frozen: false
84-
# cache: false
85-
# environments: default
86-
# activate-environment: default
87-
# - run: pytest tests/test_ci.py
63+
- if: contains('2.0,2.1,2.2', matrix.pytorch)
64+
run: echo "NUMPY_VERSION='--with numpy<2'" >> $GITHUB_ENV
65+
- run: uv run --python ${{ matrix.python }} --with torch~=${{ matrix.pytorch }} ${{ env.NUMPY_VERSION }} pytest --verbose tests/test_ci.py

0 commit comments

Comments
 (0)