-
Notifications
You must be signed in to change notification settings - Fork 55
363 lines (303 loc) · 12.5 KB
/
main.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
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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
# GitHub Actions docs
# https://help.github.com/en/articles/about-github-actions
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
name: CI
on:
# Trigger the workflow on push or pull request,
# but only for the master branch
push:
branches:
- master
pull_request:
branches:
- master
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
security-check:
name: PHP Security Checker
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: '0'
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@81cd5ae0920b34eef300e1775313071038a53429 # v2.27.0
with:
php-version: '8.2'
tools: composer:v2
- name: Get composer cache directory
id: composer-cache
run: echo "CACHE_DIR=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
path: ${{ steps.composer-cache.outputs.CACHE_DIR }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install --no-progress --optimize-autoloader
- name: Check which versions we're using
run: |
mysql --version
php --version
php ./bin/console --version
php ./vendor/bin/phpunit --version
composer --version
- name: PHP Security Checker
uses: symfonycorp/security-checker-action@258311ef7ac571f1310780ef3d79fc5abef642b5 # v5
- name: Check that application doesn't have installed dependencies with known security vulnerabilities
run: make check-security
lint-configuration:
name: Lint configuration
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: '0'
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@81cd5ae0920b34eef300e1775313071038a53429 # v2.27.0
with:
php-version: '8.2'
tools: composer:v2
- name: Get composer cache directory
id: composer-cache
run: echo "CACHE_DIR=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
path: ${{ steps.composer-cache.outputs.CACHE_DIR }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install --no-progress --optimize-autoloader
- name: Check which versions we're using
run: |
mysql --version
php --version
php ./bin/console --version
php ./vendor/bin/phpunit --version
composer --version
- name: Validate main `composer.json` and `composer.lock` files
run: composer validate --no-check-version
- name: Check that environment is configured correctly
run: php ./vendor/bin/requirements-checker
- name: Lint YAML configurations
run: make lint-yaml
static:
name: Static analyzers
runs-on: ubuntu-latest
needs:
- security-check
- lint-configuration
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: '0'
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@81cd5ae0920b34eef300e1775313071038a53429 # v2.27.0
with:
php-version: '8.2'
tools: composer:v2
- name: Get composer cache directory
id: composer-cache
run: echo "CACHE_DIR=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
path: ${{ steps.composer-cache.outputs.CACHE_DIR }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install --no-progress --optimize-autoloader
- name: Check which versions we're using
run: |
mysql --version
php --version
php ./bin/console --version
php ./vendor/bin/phpunit --version
composer --version
- name: Run PHP CodeSniffer
run: make phpcs
- name: Run The Easiest Way to Use Any Coding Standard
run: make ecs
- name: Run PHPLint tool
run: make phplint
- name: Run Psalm static analysis tool and report statistics to https://shepherd.dev/
run: make psalm-github
#- name: Run Psalm static analysis tool
# run: make psalm
- name: Run PHPStan static analysis tool
run: make phpstan-github
# Disabled this because of - https://github.com/nunomaduro/phpinsights/issues/622
#- name: Run `phploc` to collect LOC stats
# run: make phploc
- name: Run `PHP Insights` static analysis tool
run: make phpinsights
- name: Archive Psalm results (psalm.json)
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: psalm.json
path: ./build/psalm.json
- name: Archive `phploc` results (phploc.json)
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: phploc.json
path: ./build/phploc.json
test:
name: PHPUnit tests
runs-on: ubuntu-latest
needs:
- static
- lint-documentation
services:
mariadb:
image: mariadb:10.7.1
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
MYSQL_ROOT_PASSWORD: symfony
MYSQL_DATABASE: symfony
ports:
- 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: '0'
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@81cd5ae0920b34eef300e1775313071038a53429 # v2.27.0
with:
php-version: '8.2'
extensions: pdo_mysql, mysql
coverage: xdebug
tools: composer:v2
- name: Get composer cache directory
id: composer-cache
run: echo "CACHE_DIR=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
path: ${{ steps.composer-cache.outputs.CACHE_DIR }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Configure application for CI run
run: |
cp .env.gh-actions .env
cp .env.gh-actions .env.test
make generate-jwt-keys
chmod 644 ./config/jwt/private.pem
- name: Install Composer dependencies
run: composer install --no-progress --optimize-autoloader
- name: Check which versions we're using
run: |
mysql --version
php --version
php ./bin/console --version
php ./vendor/bin/phpunit --version
composer --version
- name: Prepare Code Climate (https://codeclimate.com/github/tarlepp/symfony-flex-backend/)
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
GIT_BRANCH=$GITHUB_REF GIT_COMMIT_SHA=$GITHUB_SHA ./cc-test-reporter before-build
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} # https://docs.codeclimate.com/docs/finding-your-test-coverage-token
- name: Run application test suites with PHPUnit
run: make run-tests-php
env:
DATABASE_URL: mysql://root:[email protected]:${{ job.services.mariadb.ports['3306'] }}/symfony
- name: Report results to Code Climate (https://codeclimate.com/github/tarlepp/symfony-flex-backend/)
run: GIT_BRANCH=$GITHUB_REF GIT_COMMIT_SHA=$GITHUB_SHA ./cc-test-reporter after-build --id ${{ secrets.CC_TEST_REPORTER_ID }} --coverage-input-type clover --exit-code $?
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} # https://docs.codeclimate.com/docs/finding-your-test-coverage-token
- name: Report results to Scrutinizer (https://scrutinizer-ci.com/g/tarlepp/symfony-flex-backend/)
run: |
composer global require scrutinizer/ocular
~/.composer/vendor/bin/ocular code-coverage:upload --access-token ${{ secrets.SCRUTINIZER_ACCESS_TOKEN }} --format=php-clover ./build/logs/clover.xml
- name: Report results to Coveralls (https://coveralls.io/github/tarlepp/symfony-flex-backend)
run: php ./vendor/bin/php-coveralls -v
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
COVERALLS_RUN_LOCALLY: 1
- name: SonarCloud Scan (https://sonarcloud.io/dashboard?id=github.com.tarlepp.symfony-flex-backend)
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # https://github.com/SonarSource/sonarcloud-github-action#secrets
- name: Create PhpMetrics report
run: make phpmetrics
- name: Archive code coverage results (clover.xml)
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: clover.xml
path: ./build/logs/clover.xml
- name: Archive code coverage results (junit.xml)
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: junit.xml
path: ./build/logs/junit.xml
- name: Archive Code Coverage
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: PhpMetrics
path: ./build/report
- name: Archive PhpMetrics results
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: PhpMetrics
path: ./build/phpmetrics
lint-documentation:
name: Lint documentation files
runs-on: ubuntu-latest
steps:
- name: Make checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Lint `./README.md`
uses: avto-dev/markdown-lint@04d43ee9191307b50935a753da3b775ab695eceb # v1.5.0
with:
config: './markdown-lint.yml'
args: './README.md'
- name: Lint all the resource docs under `./doc/` directory
uses: avto-dev/markdown-lint@04d43ee9191307b50935a753da3b775ab695eceb # v1.5.0
with:
config: './markdown-lint.yml'
args: './doc/*.md'
- name: Lint all the docs under `./docker/` directory
uses: avto-dev/markdown-lint@04d43ee9191307b50935a753da3b775ab695eceb # v1.5.0
with:
config: './markdown-lint.yml'
args: './docker/*.md'
- name: Lint all the docs under `./secrets/` directory
uses: avto-dev/markdown-lint@04d43ee9191307b50935a753da3b775ab695eceb # v1.5.0
with:
config: './markdown-lint.yml'
args: './secrets/*.md'
build:
name: Build application Docker image
runs-on: ubuntu-latest
needs:
- test
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Set tag var
id: vars
run: echo "DOCKER_TAG=$(echo ${GITHUB_REF} | sed -r 's/[\/()\.]+/_/g')-${GITHUB_SHA}" >> $GITHUB_OUTPUT
- name: Build the Docker image
run: docker build . --file Dockerfile --tag symfony-flex-backend:${{ steps.vars.outputs.DOCKER_TAG }}