-
Notifications
You must be signed in to change notification settings - Fork 13
280 lines (236 loc) · 10.8 KB
/
check-extension.yaml
File metadata and controls
280 lines (236 loc) · 10.8 KB
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
name: MageCheck Extension
on:
workflow_call:
inputs:
path:
type: string
required: false
default: "."
description: "The folder of the Magento store or extension that you are testing."
magento_repository:
type: string
required: false
default: "https://mirror.mage-os.org/"
description: "Where to install Magento from"
matrix:
type: string
required: true
description: "The matrix of Magento versions to test against"
fail-fast:
type: boolean
required: false
default: true
composer_cache_key:
type: string
required: false
default: "_mageos"
description: A key to version the composer cache. Can be incremented if you need to bust the cache.
secrets:
composer_auth:
required: false
description: "Your composer credentials (typically a stringified json object of the contents of your auth.json)"
jobs:
unit-test-extension:
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{ fromJSON(inputs.matrix) }}
fail-fast: ${{ inputs.fail-fast }}
steps:
- uses: actions/checkout@v6
- uses: graycoreio/github-actions-magento2/setup-magento@main
id: setup-magento
with:
php-version: ${{ matrix.php }}
tools: composer:v${{ matrix.composer }}
mode: extension
magento_version: ${{ matrix.magento }}
magento_repository: ${{ inputs.magento_repository }}
composer_auth: ${{ secrets.composer_auth }}
- uses: graycoreio/github-actions-magento2/cache-magento@main
with:
mode: extension
composer_cache_key: ${{ inputs.composer_cache_key }}
- name: Add extension repository
working-directory: ${{ steps.setup-magento.outputs.path }}
run: composer config repositories.local path ${{ github.workspace }}/${{ inputs.path }}
- name: Get package name
id: package
run: echo "name=$(jq -r .name ${{ github.workspace }}/${{ inputs.path }}/composer.json)" >> $GITHUB_OUTPUT
- name: Require extension
working-directory: ${{ steps.setup-magento.outputs.path }}
run: composer require "${{ steps.package.outputs.name }}:@dev" --no-install
- name: Composer install
working-directory: ${{ steps.setup-magento.outputs.path }}
run: composer install
env:
COMPOSER_AUTH: ${{ secrets.composer_auth }}
- name: Configure phpunit.xml.dist
working-directory: ${{ steps.setup-magento.outputs.path }}
run: |
## Add the testsuite
cat > /tmp/testsuite.xml << 'EOF'
<testsuite name="Extension_Unit_Tests">
<directory>../../../vendor/${{ steps.package.outputs.name }}/Test/Unit</directory>
</testsuite>
EOF
sed -i '/<testsuites>/r /tmp/testsuite.xml' dev/tests/unit/phpunit.xml.dist
## Disable allure (See https://github.com/magento/magento2/issues/36702 )
## (╯°□°)╯︵ ┻━┻
sed -i '/<extensions>/,/<\/extensions>/d' dev/tests/unit/phpunit.xml.dist
- name: Run extension unit tests
working-directory: ${{ steps.setup-magento.outputs.path }}
run: vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist --testsuite Extension_Unit_Tests
compile-extension:
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{ fromJSON(inputs.matrix) }}
fail-fast: ${{ inputs.fail-fast }}
steps:
- uses: actions/checkout@v6
- uses: graycoreio/github-actions-magento2/setup-magento@main
id: setup-magento
with:
php-version: ${{ matrix.php }}
tools: composer:v${{ matrix.composer }}
mode: extension
magento_version: ${{ matrix.magento }}
magento_repository: ${{ inputs.magento_repository }}
composer_auth: ${{ secrets.composer_auth }}
- uses: graycoreio/github-actions-magento2/cache-magento@main
with:
mode: extension
composer_cache_key: ${{ inputs.composer_cache_key }}
- name: Add extension repository
working-directory: ${{ steps.setup-magento.outputs.path }}
run: composer config repositories.local path ${{ github.workspace }}/${{ inputs.path }}
- name: Get package name
id: package
run: echo "name=$(jq -r .name ${{ github.workspace }}/${{ inputs.path }}/composer.json)" >> $GITHUB_OUTPUT
- name: Require extension
working-directory: ${{ steps.setup-magento.outputs.path }}
run: composer require "${{ steps.package.outputs.name }}:@dev" --no-install
env:
COMPOSER_AUTH: ${{ secrets.composer_auth }}
- name: Composer install
working-directory: ${{ steps.setup-magento.outputs.path }}
run: composer install
env:
COMPOSER_AUTH: ${{ secrets.composer_auth }}
- name: Enable all modules
working-directory: ${{ steps.setup-magento.outputs.path }}
run: php bin/magento module:enable --all
- name: Compile
working-directory: ${{ steps.setup-magento.outputs.path }}
run: php bin/magento setup:di:compile
coding-standard:
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{ fromJSON(inputs.matrix) }}
fail-fast: ${{ inputs.fail-fast }}
steps:
- uses: actions/checkout@v6
- name: Get Composer Version
uses: graycoreio/github-actions-magento2/get-composer-version@main
id: get-composer-version
- name: Check if allow-plugins option is available for this version of composer
uses: graycoreio/github-actions-magento2/semver-compare@main
with:
version: 2.2
compare_against: ${{ steps.get-composer-version.outputs.version }}
id: is-allow-plugins-available
- name: Enable dealerdirect/phpcodesniffer-composer-installer plugin
shell: bash
working-directory: ${{ inputs.path }}
run: composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true --global
if: steps.is-allow-plugins-available.outputs.result < 1
- name: Install Coding Standard
shell: bash
working-directory: ${{ inputs.path }}
run: composer require "magento/magento-coding-standard" "magento/php-compatibility-fork"
env:
COMPOSER_AUTH: ${{ secrets.composer_auth }}
- name: Register Coding Standard
shell: bash
working-directory: ${{ inputs.path }}
run: vendor/bin/phpcs --config-set installed_paths vendor/magento/magento-coding-standard,vendor/magento/php-compatibility-fork
- name: Coding Standard Check
shell: bash
run: |
if [ -f .phpcs.xml ] || [ -f phpcs.xml ] || [ -f .phpcs.xml.dist ] || [ -f phpcs.xml.dist ]; then
./vendor/bin/phpcs .
else
./vendor/bin/phpcs --standard=Magento2 --ignore=*vendor/* .
fi
working-directory: ${{ inputs.path }}
integration_test:
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{ fromJSON(inputs.matrix) }}
fail-fast: ${{ inputs.fail-fast }}
services: ${{ matrix.services }}
steps:
- uses: actions/checkout@v6
- uses: graycoreio/github-actions-magento2/setup-magento@main
id: setup-magento
with:
php-version: ${{ matrix.php }}
tools: composer:v${{ matrix.composer }}
mode: extension
magento_version: ${{ matrix.magento }}
magento_repository: ${{ inputs.magento_repository }}
composer_auth: ${{ secrets.composer_auth }}
- uses: graycoreio/github-actions-magento2/cache-magento@main
with:
mode: extension
composer_cache_key: ${{ inputs.composer_cache_key }}
- name: Add extension repository
working-directory: ${{ steps.setup-magento.outputs.path }}
run: composer config repositories.local path ${{ github.workspace }}/${{ inputs.path }}
- name: Get package name
id: package
run: echo "name=$(jq -r .name ${{ github.workspace }}/${{ inputs.path }}/composer.json)" >> $GITHUB_OUTPUT
- name: Require extension
working-directory: ${{ steps.setup-magento.outputs.path }}
run: composer require "${{ steps.package.outputs.name }}:@dev" --no-install
env:
COMPOSER_AUTH: ${{ secrets.composer_auth }}
- name: Composer install
working-directory: ${{ steps.setup-magento.outputs.path }}
run: composer install
env:
COMPOSER_AUTH: ${{ secrets.composer_auth }}
- uses: graycoreio/github-actions-magento2/get-magento-version@main
id: magento-version
with:
working-directory: ${{ steps.setup-magento.outputs.path }}
- name: Replace Configuration Settings for env
working-directory: ${{ steps.setup-magento.outputs.path }}/dev/tests/integration
run: |
sed -i "s/'db-host' => 'localhost'/'db-host' => '127.0.0.1'/" etc/install-config-mysql.php.dist
sed -i "s/'db-user' => 'root'/'db-user' => 'user'/" etc/install-config-mysql.php.dist
sed -i "s/'db-password' => '123123q'/'db-password' => 'password'/" etc/install-config-mysql.php.dist
sed -i "s/'elasticsearch-host' => 'localhost'/'elasticsearch-host' => '127.0.0.1'/" etc/install-config-mysql.php.dist
sed -i "s/'amqp-host' => 'localhost'/'amqp-host' => '127.0.0.1'/" etc/install-config-mysql.php.dist
- name: Enable log-bin-trust-function-creators
run: |
mysql -h127.0.0.1 -uroot -prootpassword -e "SET GLOBAL log_bin_trust_function_creators = 1;"
- name: Configure phpunit.xml.dist
working-directory: ${{ steps.setup-magento.outputs.path }}
run: |
## Add the testsuite
cat > /tmp/testsuite.xml << 'EOF'
<testsuite name="Extension_Integration_Tests">
<directory>../../../vendor/${{ steps.package.outputs.name }}/Test/Integration</directory>
</testsuite>
EOF
sed -i '/<testsuites>/r /tmp/testsuite.xml' dev/tests/integration/phpunit.xml.dist
- name: Run Integration Tests
working-directory: ${{ steps.setup-magento.outputs.path }}/dev/tests/integration
run: ../../../vendor/bin/phpunit -c phpunit.xml.dist --testsuite Extension_Integration_Tests
- name: Upload test sandbox dir
uses: actions/upload-artifact@v6
if: failure()
with:
name: sandbox-data-${{ steps.magento-version.outputs.version }}
path: ${{ steps.setup-magento.outputs.path }}/dev/tests/integration/tmp/sandbox-*
retention-days: 3