From 39325ad421b5fc99db76c3ac7640945f26fb6770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Mon, 23 Sep 2024 23:27:21 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20Run=20tests=20from=20Python=20en?= =?UTF-8?q?vironment=20(with=20`uv`),=20not=20from=20Docker=20container=20?= =?UTF-8?q?(#1361)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/smokeshow.yml | 2 +- .../workflows/{test.yml => test-backend.yml} | 22 +++++++++------- .github/workflows/test-docker-compose.yml | 26 +++++++++++++++++++ 3 files changed, 40 insertions(+), 10 deletions(-) rename .github/workflows/{test.yml => test-backend.yml} (70%) create mode 100644 .github/workflows/test-docker-compose.yml diff --git a/.github/workflows/smokeshow.yml b/.github/workflows/smokeshow.yml index 62aef24..90c73f5 100644 --- a/.github/workflows/smokeshow.yml +++ b/.github/workflows/smokeshow.yml @@ -2,7 +2,7 @@ name: Smokeshow on: workflow_run: - workflows: [Test] + workflows: [Test Backend] types: [completed] jobs: diff --git a/.github/workflows/test.yml b/.github/workflows/test-backend.yml similarity index 70% rename from .github/workflows/test.yml rename to .github/workflows/test-backend.yml index 1874f68..4d01336 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test-backend.yml @@ -1,4 +1,4 @@ -name: Test +name: Test Backend on: push: @@ -11,7 +11,7 @@ on: jobs: - test: + test-backend: runs-on: ubuntu-latest steps: - name: Checkout @@ -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 @@ -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 diff --git a/.github/workflows/test-docker-compose.yml b/.github/workflows/test-docker-compose.yml new file mode 100644 index 0000000..d8a3923 --- /dev/null +++ b/.github/workflows/test-docker-compose.yml @@ -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