Skip to content

e2e test fix

e2e test fix #1188

name: End-to-end Tests
on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- main
- master
- develop
pull_request:
jobs:
playwright-e2e:
runs-on: ubuntu-latest
services:
mailhog:
image: mailhog/mailhog
ports:
- 1025:1025 # smtp server
- 8025:8025 # web ui
postgres:
image: postgres
env:
POSTGRES_DB: default
POSTGRES_USER: default
POSTGRES_PASSWORD: secret
TZ: Europe/Warsaw
ports:
- 5432:5432
options: >-
--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
redis:
image: redis
options: >-
--health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
api:
image: escolalms/api:latest
env:
LARAVEL_APP_NAME: Wellms Playwright Demo
LARAVEL_APP_ENV: local
LARAVEL_APP_KEY: base64:pveos6JL8iCwO3MbzoyQpNx6TETMYuUpfZ18CDKl6Cw=
LARAVEL_APP_DEBUG: true
LARAVEL_APP_LOG_LEVEL: debug
LARAVEL_APP_URL: http://api.localhost
LARAVEL_DB_CONNECTION: pgsql
LARAVEL_DB_HOST: postgres
LARAVEL_DB_PORT: 5432
LARAVEL_DB_DATABASE: default
LARAVEL_DB_USERNAME: default
LARAVEL_DB_PASSWORD: secret
LARAVEL_BROADCAST_DRIVER: log
LARAVEL_CACHE_DRIVER: redis
LARAVEL_SESSION_DRIVER: cookie
LARAVEL_QUEUE_DRIVER: redis
LARAVEL_QUEUE_CONNECTION: redis
LARAVEL_REDIS_HOST: redis
LARAVEL_REDIS_PASSWORD:
LARAVEL_REDIS_PORT: 6379
LARAVEL_MAIL_DRIVER: smtp
LARAVEL_MAIL_HOST: mailhog
LARAVEL_MAIL_PORT: 1025
LARAVEL_MAIL_USERNAME: null
LARAVEL_MAIL_PASSWORD: null
LARAVEL_MAIL_ENCRYPTION:
LARAVEL_MJML_BINARY_PATH: /usr/bin/mjml
LARAVEL_TRACKER_ENABLED: false
LARAVEL_INITIAL_USER_PASSWORD: secret
DISABLE_HORIZON: true
DISABLE_SCHEDULER: true
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Run Caddy container with custom Caddyfile
run: |
docker run -d \
-p 80:80 \
--name caddy \
--network ${{ job.container.network }} \
-e CADDY_CONFIG="http://api.localhost {
encode zstd gzip
reverse_proxy api:9000 {
header_up -Access-Control-Allow-Origin
header_down -Access-Control-Allow-Origin
transport fastcgi {
env SCRIPT_FILENAME /var/www/html/index.php
}
}
@origin header Origin {http.request.header.Origin}
header @origin Access-Control-Allow-Origin {http.request.header.Origin}
@excluded {
not header Origin {http.request.header.Origin}
}
header @excluded Access-Control-Allow-Origin *
header Access-Control-Allow-Credentials true
}" \
caddy sh -c 'echo "$CADDY_CONFIG" > /etc/caddy/Caddyfile && caddy run --config /etc/caddy/Caddyfile'
- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Test login endpoint
run: |
curl -X POST "http://api.localhost/api/auth/login" \
-H "Content-Type: application/json" \
-d '{"email": "admin@escolalms.com", "password": "secret"}' \
-i
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
name: List the state of node modules
continue-on-error: true
run: npm list
- name: Node dependencies
run: npm i --legacy-peer-deps
- name: Build
run: cp .env.ci .env && REACT_APP_API_URL=http://api.localhost npm run --openssl-legacy-provider build
- name: Install Playwright
run: npx playwright install --with-deps
- name: Run your tests
run: npm run test:e2e
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: test-results