Skip to content

Commit

Permalink
Merge pull request #50 from intuitem/CA-169-Test-of-the-docker-compose
Browse files Browse the repository at this point in the history
add a github action to test the docker compose app
  • Loading branch information
eric-intuitem authored Feb 14, 2024
2 parents 6227df8 + e081c57 commit 9dd0640
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 10 deletions.
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

0 comments on commit 9dd0640

Please sign in to comment.