Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/Dockerfile.test-db
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Dockerfile.test-db
FROM mirror.gcr.io/library/mariadb:lts

ENV MARIADB_DATABASE=librebooking
ENV MARIADB_ROOT_PASSWORD=devpass
ENV MARIADB_USER=lb_user
ENV MARIADB_PASSWORD=password

COPY database_schema/init.sql /docker-entrypoint-initdb.d/init.sql

150 changes: 150 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
name: E2E Tests

on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- develop
- e2e
push:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

permissions:
contents: read
packages: read

jobs:
e2e:
runs-on: ubuntu-latest

services:
mariadb:
image: ghcr.io/barakiva/librebooking-test-db:latest
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
ports:
- 3306:3306
options: >-
--health-cmd="mariadb-admin ping -h 127.0.0.1 -ulb_user -ppassword"
--health-interval=5s
--health-timeout=3s
--health-retries=10

steps:
- name: Checkout code
uses: actions/checkout@v6.0.3
- name: Install MySQL client
run: which mysql || (sudo apt-get update -qq && sudo apt-get install -y default-mysql-client)

- name: Cache PHP extensions
id: cache-extensions
uses: shivammathur/cache-extensions@v1
with:
php-version: '8.5'
extensions: intl, mysqli, pdo_mysql
key: php-ext-v1

- name: Set up PHP 8.5
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
extensions: intl, mysqli, pdo_mysql
extensions-cache-key: ${{ steps.cache-extensions.outputs.key }}

- name: Cache Composer vendor
uses: actions/cache@v4
with:
path: vendor/
key: composer-${{ hashFiles('composer.lock') }}

- name: Install Composer dependencies
uses: ramsey/composer-install@v4
with:
composer-options: '--no-dev'

- name: Generate test config
env:
CI: 'true'
LB_TEST_DB_HOST: '127.0.0.1'
LB_TEST_DB_PORT: '3306'
LB_TEST_DB_NAME: 'librebooking'
LB_TEST_DB_USER: 'lb_user'
LB_TEST_DB_PASSWORD: 'password'
LB_TEST_BASE_URL: 'http://localhost:8080'
run: php tests/Integration/create-test-config.php

- name: Create template cache directory
run: mkdir -p tpl_c

- name: Start PHP development server
run: |
nohup php -S localhost:8080 -t Web > /tmp/php-server.log 2>&1 &
sleep 2
if ! ps aux | grep -v grep | grep "php -S"; then
echo "PHP server failed to start"
cat /tmp/php-server.log
exit 1
fi

- name: Wait for PHP server to be ready
run: |
for i in $(seq 1 30); do
if curl -sf http://localhost:8080/ > /dev/null 2>&1; then
echo "Server ready after $i attempts"
break
fi
echo "Waiting for server... ($i/30)"
if [ $i -eq 30 ]; then
echo "Server failed to respond"
cat /tmp/php-server.log
exit 1
fi
sleep 1
done

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'npm'
- name: Install npm dependencies
run: npm ci
- name: Cache Playwright browsers
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ hashFiles('package-lock.json') }}

- name: Install Playwright browsers
run: npx playwright install chromium --with-deps

- name: Create Playwright auth directory
run: mkdir -p tests/playwright/.auth

- name: Smoke-check server response
run: |
echo "=== PHP server log ==="
cat /tmp/php-server.log || true
echo "=== HTTP status ==="
curl -s -o /dev/null -w '%{http_code}\n' http://localhost:8080/
echo "=== Response body ==="
curl -sL http://localhost:8080/ | grep -v '^\s*$' | tail -n +50 | head -40

- name: Run E2E tests
run: npx playwright test

- name: Dump PHP server log
if: failure()
run: cat /tmp/php-server.log || true

- name: Upload Playwright report
uses: actions/upload-artifact@v4
if: failure()
with:
name: playwright-report
path: playwright-report/
retention-days: 7
40 changes: 40 additions & 0 deletions .github/workflows/test-db.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build Test DB Image

on:
push:
branches: [develop,e2e]
workflow_dispatch: {}

permissions:
contents: read
packages: write

jobs:
build-db-image:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6.0.3

- name: Compute lowercase image name
id: vars
run: echo "owner=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push test-db image
uses: docker/build-push-action@v6
with:
context: .
file: .github/workflows/Dockerfile.test-db
push: true
tags: |
ghcr.io/${{ steps.vars.outputs.owner }}/librebooking-test-db:latest
ghcr.io/${{ steps.vars.outputs.owner }}/librebooking-test-db:${{ github.sha }}

7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,10 @@ php8-report.log
# phpunit cache
.phpunit.cache/
.env

# Playwright
tests/playwright/.auth/
/test-results/
playwright-report/
blob-report/
tests/**/user.json
Loading
Loading