Skip to content

Fast api

Fast api #97

Workflow file for this run

name: CI
on:
push:
branches: [ master]
pull_request:
jobs:
python:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: profiling
POSTGRES_PASSWORD: profiling
POSTGRES_DB: website_profiling
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U profiling -d website_profiling"
--health-interval 5s
--health-timeout 3s
--health-retries 5
env:
DATABASE_URL: postgres://profiling:profiling@localhost:5432/website_profiling
WEBSITE_PROFILING_ROOT: ${{ github.workspace }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: pip install -r requirements.txt
- name: Apply migrations
run: alembic upgrade head
- name: Pytest (core, 100% coverage)
run: pytest tests/ -q -m "not browser"
- name: Pytest (reporting coverage gate)
run: |
pytest tests/reporting/ \
--cov=website_profiling.reporting --cov-config=.coveragerc.reporting \
--cov-report=term-missing --cov-fail-under=100 -q -o addopts=
- name: Pytest (tools coverage gate)
run: |
pytest tests/tools/ tests/clients/ \
--cov=website_profiling.tools --cov-config=.coveragerc.tools \
--cov-report=term-missing --cov-fail-under=100 -q -o addopts=
- name: CLI smoke
run: python -m src --help
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build backend image
run: docker build -t website-profiling:ci .
- name: Build web image
run: docker build -t website-profiling-web:ci ./web --build-arg VITE_BFF_BASE_URL=http://localhost:8090
- name: Browser crawl tests in image
run: |
docker run --rm \
website-profiling:ci \
/opt/venv/bin/pytest tests/test_crawl_fetchers.py tests/test_crawler_browser_e2e.py -m browser -q -o addopts=
- name: Compose smoke (postgres + fastapi + web)
env:
BACKEND_IMAGE: website-profiling:ci
WEB_IMAGE: website-profiling-web:ci
run: |
docker compose -f docker-compose.pull.yml up -d --wait
curl -fsS http://127.0.0.1:3000/home
docker compose -f docker-compose.pull.yml down -v
web:
runs-on: ubuntu-latest
defaults:
run:
working-directory: web
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: npm
cache-dependency-path: web/package-lock.json
- name: Install
run: npm ci
- name: Build
run: npm run build
- name: Typecheck
run: npm run typecheck
- name: Lint
run: npm run lint
- name: Test
run: npm test
files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Test FileService
run: dotnet test services/FileService/FileService.slnx
bff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Test BFF
run: dotnet test services/Bff/Bff.slnx
- name: Generated client drift gate
run: |
dotnet tool install -g NSwag.ConsoleCore
export PATH="$PATH:$HOME/.dotnet/tools"
(cd services/Bff && nswag run nswag.json)
git diff --exit-code services/Bff/src/Bff.Application/Generated/FastApiClient.g.cs \
|| (echo "::error::FastApiClient.g.cs is stale — run services/Bff/generate-client.sh and commit." && exit 1)
data:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Test Data service
run: dotnet test services/Data/Data.slnx