Skip to content

Commit 968dabb

Browse files
committed
changed ci config for mysql, postgres and mssql
1 parent e518dc9 commit 968dabb

File tree

1 file changed

+172
-83
lines changed

1 file changed

+172
-83
lines changed

.github/workflows/ci.yml

Lines changed: 172 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,34 @@ name: CI
22

33
on:
44
push:
5-
branches: [feature-*, develop, dev-*, master]
5+
branches: [ feature-*, develop, dev-*, master ]
66
tags:
77
- '*'
88
pull_request:
9-
branches: [feature-*, develop, dev-*, master]
9+
branches: [ feature-*, develop, dev-*, master ]
1010

1111
jobs:
12-
test:
12+
test-mysql:
13+
name: Laravel ${{ matrix.laravel }} / PHP ${{ matrix.php }} / MySQL ${{ matrix.mysql }}
1314
runs-on: ubuntu-latest
1415
timeout-minutes: 30
1516
strategy:
1617
matrix:
1718
laravel: [10, 11, 12]
1819
php: [8.2, 8.3, 8.4]
19-
db:
20-
- engine: mysql
21-
version: 5.7
22-
- engine: mysql
23-
version: 8.0
24-
- engine: pgsql
25-
version: 15
26-
- engine: sqlsrv
27-
version: 2022-latest
20+
mysql: [5.7, 8.0]
2821

2922
exclude:
3023
- laravel: 10
3124
php: 8.4
32-
db:
33-
engine: mysql
34-
version: 5.7
25+
mysql: 5.7
3526
- laravel: 10
3627
php: 8.4
37-
db:
38-
engine: mysql
39-
version: 8.0
40-
- laravel: 10
41-
db:
42-
engine: sqlsrv
43-
version: 2022-latest
44-
- laravel: 11
45-
db:
46-
engine: sqlsrv
47-
version: 2022-latest
28+
mysql: 8.0
4829

