Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a github action to test the docker compose app #50

Merged
merged 8 commits into from
Feb 14, 2024
52 changes: 45 additions & 7 deletions .github/workflows/startup-tests.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
name: Startup Functional Tests
name: Startup Tests

on:
pull_request:
workflow_dispatch:

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:
Expand Down Expand Up @@ -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 "[email protected] 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
6 changes: 3 additions & 3 deletions frontend/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Loading