Skip to content

Commit

Permalink
đŸ‘· Run tests from Python environment (with uv), not from Docker cont…
Browse files Browse the repository at this point in the history
…ainer (#1361)
  • Loading branch information
tiangolo authored Sep 23, 2024
1 parent b3a7794 commit 39325ad
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/smokeshow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Smokeshow

on:
workflow_run:
workflows: [Test]
workflows: [Test Backend]
types: [completed]

jobs:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: Test Backend

on:
push:
Expand All @@ -11,7 +11,7 @@ on:

jobs:

test:
test-backend:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -21,14 +21,18 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: '3.10'

- run: docker compose build
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
version: "0.4.15"
- run: docker compose down -v --remove-orphans
- run: docker compose up -d
- name: Lint
run: docker compose exec -T backend bash scripts/lint.sh
- run: docker compose up -d db mailcatcher
- name: Migrate DB
run: uv run bash scripts/prestart.sh
working-directory: backend
- name: Run tests
run: docker compose exec -T backend bash scripts/tests-start.sh "Coverage for ${{ github.sha }}"
run: uv run 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@v4
Expand All @@ -41,7 +45,7 @@ jobs:
alls-green: # This job does nothing and is only used for the branch protection
if: always()
needs:
- test
- test-backend
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/test-docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test Docker Compose

on:
push:
branches:
- master
pull_request:
types:
- opened
- synchronize

jobs:

test-docker-compose:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- run: docker compose build
- run: docker compose down -v --remove-orphans
- run: docker compose up -d --wait
- name: Test backend is up
run: curl http://localhost:8000/api/v1/utils/health-check
- name: Test frontend is up
run: curl http://localhost:5173
- run: docker compose down -v --remove-orphans

0 comments on commit 39325ad

Please sign in to comment.