Skip to content

Commit d8d31be

Browse files
authored
Added multi-database architecture CI pipeline (alexjustesen#2295)
Co-authored-by: Alex Justesen <[email protected]>
1 parent 6b3ad59 commit d8d31be

File tree

3 files changed

+225
-11
lines changed

3 files changed

+225
-11
lines changed

.env.ci

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
APP_NAME="Speedtest Tracker"
2+
APP_KEY=

.github/workflows/ci.yml

Lines changed: 216 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,217 @@ jobs:
2121
with:
2222
args: lint --using=pint -v
2323

24-
test-app:
24+
test-mariadb-11:
25+
needs: lint-app
26+
runs-on: ubuntu-24.04
27+
services:
28+
mariadb:
29+
image: mariadb:11
30+
env:
31+
MARIADB_ROOT_PASSWORD: password
32+
MARIADB_DATABASE: testing
33+
ports:
34+
- 3306:3306
35+
options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@v4
39+
40+
- name: Setup PHP
41+
uses: shivammathur/setup-php@v2
42+
with:
43+
php-version: '8.3'
44+
45+
- name: Install Dependencies
46+
run: |
47+
composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
48+
npm ci && npm run build
49+
50+
- name: Copy Environment File
51+
run: cp .env.ci .env
52+
53+
- name: Generate App Key
54+
run: php artisan key:generate --quiet
55+
56+
- name: Run Tests
57+
run: php artisan test
58+
env:
59+
DB_CONNECTION: mysql
60+
DB_HOST: 127.0.0.1
61+
DB_PORT: 3306
62+
DB_DATABASE: testing
63+
DB_USERNAME: root
64+
DB_PASSWORD: password
65+
66+
test-mysql-8:
67+
needs: lint-app
68+
runs-on: ubuntu-24.04
69+
services:
70+
mysql:
71+
image: mysql:8
72+
env:
73+
MYSQL_ROOT_PASSWORD: password
74+
MYSQL_DATABASE: testing
75+
ports:
76+
- 3306:3306
77+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
78+
steps:
79+
- name: Checkout
80+
uses: actions/checkout@v4
81+
82+
- name: Setup PHP
83+
uses: shivammathur/setup-php@v2
84+
with:
85+
php-version: '8.3'
86+
87+
- name: Install Dependencies
88+
run: |
89+
composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
90+
npm ci && npm run build
91+
92+
- name: Copy Environment File
93+
run: cp .env.ci .env
94+
95+
- name: Generate App Key
96+
run: php artisan key:generate --quiet
97+
98+
- name: Run Tests
99+
run: php artisan test
100+
env:
101+
DB_CONNECTION: mysql
102+
DB_HOST: 127.0.0.1
103+
DB_PORT: 3306
104+
DB_DATABASE: testing
105+
DB_USERNAME: root
106+
DB_PASSWORD: password
107+
108+
test-postgres-15:
109+
needs: lint-app
110+
runs-on: ubuntu-24.04
111+
services:
112+
postgres:
113+
image: postgres:15
114+
env:
115+
POSTGRES_PASSWORD: password
116+
POSTGRES_DB: testing
117+
ports:
118+
- 5432:5432
119+
options: --health-cmd="pg_isready -U postgres" --health-interval=10s --health-timeout=5s --health-retries=3
120+
steps:
121+
- name: Checkout
122+
uses: actions/checkout@v4
123+
124+
- name: Setup PHP
125+
uses: shivammathur/setup-php@v2
126+
with:
127+
php-version: '8.3'
128+
129+
- name: Install Dependencies
130+
run: |
131+
composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
132+
npm ci && npm run build
133+
134+
- name: Copy Environment File
135+
run: cp .env.ci .env
136+
137+
- name: Generate App Key
138+
run: php artisan key:generate --quiet
139+
140+
- name: Run Tests
141+
run: php artisan test
142+
env:
143+
DB_CONNECTION: pgsql
144+
DB_HOST: 127.0.0.1
145+
DB_PORT: 5432
146+
DB_DATABASE: testing
147+
DB_USERNAME: postgres
148+
DB_PASSWORD: password
149+
150+
test-postgres-16:
151+
needs: lint-app
152+
runs-on: ubuntu-24.04
153+
services:
154+
postgres:
155+
image: postgres:16
156+
env:
157+
POSTGRES_PASSWORD: password
158+
POSTGRES_DB: testing
159+
ports:
160+
- 5432:5432
161+
options: --health-cmd="pg_isready -U postgres" --health-interval=10s --health-timeout=5s --health-retries=3
162+
steps:
163+
- name: Checkout
164+
uses: actions/checkout@v4
165+
166+
- name: Setup PHP
167+
uses: shivammathur/setup-php@v2
168+
with:
169+
php-version: '8.3'
170+
171+
- name: Install Dependencies
172+
run: |
173+
composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
174+
npm ci && npm run build
175+
176+
- name: Copy Environment File
177+
run: cp .env.ci .env
178+
179+
- name: Generate App Key
180+
run: php artisan key:generate --quiet
181+
182+
- name: Run Tests
183+
run: php artisan test
184+
env:
185+
DB_CONNECTION: pgsql
186+
DB_HOST: 127.0.0.1
187+
DB_PORT: 5432
188+
DB_DATABASE: testing
189+
DB_USERNAME: postgres
190+
DB_PASSWORD: password
191+
192+
test-postgres-17:
193+
needs: lint-app
194+
runs-on: ubuntu-24.04
195+
services:
196+
postgres:
197+
image: postgres:17
198+
env:
199+
POSTGRES_PASSWORD: password
200+
POSTGRES_DB: testing
201+
ports:
202+
- 5432:5432
203+
options: --health-cmd="pg_isready -U postgres" --health-interval=10s --health-timeout=5s --health-retries=3
204+
steps:
205+
- name: Checkout
206+
uses: actions/checkout@v4
207+
208+
- name: Setup PHP
209+
uses: shivammathur/setup-php@v2
210+
with:
211+
php-version: '8.3'
212+
213+
- name: Install Dependencies
214+
run: |
215+
composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
216+
npm ci && npm run build
217+
218+
- name: Copy Environment File
219+
run: cp .env.ci .env
220+
221+
- name: Generate App Key
222+
run: php artisan key:generate --quiet
223+
224+
- name: Run Tests
225+
run: php artisan test
226+
env:
227+
DB_CONNECTION: pgsql
228+
DB_HOST: 127.0.0.1
229+
DB_PORT: 5432
230+
DB_DATABASE: testing
231+
DB_USERNAME: postgres
232+
DB_PASSWORD: password
233+
234+
test-sqlite:
25235
needs: lint-app
26236
runs-on: ubuntu-24.04
27237
steps:
@@ -35,18 +245,20 @@ jobs:
35245

36246
- name: Create SQLite Database
37247
run: |
38-
touch database/testing.sqlite
248+
touch database/database.sqlite
39249
40250
- name: Install Dependencies
41251
run: |
42252
composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
43253
npm ci && npm run build
44254
45255
- name: Copy Environment File
46-
run: cp .env.example .env
256+
run: cp .env.ci .env
47257

48258
- name: Generate App Key
49259
run: php artisan key:generate --quiet
50260

51261
- name: Run Tests
52-
run: php artisan test --parallel
262+
run: php artisan test
263+
env:
264+
DB_CONNECTION: sqlite

phpunit.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
</source>
2020
<php>
2121
<env name="APP_ENV" value="testing"/>
22-
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
23-
<env name="CACHE_STORE" value="database"/>
24-
<env name="DB_CONNECTION" value="sqlite"/>
25-
<env name="DB_DATABASE" value=":memory:"/>
26-
<env name="MAIL_MAILER" value="array"/>
27-
<env name="QUEUE_CONNECTION" value="database"/>
28-
<env name="SESSION_DRIVER" value="database"/>
22+
<!-- <env name="APP_MAINTENANCE_DRIVER" value="file"/> -->
23+
<!-- <env name="CACHE_STORE" value="database"/> -->
24+
<!-- <env name="DB_CONNECTION" value="sqlite"/> -->
25+
<!-- <env name="DB_DATABASE" value=":memory:"/> -->
26+
<!-- <env name="MAIL_MAILER" value="array"/> -->
27+
<!-- <env name="QUEUE_CONNECTION" value="database"/> -->
28+
<!-- <env name="SESSION_DRIVER" value="database"/> -->
2929
</php>
3030
</phpunit>

0 commit comments

Comments
 (0)