Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: docs

on:
push:
branches:
- main
pull_request:
paths:
- "docs/**"
- "complextorch/**"
- "pyproject.toml"
- "CHANGELOG.md"
- ".github/workflows/docs.yml"
workflow_dispatch:

# Allow only one concurrent deployment to GitHub Pages, skipping runs queued
# between the run in-progress and latest queued. Do not cancel in-progress runs.
concurrency:
group: pages
cancel-in-progress: false

jobs:
# On PRs: build a single version with warnings-as-errors. This is the
# analogue of the --cov-fail-under=100 gate in test.yml — any broken
# cross-reference, missing toctree entry, or notebook execution failure
# fails the PR.
pr-check:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-docs-${{ hashFiles('pyproject.toml') }}

- name: Install complextorch with doc extras
run: |
python -m pip install --upgrade pip
python -m pip install .[docs]

- name: Build HTML (warnings-as-errors)
run: sphinx-build -W -b html docs/source docs/build/html

# On main: multi-version build + deploy to GitHub Pages.
build:
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# sphinx-multiversion needs the full history and all tags.
fetch-depth: 0

- name: Fetch all tags
run: git fetch --tags --force

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-docs-${{ hashFiles('pyproject.toml') }}

- name: Install complextorch with doc extras
run: |
python -m pip install --upgrade pip
python -m pip install .[docs]

- name: Build multi-version HTML
run: sphinx-multiversion docs/source docs/build/html

- name: Add root → latest redirect
run: cp docs/source/_templates/redirect.html docs/build/html/index.html

- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/build/html

deploy:
needs: build
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
33 changes: 33 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: lint

on:
push:
pull_request:

jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-lint-${{ hashFiles('pyproject.toml') }}

- name: Install ruff
run: |
python -m pip install --upgrade pip
python -m pip install '.[dev]'

- name: ruff check
run: ruff check

- name: ruff format --check
run: ruff format --check
89 changes: 89 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Publish Python distribution to PyPI

on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'

jobs:
build:
name: Build distribution
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Install build
run: python -m pip install --upgrade pip build

- name: Build sdist and wheel
run: python -m build

- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: Publish to PyPI
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/complextorch
permissions:
id-token: write # trusted publishing

steps:
- name: Download dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

github-release:
name: Sign with Sigstore and publish GitHub Release
needs: publish-to-pypi
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write

steps:
- name: Download dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/

- name: Sign dists with Sigstore
uses: sigstore/gh-action-sigstore-python@v3.0.0
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl

- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create '${{ github.ref_name }}'
--repo '${{ github.repository }}'
--notes ""

- name: Upload artifacts and signatures
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'
48 changes: 48 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: pytest

on:
push:
pull_request:

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}

- name: Install complextorch with test extras
run: |
python -m pip install --upgrade pip
python -m pip install '.[test]'

- name: Run pytest
run: |
pytest tests \
--junitxml=junit/test-results-${{ matrix.python-version }}.xml \
--cov=complextorch \
--cov-report=xml \
--cov-report=html \
--cov-report=term-missing \
--cov-fail-under=100

- name: Upload coverage HTML
if: matrix.python-version == '3.11'
uses: actions/upload-artifact@v4
with:
name: htmlcov
path: htmlcov
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
todo

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -71,7 +69,7 @@ instance/
.scrapy

# Sphinx documentation
docs/_build/
docs/**/_build/

# PyBuilder
.pybuilder/
Expand Down
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Pre-commit hooks. Install with `pre-commit install`; update pins with
# `pre-commit autoupdate`. See https://pre-commit.com for the docs.
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.12
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
20 changes: 0 additions & 20 deletions .readthedocs.yaml

This file was deleted.

Loading
Loading