Adding End-to-End testing (E2E) to automate and streamline QA during development #6
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: E2E Tests | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| branches: | |
| - develop | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| e2e: | |
| runs-on: ubuntu-latest | |
| services: | |
| mariadb: | |
| image: mirror.gcr.io/library/mariadb:lts | |
| env: | |
| MARIADB_ROOT_PASSWORD: root | |
| MARIADB_DATABASE: librebooking_test | |
| ports: | |
| - 3306:3306 | |
| options: >- | |
| --health-cmd="mariadb-admin ping -h 127.0.0.1" | |
| --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: Load database schema | |
| run: mysql -h 127.0.0.1 -u root -proot librebooking_test < database_schema/create-schema.sql | |
| - name: Apply database upgrades | |
| run: php phing-tasks/UpgradeDbTask.php root root 127.0.0.1 librebooking_test database_schema | |
| - name: Load base data | |
| run: mysql -h 127.0.0.1 -u root -proot librebooking_test < database_schema/create-data.sql | |
| - name: Load sample data | |
| run: mysql -h 127.0.0.1 -u root -proot librebooking_test < database_schema/sample-data-utf8.sql | |
| - 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_test' | |
| LB_TEST_DB_USER: 'root' | |
| LB_TEST_DB_PASSWORD: 'root' | |
| 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: php -S localhost:8080 -t Web > /tmp/php-server.log 2>&1 & | |
| - name: Wait for PHP server to be ready | |
| run: | | |
| for i in $(seq 1 15); do | |
| STATUS=$(curl -s -o /dev/null -w '%{http_code}' http://localhost:8080/ || true) | |
| if [ "$STATUS" != "000" ]; then | |
| echo "Server ready (HTTP $STATUS)" | |
| break | |
| fi | |
| echo "Waiting for server... ($i/15)" | |
| sleep 1 | |
| done | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| 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 |