blob: 6ca40d44680349357a7355eaa360cf43d6d817d8 [file]
name: Backend
on:
push:
branches: [main, master]
paths:
- "backend/**"
- "pyproject.toml"
- "uv.lock"
- "config.yaml.example"
- ".github/workflows/backend.yml"
pull_request:
paths:
- "backend/**"
- "pyproject.toml"
- "uv.lock"
- "config.yaml.example"
- ".github/workflows/backend.yml"
workflow_dispatch:
permissions:
contents: read
concurrency:
group: backend-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
name: Lint and types
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
enable-cache: true
- name: Install dependencies
run: uv sync --all-groups
- name: ruff
run: uv run ruff check backend
- name: ruff format check
run: uv run ruff format --check backend
- name: mypy
run: uv run mypy
test:
name: Tests (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --all-groups
- name: pytest
run: uv run pytest --cov=backend/asfcalendar --cov-report=term-missing --cov-report=xml
- name: Upload coverage
if: matrix.python-version == '3.12'
uses: actions/upload-artifact@v4
with:
name: backend-coverage
path: coverage.xml
if-no-files-found: warn
smoke:
name: Starts up
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
enable-cache: true
- name: Install dependencies
run: uv sync --all-groups
# The unit tests use the Quart test client, which never binds a socket.
# This checks the real server comes up and answers.
- name: Boot the server and call it
run: |
uv run asf-calendar --port 8099 &
server=$!
for attempt in $(seq 1 30); do
if curl -sf http://127.0.0.1:8099/api/healthz > /dev/null; then break; fi
sleep 1
done
curl -sf http://127.0.0.1:8099/api/healthz
curl -sf http://127.0.0.1:8099/api/events
kill "$server"