Skip to content

Misc refactoring

Misc refactoring #184

Workflow file for this run

name: Run checks on push or PR to main
on:
push:
branches: [main]
pull_request:
branches:
- main
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: prefix-dev/setup-pixi@v0.8.1
with:
pixi-version: v0.27.1
frozen: true
cache: true
environments: dev
activate-environment: dev
- run: ruff check
if: success() || failure()
- run: ruff format --check
if: success() || failure()
##
typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: prefix-dev/setup-pixi@v0.8.1
with:
pixi-version: v0.27.1
frozen: true
cache: true
environments: extra
activate-environment: extra
- run: pyright
if: success() || failure()
##
get-pytorch-versions:
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.get-pytorch-versions.outputs.versions }}
steps:
- name: Get PyTorch versions
id: get-pytorch-versions
run: |
VERSIONS=$(
curl -s https://pypi.org/pypi/torch/json | jq -r '.releases | keys[]' |
# remove versions <2.0; strip "patch" from versions
grep -v '^1\.' | grep -E '\.[0]+$' | sort -V | sed 's/\.0$//' |
# to JSON array
jq -R . | jq -sc .
)
echo "versions=$VERSIONS" >> $GITHUB_OUTPUT
# e.g. ["2.0","2.1","2.2","2.3","2.4"]
test:
runs-on: ubuntu-latest
needs: get-pytorch-versions
strategy:
fail-fast: false
matrix:
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
pytorch: ${{fromJson(needs.get-pytorch-versions.outputs.versions)}}
steps:
- uses: actions/checkout@v4
- name: Inject (python / pytorch) test deps into pixi.toml / pyproject.toml
run: |
sed -i 's/python = "3.8.1"/python = "${{ matrix.python }}.*"/' pixi.toml
sed -i 's/torch>=2.0.0/torch~=${{ matrix.pytorch }}/' pyproject.toml
- uses: prefix-dev/setup-pixi@v0.8.1
with:
pixi-version: v0.27.1
locked: false
frozen: false
cache: false
environments: default
activate-environment: default
- run: pytest tests/test_ci.py