-
Notifications
You must be signed in to change notification settings - Fork 66
271 lines (248 loc) · 8.94 KB
/
build.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
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
name: Build and test
on:
push:
branches-ignore: [gh-pages]
# pull_request:
# branches-ignore: [gh-pages]
jobs:
build:
name: Build (PHP ${{ matrix.php-versions }})
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['8.1', '8.2']
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Run security checker
uses: symfonycorp/security-checker-action@v5
- name: Get composer cache directory
id: composer-cache
run: |
dir="$(composer config cache-files-dir)"
echo "dir=$dir" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Extract English translations
run: php bin/console translation:extract --force en -vv
test:
name: Tests (PHP ${{ matrix.php-versions }})
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
php-versions: ['8.1', '8.2']
services:
mysql:
image: mysql:latest
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
MYSQL_ROOT_PASSWORD: 12345678
#MYSQL_DATABASE: zk_test
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout sources
uses: actions/checkout@v3
# Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP with PCOV
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: php-cs-fixer, phpunit-bridge
# required PHP extensions for Symfony: see https://symfony.com/doc/current/setup.html#technical-requirements
extensions: ctype, iconv, intl, json, mbstring, pcre, session, simplexml, tokenizer, xml, php-ast # xml is required by phpunit, php-ast is used by phan
#ini-values: memory_limit=256M, post_max_size=256M, max_execution_time=180, pcov.directory=src
coverage: pcov
- name: Install composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Run linter
run: |
php bin/console lint:container
php bin/console lint:yaml config/
php bin/console lint:yaml src/system/ --parse-tags
php bin/console lint:twig --show-deprecations src/system/
- name: Cache vulnerability database
uses: actions/cache@v3
id: cache-db
with:
path: ~/.symfony/cache
key: db
- name: Run security checker
uses: symfonycorp/security-checker-action@v5
# TODO enable migrations
# - name: Run Migration
# run: |
# composer require --dev symfony/orm-pack
# php bin/console doctrine:schema:update --force || echo "No migrations found or schema update failed"
# php bin/console doctrine:migrations:migrate || echo "No migrations found or migration failed"
# env:
# DATABASE_URL: mysql://root:[email protected]:${{ job.services.mysql.ports['3306'] }}/zk_test
- name: Run unit tests with coverage
# see https://dev.to/swashata/setup-php-pcov-for-5-times-faster-phpunit-code-coverage-3d9c
# run: ./vendor/bin/phpunit
run: php -dpcov.enabled=1 -dpcov.directory="src" -dpcov.exclude="~vendor~" vendor/bin/phpunit -c "phpunit.xml.dist" "src" --coverage-text
# - name: Determine coverage badge
# uses: timkrase/phpunit-coverage-badge@main
# with:
# push_badge: true
# repo_token: ${{ secrets.GITHUB_TOKEN }}
- name: Test installation
run: ./.github/scripts/testInstall.sh
# qa-phpstan:
# name: QA - Run phpstan (PHP ${{ matrix.php-versions }})
# runs-on: ubuntu-latest
# needs: test
# strategy:
# matrix:
# php-versions: ['8.2']
# steps:
# - name: Checkout sources
# uses: actions/checkout@v3
#
# - name: Install composer dependencies
# run: composer install --no-progress --prefer-dist --optimize-autoloader
#
# - name: Run phpstan
# # see https://github.com/phpstan/phpstan
# # level: (0 = loosest - 7 = "max" = strictest), default level is 0
# run: ./vendor/bin/phpstan analyse -c ./build/phpstan.neon --level 3 src
#
# qa-psalm:
# name: QA - Run psalm (PHP ${{ matrix.php-versions }})
# runs-on: ubuntu-latest
# needs: test
# strategy:
# matrix:
# php-versions: ['8.2']
# steps:
# - name: Checkout sources
# uses: actions/checkout@v3
#
# - name: Install composer dependencies
# run: composer install --no-progress --prefer-dist --optimize-autoloader
#
# - name: Run psalm
# run: ./vendor/bin/psalm src --find-dead-code --threads=8 --diff --diff-methods --show-info=1
#
# qa-phpcpd:
# name: QA - Run phpcpd (PHP ${{ matrix.php-versions }})
# runs-on: ubuntu-latest
# needs: test
# strategy:
# matrix:
# php-versions: ['8.2']
# steps:
# - name: Checkout sources
# uses: actions/checkout@v3
#
# - name: Install composer dependencies
# run: composer install --no-progress --prefer-dist --optimize-autoloader
#
# - name: Run phpcpd
# # see https://github.com/sebastianbergmann/phpcpd
# run: ./vendor/bin/phpcpd --exclude vendor ./src/
#
# qa-phpmd:
# name: QA - Run phpmd (PHP ${{ matrix.php-versions }})
# runs-on: ubuntu-latest
# needs: test
# strategy:
# matrix:
# php-versions: ['8.2']
# steps:
# - name: Checkout sources
# uses: actions/checkout@v3
#
# - name: Install composer dependencies
# run: composer install --no-progress --prefer-dist --optimize-autoloader
#
# - name: Run phpmd
# # see https://github.com/phpmd/phpmd
# run: ./vendor/bin/phpmd src text "build/phpmd.xml" --exclude vendor
#
# qa-phan:
# name: QA - Run phan (PHP ${{ matrix.php-versions }})
# runs-on: ubuntu-latest
# needs: test
# strategy:
# matrix:
# php-versions: ['8.2']
# steps:
# - name: Checkout sources
# uses: actions/checkout@v3
#
# - name: Install composer dependencies
# run: composer install --no-progress --prefer-dist --optimize-autoloader
#
# - name: Run phan
# # see https://github.com/phan/phan
# run: ./vendor/bin/phan --config-file "build/phan.php" --directory src
#
# qa-cs-fixer:
# name: QA - Run php-cs-fixer (PHP ${{ matrix.php-versions }})
# runs-on: ubuntu-latest
# needs: test
# strategy:
# matrix:
# php-versions: ['8.2']
# steps:
# - name: Checkout sources
# uses: actions/checkout@v3
#
# - name: Install composer dependencies
# run: composer install --no-progress --prefer-dist --optimize-autoloader
#
# - name: Run php-cs-fixer
# # see https://cs.symfony.com/
# run: ./vendor/bin/php-cs-fixer fix --verbose --allow-risky=yes --dry-run --config "build/php_cs_fixer.dist"
docs:
name: Documentation
if: github.ref_name == 'main'
runs-on: ubuntu-latest
needs: [build, test]
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Install composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Dump vendors into doc
run: ./build.php build:generate_vendor_doc --write-to "docs/General/VendorInformation.md"
# GH action not possible yet
# see https://github.com/CouscousPHP/Couscous/issues/263
# see https://github.com/CouscousPHP/Couscous/issues/265
- name: Build docs
#uses: CouscousPHP/GitHub-Action@v1
run: |
wget https://github.com/CouscousPHP/Couscous/archive/refs/heads/master.zip
unzip master.zip && rm master.zip
cd Couscous-master && composer install && cd ..
Couscous-master/bin/couscous generate
rm -rf Couscous-master/
- name: Deploy docs
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./.couscous/generated
create-artifacts:
name: Package
runs-on: ubuntu-latest
needs: [build, test, docs]
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Build release artifacts
run: ./.github/scripts/buildReleaseArtifacts.sh
# see https://github.com/actions/upload-artifact
- name: Upload release artifacts
uses: actions/upload-artifact@master
with:
name: release-archives
path: './build_work/archive'