diff --git a/.github/workflows/startup-tests.yml b/.github/workflows/startup-tests.yml index 51d3ac183..560c20539 100644 --- a/.github/workflows/startup-tests.yml +++ b/.github/workflows/startup-tests.yml @@ -1,4 +1,4 @@ -name: Startup Functional Tests +name: Startup Tests on: pull_request: @@ -6,13 +6,12 @@ on: env: GITHUB_WORKFLOW: github_actions + backend-directory: ./backend + working-directory: ./frontend jobs: - startup-tests: + startup-functional-test: runs-on: ubuntu-latest - env: - backend-directory: ./backend - working-directory: ./frontend services: postgres: @@ -88,8 +87,47 @@ jobs: - uses: actions/upload-artifact@v4 if: always() with: - name: startup-tests-report + name: startup-functional-test-report path: | - ${{ env.working-directory }}/tests/results/ ${{ env.working-directory }}/tests/reports/ + retention-days: 5 + startup-docker-compose-test: + runs-on: ubuntu-latest + env: + COMPOSE_TEST: True + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: latest + - name: Install dependencies + working-directory: ${{ env.working-directory }} + run: | + npm install + npm ci + - name: Install Playwright Browsers + working-directory: ${{ env.working-directory }} + run: npx playwright install --with-deps + - name: Build the Docker app + run: docker compose up -d --build + - name: Create backend environment variables file + working-directory: ${{ env.backend-directory }} + run: | + touch .env + echo DJANGO_SECRET_KEY=${{ secrets.DJANGO_SECRET_KEY }} >> .env + export $(grep -v '^#' .env | xargs) + - name: Config the Docker app + run: | + docker compose exec backend python manage.py migrate + docker compose exec backend /bin/bash -c "DJANGO_SUPERUSER_EMAIL=admin@tests.com DJANGO_SUPERUSER_PASSWORD=1234 python manage.py createsuperuser --noinput" + - name: Run tests + working-directory: ${{ env.working-directory }} + run: npx playwright test tests/functional/startup.test.ts + - uses: actions/upload-artifact@v4 + if: always() + with: + name: startup-docker-test-report + path: | + ${{ env.working-directory }}/tests/reports/ + ${{ env.working-directory }}/tests/results/ retention-days: 5 \ No newline at end of file diff --git a/frontend/playwright.config.ts b/frontend/playwright.config.ts index a61b39f30..2823fb463 100644 --- a/frontend/playwright.config.ts +++ b/frontend/playwright.config.ts @@ -3,9 +3,9 @@ import { devices } from '@playwright/test'; const config: PlaywrightTestConfig = { webServer: { - command: 'npm run build && npm run preview', - port: 4173, - reuseExistingServer: !process.env.CI, + command: process.env.COMPOSE_TEST ? 'echo "The docker compose frontend server didn\'t start correctly"' : 'npm run build && npm run preview', + port: process.env.COMPOSE_TEST ? 3000 : 4173, + reuseExistingServer: process.env.COMPOSE_TEST }, testDir: 'tests', outputDir: 'tests/results',