-
Notifications
You must be signed in to change notification settings - Fork 49
147 lines (141 loc) · 4.83 KB
/
tests.yml
File metadata and controls
147 lines (141 loc) · 4.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: Tests
on:
push:
pull_request:
jobs:
phpstan:
name: PHPStan Static Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: pdo, pdo_mysql, pdo_pgsql, pdo_sqlite
coverage: none
- run: composer install --no-interaction --prefer-dist
- run: composer phpstan
mysql:
name: MySQL Tests
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_DATABASE: testdb
MYSQL_USER: testuser
MYSQL_PASSWORD: testpass
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h 127.0.0.1 -uroot -proot"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: pdo_mysql, simplexml, xmlreader
coverage: xdebug
- run: composer install --no-interaction --prefer-dist
- name: Enable MySQL local_infile
run: |
mysql -h 127.0.0.1 -uroot -proot -e "SET GLOBAL local_infile=1;"
- run: |
DB_DSN="mysql:host=127.0.0.1;port=3306;dbname=testdb;charset=utf8mb4" \
DB_USER="testuser" \
DB_PASS="testpass" \
vendor/bin/phpunit tests/PdoDbMySQLTest.php --coverage-clover coverage-mysql.xml
- name: Upload MySQL coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage-mysql.xml
flags: mysql
name: mysql-coverage
postgres:
name: PostgreSQL Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_DB: testdb
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5433:5432
options: >-
--health-cmd="pg_isready -U postgres -d testdb"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: pdo_pgsql, simplexml, xmlreader
coverage: xdebug
- run: composer install --no-interaction --prefer-dist
- name: Setup PostgreSQL test user with permissions
run: |
PGPASSWORD=postgres psql -h localhost -p 5433 -U postgres -d testdb -c "CREATE USER testuser WITH PASSWORD 'testpass';"
PGPASSWORD=postgres psql -h localhost -p 5433 -U postgres -d testdb -c "GRANT ALL PRIVILEGES ON DATABASE testdb TO testuser;"
PGPASSWORD=postgres psql -h localhost -p 5433 -U postgres -d testdb -c "GRANT ALL ON SCHEMA public TO testuser;"
PGPASSWORD=postgres psql -h localhost -p 5433 -U postgres -d testdb -c "GRANT pg_read_server_files TO testuser;"
- run: |
DB_DSN="pgsql:host=localhost;port=5433;dbname=testdb" \
DB_USER="testuser" \
DB_PASS="testpass" \
vendor/bin/phpunit tests/PdoDbPostgreSQLTest.php --coverage-clover coverage-postgres.xml
- name: Upload PostgreSQL coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage-postgres.xml
flags: postgres
name: postgres-coverage
sqlite:
name: SQLite Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: pdo_sqlite
coverage: xdebug
- run: composer install --no-interaction --prefer-dist
- run: |
DB_DSN="sqlite::memory:" \
vendor/bin/phpunit tests/PdoDbSqliteTest.php --coverage-clover coverage-sqlite.xml
- name: Upload SQLite coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage-sqlite.xml
flags: sqlite
name: sqlite-coverage
shared-coverage:
name: Shared Coverage Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: pdo_sqlite
coverage: xdebug
- run: composer install --no-interaction --prefer-dist
- run: vendor/bin/phpunit tests/SharedCoverageTest.php --coverage-clover coverage-shared.xml
- name: Upload Shared coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage-shared.xml
flags: shared
name: shared-coverage