-
-
Notifications
You must be signed in to change notification settings - Fork 2
216 lines (208 loc) · 7.98 KB
/
back-end.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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow
name: "Back-end"
on: # yamllint disable-line rule:truthy
pull_request: null
push:
branches:
- "master"
# Add [skip ci] to commit message to skip CI.
permissions: {} # yamllint disable-line rule:braces
#permissions: "read-all"
#permissions:
# contents: "read" # Private repositories need read permission
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
jobs:
syntax_errors:
name: "1️⃣ Syntax errors"
runs-on: "ubuntu-22.04"
timeout-minutes: 5
steps:
-
name: "Set up PHP"
uses: "shivammathur/[email protected]"
with:
php-version: "8.2"
coverage: "none"
tools: "parallel-lint"
-
name: "Checkout repository"
uses: "actions/[email protected]"
-
name: "Search for invalid complex curly syntax 🐌"
run: |
! git grep -e '\${[A-Z_a-z]' -- '*.php' '*.scss'
-
name: "Check source code for syntax errors"
run: "composer exec --no-interaction -- parallel-lint src/ tests/"
# @TODO Check template files for syntax errors
unit_tests:
name: "2️⃣ Unit and functional tests"
needs:
- "syntax_errors"
strategy:
#fail-fast: false
matrix:
php-version:
- "8.2"
dependencies:
- "lowest"
- "highest"
runs-on: "ubuntu-22.04"
timeout-minutes: 5
#services:
# database:
# image: "mariadb:11.0.2"
# env:
# MYSQL_DATABASE: "cylinder"
# MYSQL_USER: "dba"
# MYSQL_PASSWORD: "plaintextoffender"
# MYSQL_RANDOM_ROOT_PASSWORD: "1"
# options: >-
# --health-cmd "healthcheck.sh --connect --innodb_initialized"
# --health-interval 1s
# --health-timeout 10s
# --health-retries 30
steps:
-
name: "Set up PHP"
uses: "shivammathur/[email protected]"
with:
php-version: "${{ matrix.php-version }}"
-
name: "Setup problem matcher for PHPUnit"
run: |
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
-
name: "Checkout repository"
uses: "actions/[email protected]"
-
name: "Install dependencies"
uses: "ramsey/[email protected]"
#env:
# COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ github.token }}"}}'
# yamllint disable-line rule:line-length
# COMPOSER_AUTH: '{"http-basic":{"nova.laravel.com":{"username":"${{ secrets.NOVA_LICENSE_ACCOUNT }}","password":"${{ secrets.NOVA_LICENSE_KEY }}"}}}'
with:
dependency-versions: "${{ matrix.dependencies }}"
#composer-options: "--with=laravel/framework:${{ matrix.laravel-constraint }}"
-
name: "Declare strict types"
if: "${{ matrix.dependencies == 'highest' }}"
run: |
echo "::group::Install slevomat/coding-standard"
composer config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer false
composer require --no-scripts --dev slevomat/coding-standard
echo "::endgroup::"
composer exec -- phpcbf --standard=vendor/slevomat/coding-standard/SlevomatCodingStandard \
--sniffs=SlevomatCodingStandard.TypeHints.DeclareStrictTypes src/ \
|| test "$?" = 1 && exit 0
-
name: "Execute unit tests"
#run: "composer exec -- phpunit"
run: "composer exec -- pest --ci"
# @TODO Run functional tests
-
name: "Tests have failed: upload logs"
if: "${{ failure() }}"
uses: "actions/[email protected]"
with:
path: "storage/logs/"
# Prefix with project name (github.repository contains a slash)
name: "laravel-logs-${{ matrix.php-version }}-${{ matrix.dependencies }}"
-
name: "Send coverage to Coveralls"
env:
COVERALLS_REPO_TOKEN: "${{ github.token }}"
if: "${{ env.COVERALLS_REPO_TOKEN && matrix.php-version == '8.2' && matrix.dependencies == 'highest' }}"
uses: "coverallsapp/[email protected]"
with:
github-token: "${{ env.COVERALLS_REPO_TOKEN }}"
flag-name: "Unit"
allow-empty: false
static_analysis:
name: "3️⃣ Static Analysis"
needs:
- "syntax_errors"
runs-on: "ubuntu-22.04"
timeout-minutes: 5
steps:
-
name: "Set up PHP"
uses: "shivammathur/[email protected]"
with:
php-version: "8.2"
coverage: "none"
-
name: "Checkout repository"
uses: "actions/[email protected]"
-
name: "Check JSON files"
run: |
git ls-files --cached -z -- '*.json' \
| xargs -t --null -L 1 -- \
php -r 'json_decode(file_get_contents($argv[1]), null, 512, JSON_THROW_ON_ERROR);'
-
name: "Validate Composer configuration"
run: "composer validate --no-interaction --strict"
-
name: "Install dependencies"
uses: "ramsey/[email protected]"
with:
dependency-versions: "highest"
-
name: "Check PSR-4 mapping 🐌"
run: "composer dump-autoload --optimize --strict-psr"
-
name: "Check for security vulnerability advisories"
run: "composer audit"
#-
# name: "Check architecture"
# run: "composer exec -- phparkitect check --config=vendor/mortexa/laravel-arkitect/src/phparkitect.php"
-
# https://github.com/phpstan/phpstan/issues/9475
name: "Search for $this typos 🐌"
run: |
! git grep --line-number -e '\$this\s*->\s*\$this\|\$\$this' -- ':!:*/back-end.yml'
-
name: "Perform static analysis"
run: "composer exec -- phpstan analyze --level=5 src/"
# @TODO Cognitive Complexity tomasvotruba/cognitive-complexity
# Mess Detector phpmd/phpmd
# Magic Number Detector povils/phpmnd
# Copy-Paste Detector https://github.com/mkrauser/phpcpd
coding_standards:
name: "4️⃣ Coding Standards"
needs:
- "syntax_errors"
runs-on: "ubuntu-22.04"
timeout-minutes: 5
steps:
-
name: "Set up PHP"
uses: "shivammathur/[email protected]"
with:
php-version: "8.2"
coverage: "none"
tools: "phpcs,cs2pr"
-
name: "Checkout repository"
uses: "actions/[email protected]"
-
name: "Install dependencies"
uses: "ramsey/[email protected]"
with:
dependency-versions: "highest"
-
name: "Detect coding standards violations"
run: "composer exec -- phpcs -q --report=checkstyle --standard=PSR12 src/ | cs2pr"
# yamllint disable-line rule:comments-indentation
#-
# name: "Detect coding standards violations"
# id: "pint"
# run: "composer exec -- pint --verbose --test"
#-
# name: "Annotate Pint results"
# if: "${{ failure() && steps.pint.outcome == 'failure' }}"
# run: "composer exec -- pint --test --format=checkstyle | cs2pr"