Allow choosing between CPU and GPU Pytorch #42
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SPDX-FileCopyrightText: Enno Hermann | |
# | |
# SPDX-License-Identifier: MIT | |
name: Test | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
types: [opened, synchronize, reopened] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- python-version: "3.9" | |
numpy-version: "--with numpy==1.21.6" | |
torch-version: "--with torch==1.12.1+cpu" | |
- python-version: "3.10" | |
numpy-version: "--with numpy==1.21.6" | |
torch-version: "--with torch==1.12.1+cpu" | |
- python-version: "3.11" | |
numpy-version: "--with numpy==1.24.4" | |
torch-version: "--with torch==2.1.1+cpu" | |
- python-version: "3.12" | |
numpy-version: "--with numpy==1.26.4" | |
torch-version: "--with torch==2.2.2+cpu" | |
- python-version: "3.13" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup uv | |
uses: ./.github/actions/setup-uv | |
- name: Tests | |
run: | | |
uv sync | |
uv run --index https://download.pytorch.org/whl/cpu \ | |
--index-strategy unsafe-best-match \ | |
${{ matrix.numpy-version }} ${{ matrix.torch-version}} \ | |
coverage run --parallel | |
- name: Upload coverage data | |
uses: actions/upload-artifact@v4 | |
with: | |
include-hidden-files: true | |
name: coverage-data-${{ matrix.python-version }} | |
path: .coverage.* | |
if-no-files-found: ignore | |
coverage: | |
if: always() | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup uv | |
uses: ./.github/actions/setup-uv | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: coverage-data-* | |
merge-multiple: true | |
- name: Combine coverage | |
run: | | |
uv python install 3.12 | |
uvx coverage combine | |
uvx coverage html --skip-covered --skip-empty | |
uvx coverage report --format=markdown >> $GITHUB_STEP_SUMMARY |