4930
services:
5031
mysql:
51-
image: mysql:${{ matrix.db.version }}
32+
image: mysql:${{ matrix.mysql }}
5233
ports:
5334
- 3306:3306
5435
env:
@@ -60,8 +41,83 @@ jobs:
6041
--health-timeout=5s
6142
--health-retries=3
6243
44+
env:
45+
DB_HOST: 127.0.0.1
46+
DB_PORT: 3306
47+
DB_USERNAME: root
48+
DB_PASSWORD: ''
49+
DB_DATABASE: testing
50+
51+
steps:
52+
- uses: actions/checkout@v4
53+
54+
- name: Set up PHP
55+
uses: shivammathur/setup-php@v2
56+
with:
57+
php-version: ${{ matrix.php }}
58+
extensions: mbstring, pdo_mysql, zip, exif, intl, gd, bcmath, curl, dom, xdebug
59+
coverage: xdebug
60+
61+
- name: Debug info
62+
run: |
63+
php -v
64+
composer --version
65+
mysql --version || true
66+
67+
- name: Wait for MySQL
68+
run: |
69+
for i in {30..0}; do
70+
if mysqladmin ping -h 127.0.0.1 --silent; then
71+
echo "MySQL is ready"
72+
break
73+
fi
74+
echo "Waiting for MySQL ($i)..."
75+
sleep 1
76+
done
77+
78+
- name: Adjust Laravel/Testbench version per matrix
79+
run: |
80+
composer remove laravel/framework orchestra/testbench --no-update || true
81+
composer require laravel/framework:^${{ matrix.laravel }} --no-update
82+
83+
if [[ "${{ matrix.laravel }}" == "10" ]]; then
84+
composer require orchestra/testbench:^8.0 --dev --no-update
85+
elif [[ "${{ matrix.laravel }}" == "11" ]]; then
86+
composer require orchestra/testbench:^9.0 --dev --no-update
87+
elif [[ "${{ matrix.laravel }}" == "12" ]]; then
88+
composer require orchestra/testbench:^10.0 --dev --no-update
89+
fi
90+
91+
composer update --no-interaction --prefer-dist --no-progress
92+
93+
- name: Ensure coverage directory exists
94+
run: mkdir -p coverage
95+
96+
- name: Run Tests
97+
run: vendor/bin/phpunit --coverage-clover=coverage/clover.xml --path-coverage
98+
99+
- uses: qltysh/qlty-action/coverage@v1
100+
with:
101+
token: ${{ secrets.QLTY_COVERAGE_TOKEN }}
102+
files: coverage/clover.xml
103+
104+
105+
test-pgsql:
106+
name: Laravel ${{ matrix.laravel }} / PHP ${{ matrix.php }} / PostgreSQL 15
107+
runs-on: ubuntu-latest
108+
timeout-minutes: 30
109+
strategy:
110+
matrix:
111+
laravel: [10, 11, 12]
112+
php: [8.2, 8.3, 8.4]
113+
114+
exclude:
115+
- laravel: 10
116+
php: 8.4
117+
118+
services:
63119
postgres:
64-
image: postgres:${{ matrix.db.version }}
120+
image: postgres:15
65121
ports:
66122
- 5432:5432
67123
env:
@@ -74,8 +130,83 @@ jobs:
74130
--health-timeout=5s
75131
--health-retries=3
76132
133+
env:
134+
DB_HOST: 127.0.0.1
135+
DB_PORT: 5432
136+
DB_USERNAME: postgres
137+
DB_PASSWORD: ''
138+
DB_DATABASE: testing
139+
140+
steps:
141+
- uses: actions/checkout@v4
142+
143+
- name: Set up PHP
144+
uses: shivammathur/setup-php@v2
145+
with:
146+
php-version: ${{ matrix.php }}
147+
extensions: mbstring, pdo_pgsql, zip, exif, intl, gd, bcmath, curl, dom, xdebug
148+
coverage: xdebug
149+
150+
- name: Debug info
151+
run: |
152+
php -v
153+
composer --version
154+
psql --version || true
155+
156+
- name: Wait for Postgres
157+
run: |
158+
for i in {30..0}; do
159+
if pg_isready -h 127.0.0.1 -U postgres; then
160+
echo "Postgres is ready"
161+
break
162+
fi
163+
echo "Waiting for Postgres ($i)..."
164+
sleep 1
165+
done
166+
167+
- name: Adjust Laravel/Testbench version per matrix
168+
run: |
169+
composer remove laravel/framework orchestra/testbench --no-update || true
170+
composer require laravel/framework:^${{ matrix.laravel }} --no-update
171+
172+
if [[ "${{ matrix.laravel }}" == "10" ]]; then
173+
composer require orchestra/testbench:^8.0 --dev --no-update
174+
elif [[ "${{ matrix.laravel }}" == "11" ]]; then
175+
composer require orchestra/testbench:^9.0 --dev --no-update
176+
elif [[ "${{ matrix.laravel }}" == "12" ]]; then
177+
composer require orchestra/testbench:^10.0 --dev --no-update
178+
fi
179+
180+
composer update --no-interaction --prefer-dist --no-progress
181+
182+
- name: Ensure coverage directory exists
183+
run: mkdir -p coverage
184+
185+
- name: Run Tests
186+
run: vendor/bin/phpunit --coverage-clover=coverage/clover.xml --path-coverage
187+
188+
- uses: qltysh/qlty-action/coverage@v1
189+
with:
190+
token: ${{ secrets.QLTY_COVERAGE_TOKEN }}
191+
files: coverage/clover.xml
192+
193+
194+
test-sqlsrv:
195+
name: Laravel ${{ matrix.laravel }} / PHP ${{ matrix.php }} / MSSQL 2022-latest
196+
runs-on: ubuntu-latest
197+
timeout-minutes: 30
198+
strategy:
199+
matrix:
200+
laravel: [10, 11, 12]
201+
php: [8.2, 8.3, 8.4]
202+
203+
exclude:
204+
- laravel: 10
205+
- laravel: 11
206+
207+
services:
77208
mssql:
78-
image: mcr.microsoft.com/mssql/server:${{ matrix.db.version }}
209+
image: mcr.microsoft.com/mssql/server:2022-latest
79210
ports:
80211
- 1433:1433
81212
env:
@@ -88,76 +219,34 @@ jobs:
88219
--health-timeout=5s
89220
--health-retries=3
90221
91-
name: Laravel ${{ matrix.laravel }} / PHP ${{ matrix.php }} / DB ${{ matrix.db.engine }} ${{ matrix.db.version }}
222+
env:
223+
DB_HOST: 127.0.0.1
224+
DB_PORT: 1433
225+
DB_USERNAME: SA
226+
DB_PASSWORD: Passw0rd1234!
227+
DB_DATABASE: testing
92228

