Skip to content

Derive JSON Schema from Python type hints in OpenAPI output #30

Derive JSON Schema from Python type hints in OpenAPI output

Derive JSON Schema from Python type hints in OpenAPI output #30

Workflow file for this run

name: Continuous Integration (uv)
# MIGRATION NOTE: PyPI auth changed: set secrets.PYPI_PASSWORD to a PyPI API token (uv publish uses UV_PUBLISH_TOKEN, mapped from PYPI_PASSWORD)
# MIGRATION NOTE: Old CI references setup.cfg - ensure project is migrated to pyproject.toml first (use: wads-migrate setup-to-pyproject)
on: [push, pull_request]
# Note: Environment variables (PROJECT_NAME and vars from [tool.wads.ci.env])
# are set by the read-ci-config action in the setup job and made available
# to all subsequent jobs via GITHUB_ENV
jobs:
# First job: Read configuration from pyproject.toml
setup:
name: Read Configuration
runs-on: ubuntu-latest
outputs:
project-name: ${{ steps.config.outputs.project-name }}
python-versions: ${{ steps.config.outputs.python-versions }}
pytest-args: ${{ steps.config.outputs.pytest-args }}
coverage-enabled: ${{ steps.config.outputs.coverage-enabled }}
exclude-paths: ${{ steps.config.outputs.exclude-paths }}
test-on-windows: ${{ steps.config.outputs.test-on-windows }}
build-sdist: ${{ steps.config.outputs.build-sdist }}
build-wheel: ${{ steps.config.outputs.build-wheel }}
metrics-enabled: ${{ steps.config.outputs.metrics-enabled }}
metrics-config-path: ${{ steps.config.outputs.metrics-config-path }}
metrics-storage-branch: ${{ steps.config.outputs.metrics-storage-branch }}
metrics-python-version: ${{ steps.config.outputs.metrics-python-version }}
metrics-force-run: ${{ steps.config.outputs.metrics-force-run }}
ruff-enabled: ${{ steps.config.outputs.ruff-enabled }}
black-enabled: ${{ steps.config.outputs.black-enabled }}
mypy-enabled: ${{ steps.config.outputs.mypy-enabled }}
docs-enabled: ${{ steps.config.outputs.docs-enabled }}
steps:
- uses: actions/checkout@v6
- name: Set up uv
uses: astral-sh/setup-uv@v7
- name: Set up Python
run: uv python install 3.11
- name: Read CI Config
id: config
uses: i2mint/wads/actions/read-ci-config@master
with:
pyproject-path: .
# Second job: Validation using the config
validation:
name: Validation
if: "!contains(github.event.head_commit.message, '[skip ci]')"
needs: setup
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ${{ fromJson(needs.setup.outputs.python-versions) }}
steps:
- uses: actions/checkout@v6
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Set up Python ${{ matrix.python-version }}
uses: i2mint/wads/actions/setup-python-uv@master
with:
python-version: ${{ matrix.python-version }}
- name: Install System Dependencies
uses: i2mint/wads/actions/install-system-deps@master
with:
pyproject-path: .
- name: Install Dependencies
uses: i2mint/wads/actions/install-deps-uv@master
- name: Format Source Code
if: needs.setup.outputs.ruff-enabled != 'false'
run: uvx ruff format .
- name: Format Source Code (black)
if: needs.setup.outputs.black-enabled == 'true'
run: uvx black .
- name: Lint Validation
if: needs.setup.outputs.ruff-enabled != 'false'
run: uvx ruff check --output-format=github ${{ needs.setup.outputs.project-name }}
- name: Type Check (mypy)
if: needs.setup.outputs.mypy-enabled == 'true'
run: uvx mypy ${{ needs.setup.outputs.project-name }}
- name: Run Tests
uses: i2mint/wads/actions/run-tests-uv@master
with:
root-dir: ${{ needs.setup.outputs.project-name }}
pytest-args: ${{ needs.setup.outputs.pytest-args }}
exclude-paths: ${{ needs.setup.outputs.exclude-paths }}
coverage: ${{ needs.setup.outputs.coverage-enabled }}
- name: Track Code Metrics
if: needs.setup.outputs.metrics-enabled == 'true'
uses: i2mint/umpyre/actions/track-metrics@master
continue-on-error: true
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
config-path: ${{ needs.setup.outputs.metrics-config-path }}
storage-branch: ${{ needs.setup.outputs.metrics-storage-branch }}
python-version: ${{ needs.setup.outputs.metrics-python-version }}
force-run: ${{ needs.setup.outputs.metrics-force-run }}
# Optional Windows testing (if enabled in config)
windows-validation:
name: Windows Tests
if: "!contains(github.event.head_commit.message, '[skip ci]') && needs.setup.outputs.test-on-windows == 'true'"
needs: setup
runs-on: windows-latest
continue-on-error: true
steps:
- uses: actions/checkout@v6
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Set up Python
uses: i2mint/wads/actions/setup-python-uv@master
with:
python-version: ${{ fromJson(needs.setup.outputs.python-versions)[0] }}
- name: Install System Dependencies
uses: i2mint/wads/actions/install-system-deps@master
with:
pyproject-path: .
- name: Install Dependencies
uses: i2mint/wads/actions/install-deps-uv@master
- name: Run Tests
uses: i2mint/wads/actions/run-tests-uv@master
with:
root-dir: ${{ needs.setup.outputs.project-name }}
pytest-args: ${{ needs.setup.outputs.pytest-args }}
exclude-paths: ${{ needs.setup.outputs.exclude-paths }}
# Publishing job
publish:
name: Publish
permissions:
contents: write
if: "!contains(github.event.head_commit.message, '[skip ci]') && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')"
needs: [setup, validation]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up uv
uses: astral-sh/setup-uv@v7
- name: Set up Python
uses: i2mint/wads/actions/setup-python-uv@master
with:
python-version: ${{ fromJson(needs.setup.outputs.python-versions)[0] }}
create-venv: "false"
- name: Format Source Code
if: needs.setup.outputs.ruff-enabled != 'false'
run: uvx ruff format .
- name: Format Source Code (black)
if: needs.setup.outputs.black-enabled == 'true'
run: uvx black .
- name: Update Version Number
id: version
uses: i2mint/isee/actions/bump-version-number@master
- name: Build Distribution
uses: i2mint/wads/actions/build-dist-uv@master
with:
sdist: ${{ needs.setup.outputs.build-sdist }}
wheel: ${{ needs.setup.outputs.build-wheel }}
- name: Publish to PyPI
uses: i2mint/wads/actions/pypi-publish-uv@master
with:
pypi-token: ${{ secrets.PYPI_PASSWORD }}
- name: Force SSH for git remote
run: git remote set-url origin git@github.com:${{ github.repository }}.git
- name: Commit Changes
uses: i2mint/wads/actions/git-commit@master
with:
commit-message: "**CI** Formatted code + Updated version to ${{ env.VERSION }} [skip ci]"
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
push: true
- name: Tag Repository
uses: i2mint/wads/actions/git-tag@master
with:
tag: ${{ env.VERSION }}
message: "Release version ${{ env.VERSION }}"
push: true
# Optional GitHub Pages (skipped when [tool.wads.ci.docs].enabled = false)
github-pages:
name: Publish GitHub Pages
permissions:
contents: write
pages: write
id-token: write
if: "!contains(github.event.head_commit.message, '[skip ci]') && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && needs.setup.outputs.docs-enabled != 'false'"
needs: [setup, publish]
runs-on: ubuntu-latest
steps:
- uses: i2mint/epythet/actions/publish-github-pages@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
ignore: "tests/,scrap/,examples/"