|
| 1 | +name: run-table-tests |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + table-test: |
| 7 | + runs-on: ubuntu-latest |
| 8 | + strategy: |
| 9 | + fail-fast: true |
| 10 | + matrix: |
| 11 | + php: [8.1, 8.0] |
| 12 | + laravel: [9.*] |
| 13 | + db: [mysql, postgres, sqlite] |
| 14 | + ssr: [true, false] |
| 15 | + dependency-version: [prefer-lowest, prefer-stable] |
| 16 | + exclude: |
| 17 | + - db: mysql |
| 18 | + ssr: true |
| 19 | + - db: postgres |
| 20 | + ssr: true |
| 21 | + |
| 22 | + name: Test P${{ matrix.php }} - L${{ matrix.laravel }} - DB ${{ matrix.db }} - SSR ${{ matrix.ssr }} - ${{ matrix.dependency-version }} |
| 23 | + |
| 24 | + services: |
| 25 | + mysql: |
| 26 | + image: mysql:8.0 |
| 27 | + env: |
| 28 | + MYSQL_ALLOW_EMPTY_PASSWORD: no |
| 29 | + MYSQL_USER: protone_media_db_test |
| 30 | + MYSQL_DATABASE: protone_media_db_test_mysql |
| 31 | + MYSQL_PASSWORD: secret |
| 32 | + MYSQL_ROOT_PASSWORD: secret |
| 33 | + ports: |
| 34 | + - 3306 |
| 35 | + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 |
| 36 | + postgres: |
| 37 | + image: postgres:15.0 |
| 38 | + env: |
| 39 | + POSTGRES_USER: protone_media_db_test |
| 40 | + POSTGRES_PASSWORD: secret |
| 41 | + POSTGRES_DB: protone_media_db_test_postgres |
| 42 | + ports: |
| 43 | + - 5432:5432 |
| 44 | + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 |
| 45 | + |
| 46 | + steps: |
| 47 | + - name: Checkout code |
| 48 | + |
| 49 | + |
| 50 | + - name: Cache node modules |
| 51 | + id: cache-npm |
| 52 | + uses: actions/cache@v3 |
| 53 | + env: |
| 54 | + cache-name: cache-node-modules |
| 55 | + with: |
| 56 | + # npm cache files are stored in `~/.npm` on Linux/macOS |
| 57 | + path: ~/.npm |
| 58 | + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} |
| 59 | + restore-keys: | |
| 60 | + ${{ runner.os }}-build-${{ env.cache-name }}- |
| 61 | + ${{ runner.os }}-build- |
| 62 | + ${{ runner.os }}- |
| 63 | +
|
| 64 | + - if: ${{ steps.cache-npm.outputs.cache-hit == 'false' }} |
| 65 | + name: List the state of node modules |
| 66 | + continue-on-error: true |
| 67 | + run: npm list |
| 68 | + |
| 69 | + - name: "Install locked dependencies with npm" |
| 70 | + run: | |
| 71 | + npm ci --ignore-scripts |
| 72 | +
|
| 73 | + - name: Build package |
| 74 | + run: | |
| 75 | + npm run build |
| 76 | + npm pack |
| 77 | + rm -rf node_modules |
| 78 | +
|
| 79 | + - name: Setup PHP |
| 80 | + uses: shivammathur/setup-php@v2 |
| 81 | + with: |
| 82 | + php-version: ${{ matrix.php }} |
| 83 | + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, mysql, mysqli, pdo_mysql |
| 84 | + coverage: none |
| 85 | + |
| 86 | + - name: Prepare environment file (MySQL) |
| 87 | + if: ${{ matrix.db == 'mysql' }} |
| 88 | + run: | |
| 89 | + cd app |
| 90 | + cp .env.example.mysql .env |
| 91 | +
|
| 92 | + - name: Prepare environment file (PostgreSQL) |
| 93 | + if: ${{ matrix.db == 'postgres' }} |
| 94 | + run: | |
| 95 | + cd app |
| 96 | + cp .env.example.postgres .env |
| 97 | +
|
| 98 | + - name: Prepare environment file (SQLite) |
| 99 | + if: ${{ matrix.db == 'sqlite' }} |
| 100 | + run: | |
| 101 | + cd app |
| 102 | + cp .env.example .env |
| 103 | + touch database/database.sqlite |
| 104 | +
|
| 105 | + - name: Prepare demo app |
| 106 | + run: | |
| 107 | + cd app |
| 108 | + npm upgrade |
| 109 | + composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest |
| 110 | + npm run build |
| 111 | + php artisan dusk:chrome-driver `/opt/google/chrome/chrome --version | cut -d " " -f3 | cut -d "." -f1` |
| 112 | +
|
| 113 | + - name: Start Chrome Driver |
| 114 | + run: | |
| 115 | + cd app |
| 116 | + ./vendor/laravel/dusk/bin/chromedriver-linux & |
| 117 | +
|
| 118 | + - name: Start SSR server |
| 119 | + run: | |
| 120 | + cd app |
| 121 | + sed -i -e "s|SPLADE_SSR_ENABLED=false|SPLADE_SSR_ENABLED=true|g" .env |
| 122 | + node bootstrap/ssr/ssr.mjs & |
| 123 | + if: matrix.ssr == true |
| 124 | + |
| 125 | + - name: Migrate DB and Run Laravel Server (MySQL) |
| 126 | + run: | |
| 127 | + cd app |
| 128 | + php artisan migrate:fresh --seed |
| 129 | + php artisan serve & |
| 130 | + if: ${{ matrix.db == 'mysql' }} |
| 131 | + env: |
| 132 | + DB_PORT: ${{ job.services.mysql.ports[3306] }} |
| 133 | + |
| 134 | + - name: Migrate DB and Run Laravel Server (PostgreSQL) |
| 135 | + run: | |
| 136 | + cd app |
| 137 | + php artisan migrate:fresh --seed |
| 138 | + php artisan serve & |
| 139 | + if: ${{ matrix.db == 'postgres' }} |
| 140 | + env: |
| 141 | + DB_PORT: ${{ job.services.postgres.ports[5432] }} |
| 142 | + |
| 143 | + - name: Migrate DB and Run Laravel Server (SQLite) |
| 144 | + if: ${{ matrix.db == 'sqlite' }} |
| 145 | + run: | |
| 146 | + cd app |
| 147 | + php artisan migrate:fresh --seed |
| 148 | + php artisan serve & |
| 149 | +
|
| 150 | + - name: Execute Dusk tests (only table tests - MySQL) |
| 151 | + if: ${{ matrix.db == 'mysql' }} |
| 152 | + uses: nick-invision/retry@v2 |
| 153 | + with: |
| 154 | + timeout_minutes: 10 |
| 155 | + max_attempts: 3 |
| 156 | + command: cd app && php artisan dusk --stop-on-error --stop-on-failure --group=table |
| 157 | + env: |
| 158 | + DB_PORT: ${{ job.services.mysql.ports[3306] }} |
| 159 | + |
| 160 | + - name: Execute Dusk tests (only table tests - PostgreSQL) |
| 161 | + if: ${{ matrix.db == 'postgres' }} |
| 162 | + uses: nick-invision/retry@v2 |
| 163 | + with: |
| 164 | + timeout_minutes: 10 |
| 165 | + max_attempts: 3 |
| 166 | + command: cd app && php artisan dusk --stop-on-error --stop-on-failure --group=table |
| 167 | + env: |
| 168 | + DB_PORT: ${{ job.services.postgres.ports[5432] }} |
| 169 | + |
| 170 | + - name: Execute Dusk tests (only table tests - SQLite) |
| 171 | + if: ${{ matrix.db == 'sqlite' }} |
| 172 | + uses: nick-invision/retry@v2 |
| 173 | + with: |
| 174 | + timeout_minutes: 10 |
| 175 | + max_attempts: 3 |
| 176 | + command: cd app && php artisan dusk --stop-on-error --stop-on-failure --group=table |
| 177 | + |
| 178 | + - name: Upload Screenshots |
| 179 | + if: failure() |
| 180 | + uses: actions/upload-artifact@v3 |
| 181 | + with: |
| 182 | + name: screenshots |
| 183 | + path: app/tests/Browser/screenshots |
| 184 | + |
| 185 | + - name: Upload Snapshots |
| 186 | + if: failure() |
| 187 | + uses: actions/upload-artifact@v3 |
| 188 | + with: |
| 189 | + name: snapshots |
| 190 | + path: app/tests/Browser/__snapshots__ |
| 191 | + |
| 192 | + - name: Upload Console Logs |
| 193 | + if: failure() |
| 194 | + uses: actions/upload-artifact@v3 |
| 195 | + with: |
| 196 | + name: console |
| 197 | + path: app/tests/Browser/console |
| 198 | + |
| 199 | + - name: Upload Logs |
| 200 | + if: failure() |
| 201 | + uses: actions/upload-artifact@v3 |
| 202 | + with: |
| 203 | + name: logs |
| 204 | + path: app/storage/logs |
0 commit comments