93229
steps:
94230
- uses: actions/checkout@v4
95231

96-
- name: Set DB env variables
97-
run: |
98-
echo "DB_ENGINE=${{ matrix.db.engine }}" >> $GITHUB_ENV
99-
echo "DB_VERSION=${{ matrix.db.version }}" >> $GITHUB_ENV
100-
101-
if [[ "${{ matrix.db.engine }}" == "mysql" ]]; then
102-
echo "DB_HOST=127.0.0.1" >> $GITHUB_ENV
103-
echo "DB_PORT=3306" >> $GITHUB_ENV
104-
echo "DB_USERNAME=root" >> $GITHUB_ENV
105-
echo "DB_PASSWORD=" >> $GITHUB_ENV
106-
echo "DB_DATABASE=testing" >> $GITHUB_ENV
107-
elif [[ "${{ matrix.db.engine }}" == "pgsql" ]]; then
108-
echo "DB_HOST=127.0.0.1" >> $GITHUB_ENV
109-
echo "DB_PORT=5432" >> $GITHUB_ENV
110-
echo "DB_USERNAME=postgres" >> $GITHUB_ENV
111-
echo "DB_PASSWORD=" >> $GITHUB_ENV
112-
echo "DB_DATABASE=testing" >> $GITHUB_ENV
113-
elif [[ "${{ matrix.db.engine }}" == "sqlsrv" ]]; then
114-
echo "DB_HOST=127.0.0.1" >> $GITHUB_ENV
115-
echo "DB_PORT=1433" >> $GITHUB_ENV
116-
echo "DB_USERNAME=SA" >> $GITHUB_ENV
117-
echo "DB_PASSWORD=Passw0rd1234!" >> $GITHUB_ENV
118-
echo "DB_DATABASE=testing" >> $GITHUB_ENV
119-
fi
120-
121-
- name: Wait for DB service
122-
run: |
123-
if [[ "${{ matrix.db.engine }}" == "mysql" ]]; then
124-
for i in {30..0}; do
125-
if mysqladmin ping -h 127.0.0.1 --silent; then
126-
echo "MySQL is ready"
127-
break
128-
fi
129-
echo "Waiting for MySQL ($i)..."
130-
sleep 1
131-
done
132-
elif [[ "${{ matrix.db.engine }}" == "pgsql" ]]; then
133-
for i in {30..0}; do
134-
if pg_isready -h 127.0.0.1 -U postgres; then
135-
echo "Postgres is ready"
136-
break
137-
fi
138-
echo "Waiting for Postgres ($i)..."
139-
sleep 1
140-
done
141-
elif [[ "${{ matrix.db.engine }}" == "sqlsrv" ]]; then
142-
echo "Waiting 30 seconds for MSSQL to start..."
143-
sleep 30
144-
fi
145-
146232
- name: Set up PHP
147233
uses: shivammathur/setup-php@v2
148234
with:
149235
php-version: ${{ matrix.php }}
150-
extensions: mbstring, pdo_mysql, pdo_pgsql, pdo_sqlsrv, zip, exif, intl, gd, bcmath, curl, dom, xdebug
236+
extensions: mbstring, pdo_sqlsrv, zip, exif, intl, gd, bcmath, curl, dom, xdebug
151237
coverage: xdebug
152238

153239
- name: Debug info
154240
run: |
155241
php -v
156242
composer --version
157-
mysql --version || true
158-
psql --version || true
159243
/opt/mssql-tools/bin/sqlcmd -? || true
160244
245+
- name: Wait for MSSQL
246+
run: |
247+
echo "Waiting 30 seconds for MSSQL to start..."
248+
sleep 30
249+
161250
- name: Adjust Laravel/Testbench version per matrix
162251
run: |
163252
composer remove laravel/framework orchestra/testbench --no-update || true

0 commit comments

Comments
 (0)