|
| 1 | +name: Front End Tests On Pull Request |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, reopened, edited, synchronize] |
| 6 | + branches: ["main"] |
| 7 | + |
| 8 | +jobs: |
| 9 | + |
| 10 | + js-unit-tests: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - name: Check out repository code |
| 14 | + uses: actions/checkout@v4 |
| 15 | + - name: Set up Node.js |
| 16 | + uses: actions/setup-node@v4 |
| 17 | + with: |
| 18 | + node-version: '22' |
| 19 | + cache: 'yarn' |
| 20 | + - name: Install JS dependencies |
| 21 | + run: yarn install --frozen-lockfile |
| 22 | + - name: Run Jest unit tests |
| 23 | + run: yarn test:unit:ci |
| 24 | + - name: Upload Jest coverage |
| 25 | + uses: actions/upload-artifact@v4 |
| 26 | + if: always() |
| 27 | + with: |
| 28 | + name: jest-coverage |
| 29 | + path: tests/js/coverage |
| 30 | + retention-days: 5 |
| 31 | + |
| 32 | + e2e-tests: |
| 33 | + runs-on: ubuntu-latest |
| 34 | + env: |
| 35 | + APP_ENV: testing |
| 36 | + APP_DEBUG: true |
| 37 | + APP_KEY: base64:4vh0op/S1dAsXKQ2bbdCfWRyCI9r8NNIdPXyZWt9PX4= |
| 38 | + APP_URL: http://localhost:8001 |
| 39 | + DEV_EMAIL_TO: smarcet@gmail.com |
| 40 | + DB_CONNECTION: mysql |
| 41 | + DB_HOST: 127.0.0.1 |
| 42 | + DB_PORT: 3306 |
| 43 | + DB_DATABASE: idp_test |
| 44 | + DB_USERNAME: root |
| 45 | + DB_PASSWORD: 1qaz2wsx |
| 46 | + REDIS_HOST: 127.0.0.1 |
| 47 | + REDIS_PORT: 6379 |
| 48 | + REDIS_DB: 0 |
| 49 | + REDIS_PASSWORD: 1qaz2wsx |
| 50 | + REDIS_DATABASES: 16 |
| 51 | + SSL_ENABLED: false |
| 52 | + SESSION_DRIVER: redis |
| 53 | + SESSION_COOKIE_SECURE: false |
| 54 | + PHP_VERSION: 8.3 |
| 55 | + OTEL_SDK_DISABLED: true |
| 56 | + OTEL_SERVICE_ENABLED: false |
| 57 | + TURNSTILE_SITE_KEY: '' |
| 58 | + TURNSTILE_SECRET_KEY: '' |
| 59 | + services: |
| 60 | + mysql: |
| 61 | + image: mysql:8.0 |
| 62 | + env: |
| 63 | + MYSQL_ROOT_PASSWORD: 1qaz2wsx |
| 64 | + MYSQL_DATABASE: idp_test |
| 65 | + ports: |
| 66 | + - 3306:3306 |
| 67 | + options: >- |
| 68 | + --health-cmd="mysqladmin ping" |
| 69 | + --health-interval=10s |
| 70 | + --health-timeout=5s |
| 71 | + --health-retries=3 |
| 72 | + steps: |
| 73 | + - name: Create Redis |
| 74 | + uses: supercharge/redis-github-action@1.8.1 |
| 75 | + with: |
| 76 | + redis-port: 6379 |
| 77 | + redis-password: 1qaz2wsx |
| 78 | + - name: Check out repository code |
| 79 | + uses: actions/checkout@v4 |
| 80 | + - name: Install PHP |
| 81 | + uses: shivammathur/setup-php@v2 |
| 82 | + with: |
| 83 | + php-version: ${{ env.PHP_VERSION }} |
| 84 | + extensions: pdo_mysql, mbstring, exif, pcntl, bcmath, sockets, gettext, apcu |
| 85 | + - name: Install PHP dependencies |
| 86 | + uses: ramsey/composer-install@v3 |
| 87 | + env: |
| 88 | + COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.PAT }}"} }' |
| 89 | + - name: Set up Node.js |
| 90 | + uses: actions/setup-node@v4 |
| 91 | + with: |
| 92 | + node-version: '22' |
| 93 | + cache: 'yarn' |
| 94 | + - name: Install JS dependencies |
| 95 | + run: yarn install --frozen-lockfile |
| 96 | + - name: Build frontend assets |
| 97 | + run: yarn build |
| 98 | + - name: Prepare application |
| 99 | + run: | |
| 100 | + cp .env.example .env |
| 101 | + ./update_doctrine.sh |
| 102 | + php artisan doctrine:migrations:migrate --no-interaction |
| 103 | + php artisan db:seed --force |
| 104 | + php artisan idp:create-super-admin test@test.com '1Qaz2wsx!' |
| 105 | + php artisan idp:create-raw-user e2e@test.com '1Qaz2wsx!' |
| 106 | + - name: Install Playwright Chromium |
| 107 | + run: npx playwright install --with-deps chromium |
| 108 | + - name: Start web server |
| 109 | + run: php artisan serve --host=127.0.0.1 --port=8001 & |
| 110 | + - name: Wait for server to be ready |
| 111 | + run: | |
| 112 | + for i in $(seq 1 20); do |
| 113 | + curl -sf http://localhost:8001 > /dev/null 2>&1 && echo "Server ready" && exit 0 |
| 114 | + sleep 2 |
| 115 | + done |
| 116 | + echo "Server did not start in time" && exit 1 |
| 117 | + - name: Run E2E tests |
| 118 | + run: yarn test:e2e --reporter=list |
| 119 | + - name: Upload Playwright report |
| 120 | + uses: actions/upload-artifact@v4 |
| 121 | + if: always() |
| 122 | + with: |
| 123 | + name: playwright-report |
| 124 | + path: tests/e2e/report |
| 125 | + retention-days: 7 |
| 126 | + - name: Upload Playwright traces |
| 127 | + uses: actions/upload-artifact@v4 |
| 128 | + if: failure() |
| 129 | + with: |
| 130 | + name: playwright-traces |
| 131 | + path: test-results/ |
| 132 | + retention-days: 7 |
0 commit comments