Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.git
.env
.env.*
**/__pycache__
**/.venv
backend/htmlcov
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/deploy-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,21 @@ jobs:
if: github.repository != 'fastapi/full-stack-fastapi-template'
runs-on: self-hosted
timeout-minutes: 30
environment: production
# Required reviewers/environment protection need native owner readback before use.
env:
DOMAIN: ${{ vars.DOMAIN }}
PROJECT_NAME: ${{ vars.PROJECT_NAME }}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
FIRST_SUPERUSER: ${{ vars.FIRST_SUPERUSER }}
FIRST_SUPERUSER_PASSWORD: ${{ secrets.FIRST_SUPERUSER_PASSWORD }}
FRONTEND_HOST: ${{ vars.FRONTEND_HOST }}
WORKOS_CLIENT_ID: ${{ vars.WORKOS_CLIENT_ID }}
WORKOS_ISSUER: ${{ vars.WORKOS_ISSUER }}
WORKOS_JWKS_URL: ${{ vars.WORKOS_JWKS_URL }}
WORKOS_API_HOSTNAME: ${{ vars.WORKOS_API_HOSTNAME }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
SMTP_HOST: ${{ vars.SMTP_HOST }}
SMTP_USER: ${{ vars.SMTP_USER }}
SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }}
EMAILS_FROM_EMAIL: ${{ vars.EMAILS_FROM_EMAIL }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
SENTRY_DSN: ${{ vars.SENTRY_DSN }}
steps:
- name: Checkout
Expand All @@ -36,6 +40,8 @@ jobs:
- name: Build
run: docker compose -f compose.yml -f compose.deploy.yml build
- name: Prepare database
run: docker compose -f compose.yml -f compose.deploy.yml run --rm backend bash scripts/prestart.sh
env:
API_MIGRATION_DATABASE_URL: ${{ secrets.API_MIGRATION_DATABASE_URL }}
run: docker compose -f compose.yml -f compose.deploy.yml run --rm migrate
- name: Start application
run: docker compose -f compose.yml -f compose.deploy.yml up -d
21 changes: 11 additions & 10 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
name: Deploy

on:
push:
branches:
- master
paths-ignore:
- release-notes.md
workflow_dispatch:

permissions:
Expand All @@ -17,6 +12,16 @@ jobs:
if: github.repository != 'fastapi/full-stack-fastapi-template'
runs-on: ubuntu-latest
timeout-minutes: 15
environment: production
# Required reviewers/environment protection need native owner readback before use.
env:
PROJECT_NAME: ${{ vars.PROJECT_NAME }}
FRONTEND_HOST: ${{ vars.FRONTEND_HOST }}
WORKOS_CLIENT_ID: ${{ vars.WORKOS_CLIENT_ID }}
WORKOS_ISSUER: ${{ vars.WORKOS_ISSUER }}
WORKOS_JWKS_URL: ${{ vars.WORKOS_JWKS_URL }}
WORKOS_API_HOSTNAME: ${{ vars.WORKOS_API_HOSTNAME }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand All @@ -42,11 +47,7 @@ jobs:
run: uv run bash scripts/prestart.sh
working-directory: backend
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
PROJECT_NAME: ${{ vars.PROJECT_NAME }}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
FIRST_SUPERUSER: ${{ vars.FIRST_SUPERUSER }}
FIRST_SUPERUSER_PASSWORD: ${{ secrets.FIRST_SUPERUSER_PASSWORD }}
API_MIGRATION_DATABASE_URL: ${{ secrets.API_MIGRATION_DATABASE_URL }}
- name: Deploy to FastAPI Cloud
run: uv run fastapi deploy
env:
Expand Down
169 changes: 89 additions & 80 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ name: Playwright Tests
on:
push:
branches:
- master
- master
pull_request:
workflow_dispatch:
inputs:
debug_enabled:
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
description: "Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)"
required: false
default: 'false'
default: "false"

permissions:
contents: read
Expand All @@ -23,71 +23,80 @@ jobs:
outputs:
changed: ${{ steps.filter.outputs.changed }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 2
persist-credentials: false
# For pull requests it's not necessary to checkout the code but for the main branch it is
- uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
id: filter
with:
filters: |
changed:
- backend/**
- frontend/**
- .env
- compose*.yml
- .github/workflows/playwright.yml
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 2
persist-credentials: false
# For pull requests it's not necessary to checkout the code but for the main branch it is
- uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
id: filter
with:
filters: |
changed:
- backend/**
- frontend/**
- .env
- compose*.yml
- .github/workflows/playwright.yml

test-playwright:
needs:
- changes
if: ${{ needs.changes.outputs.changed == 'true' }}
timeout-minutes: 15
runs-on: ubuntu-latest
env:
# Browser network fixtures are not backend JWT/RLS or live WorkOS proof.
PROJECT_NAME: API browser fixture
FRONTEND_HOST: http://localhost:8000
FASTAPI_ENV: development
WORKOS_CLIENT_ID: client_fixture
WORKOS_ISSUER: https://auth.fixture.test/
WORKOS_JWKS_URL: https://auth.fixture.test/sso/jwks/client_fixture
WORKOS_API_HOSTNAME: auth.fixture.test
DATABASE_URL: postgresql+psycopg://fixture:fixture@localhost/api_test_unconfigured
strategy:
matrix:
shardIndex: [1, 2, 3, 4]
shardTotal: [4]
fail-fast: false
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: 1.3.12
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version-file: .python-version
- name: Setup tmate session
uses: mxschmitt/action-tmate@35b54afac29c97fb54faba5b513f8fbd1882f113 # v3.24
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }}
with:
limit-access-to-actor: true
- name: Install uv
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
version: "latest-known"
- run: uv sync
working-directory: backend
- run: bun ci
working-directory: frontend
- run: bash scripts/generate-client.sh
- run: docker compose build
- run: docker compose down -v --remove-orphans
- run: docker compose run --rm backend bash scripts/prestart.sh
- name: Run Playwright tests
run: docker compose run --rm playwright bunx playwright test --fail-on-flaky-tests --trace=retain-on-failure --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- run: docker compose down -v --remove-orphans
- name: Upload blob report to GitHub Actions Artifacts
if: ${{ !cancelled() }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: blob-report-${{ matrix.shardIndex }}
path: frontend/blob-report
include-hidden-files: true
retention-days: 1
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: 1.3.12
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version-file: .python-version
- name: Setup tmate session
uses: mxschmitt/action-tmate@35b54afac29c97fb54faba5b513f8fbd1882f113 # v3.24
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }}
with:
limit-access-to-actor: true
- name: Install uv
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
version: "latest-known"
- run: uv sync
working-directory: backend
- run: bun ci
working-directory: frontend
- run: bash scripts/generate-client.sh
- run: docker compose build
- run: docker compose down -v --remove-orphans
- name: Run Playwright tests
run: docker compose run --rm playwright bunx playwright test --fail-on-flaky-tests --trace=retain-on-failure --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- run: docker compose down -v --remove-orphans
- name: Upload blob report to GitHub Actions Artifacts
if: ${{ !cancelled() }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: blob-report-${{ matrix.shardIndex }}
path: frontend/blob-report
include-hidden-files: true
retention-days: 1

merge-playwright-reports:
needs:
Expand All @@ -98,33 +107,33 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: 1.3.12
- name: Install dependencies
run: bun ci
- name: Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
path: frontend/all-blob-reports
pattern: blob-report-*
merge-multiple: true
- name: Merge into HTML Report
run: bunx playwright merge-reports --reporter html ./all-blob-reports
working-directory: frontend
- name: Upload HTML report
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: html-report--attempt-${{ github.run_attempt }}
path: frontend/playwright-report
retention-days: 30
include-hidden-files: true
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: 1.3.12
- name: Install dependencies
run: bun ci
- name: Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
path: frontend/all-blob-reports
pattern: blob-report-*
merge-multiple: true
- name: Merge into HTML Report
run: bunx playwright merge-reports --reporter html ./all-blob-reports
working-directory: frontend
- name: Upload HTML report
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: html-report--attempt-${{ github.run_attempt }}
path: frontend/playwright-report
retention-days: 30
include-hidden-files: true

# https://github.com/marketplace/actions/alls-green#why
alls-green-playwright: # This job does nothing and is only used for the branch protection
alls-green-playwright: # This job does nothing and is only used for the branch protection
if: always()
needs:
- test-playwright
Expand Down
32 changes: 26 additions & 6 deletions .github/workflows/test-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ jobs:
test-backend:
runs-on: ubuntu-latest
timeout-minutes: 5
concurrency:
group: api-sql-fixture
cancel-in-progress: false
env:
DATABASE_URL: ${{ secrets.API_TEST_DATABASE_URL }}
API_MIGRATION_DATABASE_URL: ${{ secrets.API_TEST_MIGRATION_DATABASE_URL }}
API_TEST_DATABASE_URL: ${{ secrets.API_TEST_DATABASE_URL }}
API_TEST_ADMIN_DATABASE_URL: ${{ secrets.API_TEST_ADMIN_DATABASE_URL }}
API_TEST_MIGRATION_DATABASE_URL: ${{ secrets.API_TEST_MIGRATION_DATABASE_URL }}
API_TEST_SUPABASE_BRANCH_REF: ${{ vars.API_TEST_SUPABASE_BRANCH_REF }}
API_TEST_ACTORS: ${{ vars.API_TEST_ACTORS }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand All @@ -25,21 +36,30 @@ jobs:
uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
with:
version: "latest-known"
- run: docker compose down -v --remove-orphans
- run: docker compose up -d --wait db mailpit
- name: Install locked backend environment
run: uv sync --locked
working-directory: backend
- name: Require isolated SQL fixture
run: |
: "${API_TEST_DATABASE_URL:?configure an isolated runtime fixture}"
: "${API_TEST_ADMIN_DATABASE_URL:?configure an isolated fixture writer}"
: "${API_TEST_MIGRATION_DATABASE_URL:?configure isolated migration authority}"
: "${API_TEST_ACTORS:?configure canonical synthetic fixture actors}"
- name: Verify actual isolated targets before migration
run: uv run --no-active --locked --no-sync python -m tests.test_data_namespace
working-directory: backend
- name: Migrate DB
run: uv run bash scripts/prestart.sh
run: uv run --no-active --locked --no-sync bash scripts/prestart.sh
working-directory: backend
- name: Run tests
run: uv run bash scripts/tests-start.sh "Coverage for ${{ github.sha }}"
run: uv run --no-active --locked --no-sync bash scripts/tests-start.sh "Coverage for ${{ github.sha }}"
working-directory: backend
- run: docker compose down -v --remove-orphans
- name: Store coverage files
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: coverage-html
path: backend/htmlcov
include-hidden-files: true
- name: Coverage report
run: uv run coverage report --fail-under=90
run: uv run --no-active --locked --no-sync coverage report --fail-under=90
working-directory: backend
17 changes: 12 additions & 5 deletions .github/workflows/test-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,28 @@ permissions:
contents: read

jobs:

test-docker-compose:
runs-on: ubuntu-latest
timeout-minutes: 10
env:
# Public-config/UI smoke fixture only; SQL/RLS runs in Test Backend.
PROJECT_NAME: API container fixture
FRONTEND_HOST: http://localhost:8000
WORKOS_CLIENT_ID: client_fixture
WORKOS_ISSUER: https://auth.fixture.test/
WORKOS_JWKS_URL: https://auth.fixture.test/sso/jwks/client_fixture
WORKOS_API_HOSTNAME: auth.fixture.test
DATABASE_URL: postgresql+psycopg://fixture:fixture@localhost/api_test_unconfigured
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- run: docker compose build
- run: docker compose down -v --remove-orphans
- run: docker compose run --rm backend bash scripts/prestart.sh
- run: docker compose up -d --wait backend adminer
- name: Test backend is up
run: curl http://localhost:8000/api/v1/utils/health-check
- run: docker compose up -d --wait backend
- name: Test public configuration fixture
run: curl --fail http://localhost:8000/api/v1/auth/config
- name: Test frontend is up
run: curl http://localhost:8000
- run: docker compose down -v --remove-orphans
Loading
Loading