Skip to content

Add Python docs

Add Python docs #59

Workflow file for this run

name: Python 🐍
on:
push:
branches: [main]
paths:
- "openapi.yaml"
- "python/remotebmi/**"
- "python/tests/**"
- "python/pyproject.toml"
- .github/workflows/python.yml
pull_request:
paths:
- "openapi.yaml"
- "python/remotebmi/**"
- "python/tests/**"
- "python/pyproject.toml"
- .github/workflows/python.yml
types: [opened, synchronize, reopened]
workflow_call:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
id-token: write # This is required for codecov
defaults:
run:
working-directory: python
jobs:
lint-format:
name: formatting and type checking πŸ”οΈ
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: "pip"
- name: Install ruff
run: pip install ruff
- name: Run ruff check
run: ruff check
- name: Run ruff format
run: ruff format --check
typing:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: "pip"
- name: Install remotebmi
run: pip install .[dev] # dev too so tests can be type checked
- name: Install mypy
run: pip install mypy numpy
- name: Run mypy
run: mypy .
test:
name: run test suite πŸ›
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
python-version: ['3.10', '3.13']
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install dependencies
run: pip install -e .[dev]
- name: Run tests
run: pytest
cov:
name: compute and upload coverage
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: "pip"
- name: Install dependencies
run: pip install -e .[dev]
- name: Run tests
run: pytest --cov --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: coverage.xml
use_oidc: true
build:
name: build the package πŸ› οΈ
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: "pip"
- name: Install build
run: pip install build
- name: Build package
run: python3 -m build
docs:
name: build docs πŸ“–
runs-on: ubuntu-latest
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: "pip"
- name: Install docs requirements
run: pip install -r docs/requirements.txt
- name: Build docs
run: make -C docs/ html
- name: Move files
run: mv docs/_build/html pydocs
- name: Deploy docs
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: python/pydocs
destination_dir:
${{ env.BRANCH_NAME == 'main' && 'python/' || format('python/branch/{0}', env.BRANCH_NAME) }}
- name: Display CI docs URL
run: echo https://www.ewatercycle.org/remotebmi/${{ env.BRANCH_NAME == 'main' && 'python/' || format('python/branch/{0}', env.BRANCH_NAME) }}