Skip to content

chore(repo): back-merge main into dev after v0.2.17 release (#270) #536

chore(repo): back-merge main into dev after v0.2.17 release (#270)

chore(repo): back-merge main into dev after v0.2.17 release (#270) #536

Workflow file for this run

name: CI
on:
push:
branches:
- main
- dev
- 'release-please--branches--**' # Release-please branches (e.g., release-please--branches--main--components--forecastlabai)
pull_request:
branches: [main, dev]
workflow_dispatch:
inputs:
ref:
description: 'Branch or ref to run CI on (leave empty to use triggering ref)'
required: false
type: string
# Cancel in-progress runs on same branch
concurrency:
group: ${{ github.workflow }}-${{ inputs.ref || github.ref }}
cancel-in-progress: true
env:
PYTHON_VERSION: "3.12"
UV_VERSION: "0.5"
# Resolve the ref to checkout: use input if provided, otherwise use github.ref
CHECKOUT_REF: ${{ inputs.ref || github.ref }}
jobs:
lint:
name: Lint & Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: ${{ env.CHECKOUT_REF }}
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Set up Python
run: uv python install ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: uv sync --frozen --all-extras --dev
- name: Run Ruff linter
run: uv run --frozen ruff check .
- name: Run Ruff formatter check
run: uv run --frozen ruff format --check .
typecheck:
name: Type Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: ${{ env.CHECKOUT_REF }}
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Set up Python
run: uv python install ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: uv sync --frozen --all-extras --dev
- name: Run MyPy
run: uv run --frozen mypy app/
- name: Run Pyright
run: uv run --frozen pyright app/
test:
name: Test
runs-on: ubuntu-latest
services:
postgres:
image: pgvector/pgvector:pg16
env:
POSTGRES_USER: forecastlab
POSTGRES_PASSWORD: forecastlab
POSTGRES_DB: forecastlab_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v6
with:
ref: ${{ env.CHECKOUT_REF }}
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Set up Python
run: uv python install ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: uv sync --frozen --all-extras --dev
- name: Run migrations
env:
DATABASE_URL: postgresql+asyncpg://forecastlab:forecastlab@localhost:5432/forecastlab_test
run: uv run --frozen alembic upgrade head
- name: Run tests
env:
DATABASE_URL: postgresql+asyncpg://forecastlab:forecastlab@localhost:5432/forecastlab_test
APP_ENV: testing
run: uv run --frozen pytest -v --tb=short
migration-check:
name: Migration Check
runs-on: ubuntu-latest
services:
postgres:
image: pgvector/pgvector:pg16
env:
POSTGRES_USER: forecastlab
POSTGRES_PASSWORD: forecastlab
POSTGRES_DB: forecastlab_migration_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v6
with:
ref: ${{ env.CHECKOUT_REF }}
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Set up Python
run: uv python install ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: uv sync --frozen --all-extras --dev
- name: Apply migrations to fresh DB
env:
DATABASE_URL: postgresql+asyncpg://forecastlab:forecastlab@localhost:5432/forecastlab_migration_test
run: uv run --frozen alembic upgrade head
- name: Verify no pending migrations
env:
DATABASE_URL: postgresql+asyncpg://forecastlab:forecastlab@localhost:5432/forecastlab_migration_test
run: |
# Check that current head matches database
uv run --frozen alembic current
# This would fail if there are unapplied migrations