Skip to content
This repository was archived by the owner on Oct 20, 2025. It is now read-only.

Commit 4f6315d

Browse files
authored
Improved DB performance in Splade Tables + Added MySQL/PostgreSQL/SQLite tests (#115)
1 parent 41f4997 commit 4f6315d

27 files changed

+626
-152
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: run-stub-tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
stub-test:
7+
runs-on: ${{ matrix.os }}
8+
9+
strategy:
10+
fail-fast: true
11+
matrix:
12+
os: [ubuntu-latest, windows-latest]
13+
php: [8.1, 8.0]
14+
laravel: [9.*]
15+
dependency-version: [prefer-lowest, prefer-stable]
16+
17+
name: Test Stubs ${{ matrix.os }} - P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}
18+
19+
steps:
20+
- name: Setup PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: ${{ matrix.php }}
24+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, mysql, mysqli, pdo_mysql, fileinfo
25+
coverage: none
26+
27+
- name: Setup Laravel
28+
run: |
29+
composer create-project laravel/laravel:^9.3 .
30+
composer require protonemedia/laravel-splade
31+
32+
- name: Remove installed Splade (Unix)
33+
run: rm -rf vendor/protonemedia/laravel-splade
34+
if: matrix.os == 'ubuntu-latest'
35+
36+
- name: Remove installed Splade (Windows)
37+
run: rd "vendor/protonemedia/laravel-splade" /s /q
38+
shell: cmd
39+
if: matrix.os == 'windows-latest'
40+
41+
- name: Checkout code
42+
uses: actions/[email protected]
43+
with:
44+
path: "vendor/protonemedia/laravel-splade"
45+
46+
- name: Install Splade
47+
run: |
48+
composer dump
49+
php artisan splade:install
50+
51+
- name: Install NPM dependencies
52+
run: |
53+
npm i
54+
npm i autosize choices.js flatpickr
55+
56+
- name: Remove installed Splade and copy front-end build from Checkout (Unix)
57+
run: |
58+
rm -rf node_modules/@protonemedia/laravel-splade/dist
59+
cp -R vendor/protonemedia/laravel-splade/dist node_modules/@protonemedia/laravel-splade/
60+
if: matrix.os == 'ubuntu-latest'
61+
62+
- name: Remove installed Splade and copy front-end build from Checkout (Windows)
63+
run: |
64+
rd "node_modules/@protonemedia/laravel-splade/dist" /s /q
65+
mkdir "node_modules/@protonemedia/laravel-splade/dist"
66+
xcopy "vendor/protonemedia/laravel-splade/dist" "node_modules/@protonemedia/laravel-splade/dist" /E /I
67+
shell: cmd
68+
if: matrix.os == 'windows-latest'
69+
70+
- name: Compile assets
71+
run: npm run build
72+
73+
- name: Run Laravel Server (Unix)
74+
run: php artisan serve &
75+
if: matrix.os == 'ubuntu-latest'
76+
77+
- name: Run Test (Unix)
78+
run: php vendor/protonemedia/laravel-splade/TestStubs.php
79+
if: matrix.os == 'ubuntu-latest'
80+
81+
- name: Run Laravel Server (Windows) and Run Test
82+
run: |
83+
start /b cmd /v:on /c "(php artisan serve) &"
84+
php vendor/protonemedia/laravel-splade/TestStubs.php
85+
shell: cmd
86+
if: matrix.os == 'windows-latest'
87+
88+
- name: Start SSR server (Unix)
89+
run: |
90+
echo "SPLADE_SSR_ENABLED=true" >> .env
91+
node bootstrap/ssr/ssr.mjs &
92+
if: matrix.os == 'ubuntu-latest'
93+
94+
- name: Run Test command (Unix)
95+
run: php artisan splade:ssr-test
96+
if: matrix.os == 'ubuntu-latest'
97+
98+
- name: Start SSR server (Windows) and Run Test command
99+
run: |
100+
echo "SPLADE_SSR_ENABLED=true" >> .env
101+
node bootstrap/ssr/ssr.mjs &
102+
php artisan splade:ssr-test
103+
if: matrix.os == 'windows-latest'
Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
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+
uses: actions/[email protected]
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

Comments
 (0)