-
Notifications
You must be signed in to change notification settings - Fork 3
300 lines (266 loc) · 10.8 KB
/
ci.yaml
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
name: Continuous Integration
on:
push:
branches:
- master
- 'MTC\-[0-9]+'
pull_request:
env:
PLUGIN_DIR: plugins/LeuchtfeuerCompanySegmentsBundle # Same as extra.install-directory-name in composer.json
jobs:
phpunit:
name: PHPUnit ${{ matrix.php-versions }}, ${{ matrix.db-types }}, Mautic ${{ matrix.mautic-versions }}
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['8.0', '8.1']
db-types: ['mysql', 'mariadb']
mautic-versions: ['5.0', '5.1', '5.x']
include:
- mautic-versions: 5.1
php-versions: 8.2
- mautic-versions: 5.x
php-versions: 8.2
- mautic-versions: 5.x
php-versions: 8.3
services:
database:
image: ${{ matrix.db-types == 'mysql' && 'mysql:8.0' || 'mariadb:10.3' }}
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: mautictest
ports:
- 3306
options: >-
--shm-size=2gb
--name=${{ matrix.db-types }}
--tmpfs=/var/lib/mysql
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
- name: Checkout Mautic
uses: actions/checkout@v4
with:
repository: mautic/mautic
ref: ${{ matrix.mautic-versions }}
fetch-depth: 0
- name: Checkout this plugin
uses: actions/checkout@v4
with:
path: ${{ env.PLUGIN_DIR }}
- name: Setup PHP Environment
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
ini-values: pcov.enabled=0, pcov.directory=., pcov.exclude="~tests|themes|vendor~", opcache.enable_cli=0
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql, pdo_mysql
coverage: pcov
- name: add MySQL config file
run: |
mysqldump --version
mysqldump --print-defaults
cp .github/ci-files/.my.cnf ~/.my.cnf
mysqldump --print-defaults
- name: Set SYMFONY_ENV to test
run: |
echo "SYMFONY_ENV=test" >> $GITHUB_ENV
echo "MAUTIC_ENV=test" >> $GITHUB_ENV
- name: NPM Cache
uses: actions/cache@v4
with:
path: ./var/cache/js
key: ${{ runner.os }}-js-${{ hashFiles('**/package-lock.json', 'webpack.config.js') }}-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-js-${{ hashFiles('**/package-lock.json', 'webpack.config.js') }}
${{ runner.os }}-js-
- name: Install composer requirements.
# composer install cache - https://github.com/ramsey/composer-install
uses: "ramsey/composer-install@v3"
- name: Install Mautic
env:
DB_PORT: ${{ job.services.database.ports[3306] }}
run: |
cp ./.github/ci-files/local.php ./app/config/local.php
php bin/console mautic:install --force http://localhost
- name: Install Plugins
env:
DB_PORT: ${{ job.services.database.ports[3306] }}
run: php bin/console mautic:plugins:install --env=dev
- name: Run tests - database = ${{ matrix.db-types }}
run: |
rm -rf var/cache
export DB_PORT="${{ job.services.database.ports[3306] }}"
if [[ "${{ matrix.php-versions }}" == "8.1" ]] && [[ "${{ matrix.db-types }}" == "mariadb" ]]; then
php -d zend.assertions=1 -d pcov.enabled=1 bin/phpunit -d memory_limit=2G --bootstrap vendor/autoload.php --configuration app/phpunit.xml.dist --coverage-clover=coverage.xml --log-junit=junit.xml -- ${{ env.PLUGIN_DIR }}/Tests
else
php -d zend.assertions=1 bin/phpunit -d memory_limit=1G --bootstrap vendor/autoload.php --configuration app/phpunit.xml.dist -- ${{ env.PLUGIN_DIR }}/Tests
fi
# maybe need to run phpunit differently to get the coverage from the bundle only?
- name: Upload coverage report
if: ${{ matrix.php-versions == '8.1' && matrix.db-types == 'mysql' && matrix.mautic-versions == '5.x' }} # upload just once, change for your matrix
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false
verbose: true
files: ./coverage.xml
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Save test results for future steps
if: ${{ matrix.php-versions == '8.1' && matrix.db-types == 'mysql' && matrix.mautic-versions == '5.x' }}
uses: actions/upload-artifact@v4
with:
name: test-results
path: |
./junit.xml
./coverage.xml
- name: Upload logs as artifacts
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: logs-${{ matrix.php-versions }}-${{ matrix.db-types }}-${{ matrix.mautic-versions }}
path: |
./var/logs/*
./media/files/temp/test*.html
# need to separate different code utilities to different processes, because if running in one "thread"
# there is an issue with the order/env variables/other means
# which does not allow the build to complete.
mautic:
runs-on: ubuntu-latest
# these should contain latest stable PHP and Mautic versions
strategy:
fail-fast: false
matrix:
commands: ['PHPStan', 'CS Fixer', 'Rector', 'Twig Lint']
php-versions: ['8.1']
mautic-versions: ['5.x']
name: ${{ matrix.commands }} - ${{ matrix.php-versions }} - ${{ matrix.mautic-versions }}
steps:
- name: Checkout Mautic
uses: actions/checkout@v4
with:
repository: mautic/mautic
ref: ${{ matrix.mautic-versions }}
fetch-depth: 0
- name: Checkout this plugin
uses: actions/checkout@v4
with:
path: ${{ env.PLUGIN_DIR }}
- name: Rector Cache
if: ${{matrix.commands == 'Rector'}}
uses: actions/cache@v4
with:
path: ./var/cache/rector
key: ${{ runner.os }}-rector-${{ hashFiles('**/composer.lock') }}-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-rector-${{ hashFiles('**/composer.lock') }}
${{ runner.os }}-rector-
- name: PHPStan Cache
if: ${{matrix.commands == 'PHPStan'}}
uses: actions/cache@v4
with:
path: ./var/phpstan-cache
key: ${{ runner.os }}-phpstan-${{ hashFiles('**/composer.lock') }}-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-phpstan-${{ hashFiles('**/composer.lock') }}
${{ runner.os }}-phpstan-
- name: NPM Cache
uses: actions/cache@v4
with:
path: ./var/cache/js
key: ${{ runner.os }}-js-${{ hashFiles('**/package-lock.json', 'webpack.config.js') }}-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-js-${{ hashFiles('**/package-lock.json', 'webpack.config.js') }}
${{ runner.os }}-js-
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql, pdo_mysql
ini-values: opcache.enable_cli=0
- name: Install dependencies
uses: "ramsey/composer-install@v3"
env:
NPM_CONFIG_CACHE: ./var/cache/js/npm
- name: Run ${{ matrix.commands }}
run: |
if [[ "${{ matrix.commands }}" == "PHPStan" ]]; then
composer remove --dev rector/rector
php ${{ env.PLUGIN_DIR }}/.github/phpstan-config.php
cat phpstan.neon
export SYMFONY_ENV=dev
export APP_ENV=dev
export APP_DEBUG=1
composer phpstan -- --no-progress ${{ env.PLUGIN_DIR }}
elif [[ "${{ matrix.commands }}" == "Rector" ]]; then
export SYMFONY_ENV=test
bin/console cache:warmup
bin/rector process --dry-run --ansi -- ${{ env.PLUGIN_DIR }}
elif [[ "${{ matrix.commands }}" == "Twig Lint" ]]; then
bin/console lint:twig ${{ env.PLUGIN_DIR }}
elif [[ "${{ matrix.commands }}" == "CS Fixer" ]]; then
bin/php-cs-fixer fix ${{ env.PLUGIN_DIR }} --config=.php-cs-fixer.php -v --dry-run --using-cache=no --show-progress=dots --diff
else
echo "Invalid command"
exit 1
fi
bundle:
runs-on: ubuntu-latest
# these should contain latest stable PHP and Mautic versions
strategy:
fail-fast: false
matrix:
commands: [ 'PHPStan', 'CS Fixer', 'Rector' ]
php-versions: [ '8.3' ]
mautic-versions: [ '5.x' ]
name: ${{ matrix.commands }} - ${{ matrix.php-versions }} - ${{ matrix.mautic-versions }}
steps:
- name: Checkout Bundle
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Rector Cache
if: ${{matrix.commands == 'Rector'}}
uses: actions/cache@v4
with:
path: ./var/cache/rector
key: ${{ runner.os }}-rector-bundle-${{ hashFiles('**/composer.lock') }}-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-rector-bundle-${{ hashFiles('**/composer.lock') }}
${{ runner.os }}-rector-bundle-
- name: PHPStan Cache
if: ${{matrix.commands == 'PHPStan'}}
uses: actions/cache@v4
with:
path: ./var/phpstan-cache
key: ${{ runner.os }}-phpstan-bundle-${{ hashFiles('**/composer.lock') }}-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-phpstan-bundle-${{ hashFiles('**/composer.lock') }}
${{ runner.os }}-phpstan-bundle-
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql, pdo_mysql
ini-values: opcache.enable_cli=0
- name: Install dependencies
uses: "ramsey/composer-install@v3"
- name: Run ${{ matrix.commands }}
run: |
if [[ "${{ matrix.commands }}" == "PHPStan" ]]; then
# composer remove --dev rector/rector
# php ${{ env.PLUGIN_DIR }}/.github/phpstan-config.php
# cat phpstan.neon
export SYMFONY_ENV=dev
export APP_ENV=dev
export APP_DEBUG=1
./vendor/bin/phpstan
elif [[ "${{ matrix.commands }}" == "Rector" ]]; then
./vendor/bin/rector process --dry-run --ansi
elif [[ "${{ matrix.commands }}" == "CS Fixer" ]]; then
./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php -v --dry-run --show-progress=dots --diff
else
echo "Invalid command"
exit 1
fi