Skip to content

Commit

Permalink
add a github action to test the docker compose app
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexdev8 committed Feb 14, 2024
1 parent 6ee8be7 commit fd4241c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 9 deletions.
50 changes: 43 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,45 @@ jobs:
- uses: actions/upload-artifact@v4
if: always()
with:
name: startup-tests-report
name: startup-functional-test-report
path: |
${{ env.working-directory }}/tests/reports/
${{ env.working-directory }}/tests/results/
retention-days: 30
startup-docker-compose-test:
runs-on: ubuntu-latest
env:
DJANGO_SUPERUSER_EMAIL: [email protected]
DJANGO_SUPERUSER_PASSWORD: 1234
DJANGO_SECRET_KEY: ${{ secrets.DJANGO_SECRET_KEY }}
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: Config the Docker app
run: |
docker compose exec backend python manage.py migrate
docker compose exec backend 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: 30
retention-days: 5
5 changes: 3 additions & 2 deletions frontend/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { devices } from '@playwright/test';

const config: PlaywrightTestConfig = {
webServer: {
command: 'npm run build && npm run preview',
port: 4173
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 fd4241c

Please sign in to comment.