Prepare for public release (0.3.0
)
#405
Workflow file for this run
This file contains hidden or 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
name: Run checks on push or PR to main | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: | |
- main | |
jobs: | |
checks: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: astral-sh/setup-uv@v5 | |
with: | |
version: "0.5.29" | |
enable-cache: true | |
- run: uv lock --check | |
- run: uv sync | |
- run: uv run --frozen ruff check | |
if: success() || failure() | |
- run: uv run --frozen ruff format --check | |
if: success() || failure() | |
- run: uv run --frozen pyright | |
if: success() || failure() | |
build-docs: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: astral-sh/setup-uv@v5 | |
with: | |
version: "0.5.29" | |
- run: uv run --group docs python -m sphinx --builder html --doctree-dir docs/_build/.doctrees --conf-dir docs --show-traceback docs/source docs/_build/html | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: docs-html-build | |
path: docs/_build/html | |
retention-days: 14 | |
## | |
get-python-pytorch-versions: | |
runs-on: ubuntu-latest | |
outputs: | |
versions: ${{ steps.get-versions.outputs.versions }} | |
steps: | |
- name: "Get (Python, PyTorch) versions" | |
id: get-versions | |
run: | | |
MIN_PYTHON_VERSION=3.9 | |
MIN_PYTORCH_VERSION=2.0 | |
# Get PyTorch versions from PyPI | |
pytorch_versions=$( | |
curl -s https://pypi.org/pypi/torch/json | jq -r '.releases | keys[]' | | |
# strip "patch" from versions | |
grep -E '\.[0]+$' | sort -V | sed 's/\.0$//' | |
) | |
# For each PyTorch version, get Python versions that have builds | |
# Generate JSON list of "python,pytorch" versions | |
version_matrix=() | |
for pytorch_version in $pytorch_versions; do | |
# Skip if PyTorch version less than minium | |
if [[ "$(printf '%s\n' "$pytorch_version" "$MIN_PYTORCH_VERSION" | sort -V | head -n 1)" != "$MIN_PYTORCH_VERSION" ]]; then continue; fi | |
python_versions=$( | |
curl -s "https://pypi.org/pypi/torch/$pytorch_version/json" | | |
jq -r '.urls[].filename | select(test("manylinux1_x86_64")) | capture("(?<cp>cp[0-9]+)-") | .cp | | |
sub("cp(?<major>[0-9])(?<minor>[0-9]+)"; "\(.major).\(.minor)")' | |
) | |
for python_version in $python_versions; do | |
# Skip if Python version less than minium | |
if [[ "$(printf '%s\n' "$python_version" "$MIN_PYTHON_VERSION" | sort -V | head -n 1)" != "$MIN_PYTHON_VERSION" ]]; then continue; fi | |
version_matrix+=($python_version,$pytorch_version) | |
done | |
done | |
version_matrix=$(printf '%s\n' "${version_matrix[@]}" | jq -R . | jq -s -c .) | |
# Write to outputs | |
echo "versions=$version_matrix" >> $GITHUB_OUTPUT | |
test: | |
runs-on: ubuntu-latest | |
needs: get-python-pytorch-versions | |
strategy: | |
fail-fast: false | |
matrix: | |
versions: ${{fromJson(needs.get-python-pytorch-versions.outputs.versions)}} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: astral-sh/setup-uv@v5 | |
with: | |
version: "0.5.29" | |
- run: | | |
IFS=',' read -r python_version pytorch_version <<< ${{ matrix.versions }} | |
echo "PYTHON_VERSION=$python_version" >> $GITHUB_ENV | |
echo "PYTORCH_VERSION=$pytorch_version" >> $GITHUB_ENV | |
if [[ "$pytorch_version" =~ ^2\.(0|1|2)$ ]]; then | |
echo "NUMPY_VERSION=--with \"numpy<2\"" >> $GITHUB_ENV | |
fi | |
- run: uv run --python ${{ env.PYTHON_VERSION }} --with torch~=${{ env.PYTORCH_VERSION }} ${{ env.NUMPY_VERSION }} pytest --verbose tests/test_ci.py |