-
-
Notifications
You must be signed in to change notification settings - Fork 5
202 lines (168 loc) · 7.05 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
name: CI
on: [push, pull_request]
jobs:
tests:
name: PHP ${{ matrix.php }}
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
matrix:
php: ["8.1", "8.2", "8.3"]
env:
extensions: mbstring, pcov
ini: pcov.directory=., "pcov.exclude=\"~(vendor|tests)~\""
steps:
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3
- name: Setup PHP cache environment
id: ext-cache
uses: shivammathur/cache-extensions@d622719c5f9eb1f119bee963028d0c0b984525c5 # pin@v1
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.extensions }}
key: php-v1
- name: Cache PHP extensions
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # pin@v3
with:
path: ${{ steps.ext-cache.outputs.dir }}
key: ${{ steps.ext-cache.outputs.key }}
restore-keys: ${{ steps.ext-cache.outputs.key }}
- name: Setup PHP environment
uses: shivammathur/setup-php@e6f75134d35752277f093989e72e140eaa222f35 # pin@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.extensions }}
ini-values: ${{ env.ini }}
coverage: pcov
tools: phpunit:9.5.13, psalm:4.11.2
- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Get Composer cache directory
id: composerCache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # pin@v3
with:
path: ${{ steps.composerCache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --prefer-dist
- name: Cache analysis data
id: finishPrepare
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # pin@v3
with:
path: ~/.cache/psalm
key: backend-analysis-${{ matrix.php }}-v2
- name: Run tests
if: always() && steps.finishPrepare.outcome == 'success'
run: phpunit --coverage-clover ${{ github.workspace }}/clover.xml
# - name: Statically analyze using Psalm
# if: always() && steps.finishPrepare.outcome == 'success'
# run: psalm --output-format=github --php-version=${{ matrix.php }}
# - name: Upload coverage results to Codecov
# uses: codecov/codecov-action@66b3de25f6f91f65eb92c514d31d6b6f13d5ab18 # pin@v3
# with:
# file: ${{ github.workspace }}/clover.xml
# flags: backend
# env_vars: PHP
# env:
# PHP: ${{ matrix.php }}
analysis:
name: Analysis
runs-on: ubuntu-latest
timeout-minutes: 5
env:
php: "8.1"
extensions: mbstring
steps:
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3
- name: Setup PHP cache environment
id: ext-cache
uses: shivammathur/cache-extensions@d622719c5f9eb1f119bee963028d0c0b984525c5 # pin@v1
with:
php-version: ${{ env.php }}
extensions: ${{ env.extensions }}
key: php-v1
- name: Cache PHP extensions
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # pin@v3
with:
path: ${{ steps.ext-cache.outputs.dir }}
key: ${{ steps.ext-cache.outputs.key }}
restore-keys: ${{ steps.ext-cache.outputs.key }}
- name: Setup PHP environment
id: finishPrepare
uses: shivammathur/setup-php@e6f75134d35752277f093989e72e140eaa222f35 # pin@v2
with:
php-version: ${{ env.php }}
extensions: ${{ env.extensions }}
coverage: none
tools: |
composer:2.3.7, composer-normalize:2.28.0,
composer-unused:0.7.12, phpcpd:6.0.3, phpmd:2.12.0
- name: Validate composer.json/composer.lock
if: always() && steps.finishPrepare.outcome == 'success'
run: composer validate --strict --no-check-version --no-check-all
- name: Ensure that composer.json is normalized
if: always() && steps.finishPrepare.outcome == 'success'
run: composer-normalize --dry-run
- name: Get Composer cache directory
id: composerCache1
if: always() && steps.finishPrepare.outcome == 'success'
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
id: composerCache2
if: always() && steps.composerCache1.outcome == 'success'
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # pin@v3
with:
path: ${{ steps.composerCache1.outputs.dir }}
key: ${{ runner.os }}-composer-locked-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-locked-
- name: Install dependencies
id: composerInstall
if: always() && steps.composerCache2.outcome == 'success'
run: composer install --prefer-dist
# - name: Check for unused Composer dependencies
# if: always() && steps.composerInstall.outcome == 'success'
# run: composer-unused --no-progress
- name: Check for duplicated code
if: always() && steps.composerInstall.outcome == 'success'
run: phpcpd --fuzzy --exclude tests --exclude vendor .
- name: Statically analyze using PHPMD
if: always() && steps.composerInstall.outcome == 'success'
run: phpmd . github phpmd.xml.dist --exclude 'tests/*,vendor/*,_templates/*'
coding-style:
name: Coding Style
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3
- name: Setup PHP environment
uses: shivammathur/setup-php@e6f75134d35752277f093989e72e140eaa222f35 # pin@v2
with:
coverage: none
tools: php-cs-fixer:3.49.0
- name: Cache analysis data
id: finishPrepare
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # pin@v3
with:
path: ~/.php-cs-fixer
key: coding-style
- name: Check for PHP coding style violations
if: always() && steps.finishPrepare.outcome == 'success'
env:
PHP_CS_FIXER_IGNORE_ENV: 1
# Use the --dry-run flag in push builds to get a failed CI status
run: >
php-cs-fixer fix --diff ${{ github.event_name != 'pull_request' && '--dry-run' || '' }}
- name: Create code suggestions from the coding style changes (on PR only)
if: >
always() && steps.finishPrepare.outcome == 'success' && github.event_name == 'pull_request'
uses: reviewdog/action-suggester@94877e550e6b522dc1d21231974b645ff2f084ce # pin@v1
with:
tool_name: PHP-CS-Fixer
fail_on_error: "true"