-
Notifications
You must be signed in to change notification settings - Fork 398
181 lines (156 loc) · 6.73 KB
/
ci.yml
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
name: CI
on:
push:
branches:
- 'master'
pull_request:
workflow_dispatch:
jobs:
testsuite:
name: "Test Suite"
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
php-version: [ '7.4', '8.2' ]
db-type: [ sqlite, mysql, pgsql, agnostic ]
symfony-version: [ '5-min', '5-max', '6-min', '6-max', '7-min', '7-max']
exclude:
- symfony-version: '6-min'
php-version: '7.4'
- symfony-version: '6-max'
php-version: '7.4'
- symfony-version: '7-min'
php-version: '7.4'
- symfony-version: '7-max'
php-version: '7.4'
env:
DB_NAME: 'propel_tests'
DB_USER: 'propel'
DB_PW: 'propel'
steps:
- name: Install PostgreSQL latest
if: matrix.db-type == 'pgsql' && matrix.php-version != '7.4'
uses: CasperWA/postgresql-action@v1.2
with:
postgresql db: $DB_NAME
postgresql user: $DB_USER
postgresql password: $DB_PW
- name: Install PostgreSQL min
if: matrix.db-type == 'pgsql' && matrix.php-version == '7.4'
uses: CasperWA/postgresql-action@v1.2
with:
postgresql version: 9
postgresql db: $DB_NAME
postgresql user: $DB_USER
postgresql password: $DB_PW
- name: Install MySQL latest
if: matrix.db-type == 'mysql' && matrix.php-version != '7.4'
uses: mirromutth/mysql-action@v1.1
with:
mysql root password: $DB_PW
- name: Install MariaDb min
if: matrix.db-type == 'mysql' && matrix.php-version == '7.4'
uses: getong/mariadb-action@v1.1
with:
mariadb version: '10.2'
mysql root password: $DB_PW
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: json, libxml, pdo, pdo_mysql, pdo_sqlite, pdo_pgsql, sqlite3
coverage: pcov
- name: Checkout
uses: actions/checkout@v2
- name: Composer get cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Composer cache dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Move specific composer.json (Symfony version ${{ matrix.symfony-version }})
run: mv tests/composer/composer-symfony${{ matrix.symfony-version }}.json composer.json
- name: Composer install (Symfony version ${{ matrix.symfony-version }})
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Wait for MySQL server to load
if: matrix.db-type == 'mysql'
run: |
bash -c "
for i in {1..10}; do
mysqladmin -h 127.0.0.1 -u root status >/dev/null 2>&1 && exit 0 || sleep 6
echo 'trying again'
done;
echo 'could not establish connection after 10 tries'
exit 1
"
env:
MYSQL_PWD: ${{ env.DB_PW }}
- name: Create MySQL Propel user
if: matrix.db-type == 'mysql'
run: |
mysql -h 127.0.0.1 -u root -e "
CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PW';
CREATE USER '$DB_USER'@'%' IDENTIFIED BY '$DB_PW';
GRANT ALL PRIVILEGES ON *.* TO '$DB_USER'@'localhost';
GRANT ALL PRIVILEGES ON *.* TO '$DB_USER'@'%';
FLUSH PRIVILEGES;
"
env:
MYSQL_PWD: ${{ env.DB_PW }}
- name: Setup database for test suite
if: matrix.db-type != 'agnostic'
run: tests/bin/setup.${{ matrix.db-type }}.sh
- name: Run tests
shell: 'script -q -e -c "bash {0}"'
run: |
if [[ ${{ matrix.php-version }} == '7.4' && ${{ matrix.symfony-version == '5-max' }} ]]; then
export CODECOVERAGE=1 && vendor/bin/phpunit -c tests/${{ matrix.db-type }}.phpunit.xml --verbose --coverage-clover=tests/coverage.xml
else
vendor/bin/phpunit -c tests/${{ matrix.db-type }}.phpunit.xml
fi
env:
SYMFONY_VERSION: ${{ matrix.symfony-version }}
- name: Code Coverage Report
if: success() && matrix.php-version == '7.4' && matrix.symfony-version == '5-max'
uses: codecov/codecov-action@v1
with:
flags: ${{ matrix.php-version }}, ${{ matrix.db-type }}, ${{ matrix.symfony-version }}
file: tests/coverage.xml
code-style-and-static-analysis:
runs-on: ubuntu-22.04
steps:
- name: Setup PHP
id: setup-php
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: json, libxml, pdo, pdo_mysql, pdo_sqlite, pdo_pgsql, sqlite3
coverage: pcov
- uses: actions/checkout@v2
- name: Composer get cache directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Composer cache
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Composer validate
run: composer validate
- name: Composer install
run: composer install --prefer-dist --no-interaction
- name: PHPStan
env:
PHPSTAN: 1
run: composer stan
- name: Psalm
run: composer psalm -- --php-version=${{ steps.setup-php.outputs.php-version }}
- name: Code Style
run: composer cs-check