Skip to content
Merged
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
108 changes: 108 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: CI

on:
pull_request:
branches: [main]
push:
branches: [main]

permissions:
contents: read
pull-requests: read

jobs:
commitlint:
name: PR Title (Conventional Commits)
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Validate PR title
uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
types: |
feat
fix
docs
style
refactor
perf
test
build
ci
chore
revert

lint:
name: Lint & Format
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- name: Set up Python
run: uv python install 3.12

- name: Install dependencies
run: uv sync --dev

- name: Ruff lint
run: uv run ruff check src/

- name: Ruff format check
run: uv run ruff format --check src/

test:
name: Tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: backend
services:
db:
image: postgres:16-alpine
env:
POSTGRES_USER: foresight
POSTGRES_PASSWORD: foresight
POSTGRES_DB: foresight_db
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U foresight -d foresight_db"
--health-interval 5s
--health-timeout 5s
--health-retries 5
env:
DATABASE_URL: postgresql+asyncpg://foresight:foresight@localhost:5432/foresight_db
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- name: Set up Python
run: uv python install 3.12

- name: Install dependencies
run: uv sync --dev

- name: Run migrations
run: uv run alembic upgrade head

- name: Pytest
# exit code 5 = no tests collected; treat as success until tests exist
run: |
code=0
uv run pytest -q || code=$?
if [ "$code" -eq 5 ]; then echo "No tests collected yet."; exit 0; fi
exit $code
Loading