Skip to content

Commit 14b82f3

Browse files
committed
feat(check-extension): add integration tests
1 parent c9c680f commit 14b82f3

File tree

2 files changed

+91
-1
lines changed

2 files changed

+91
-1
lines changed

.github/workflows/_internal_check_extension.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
- uses: ./supported-version
3131
with:
3232
kind: currently-supported
33+
include_services: true
3334
id: supported-version
3435
check-workflow:
3536
needs: compute_matrix

.github/workflows/check-extension.yaml

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,93 @@ jobs:
188188
shell: bash
189189
run: |
190190
./vendor/bin/phpcs --standard=Magento2 --ignore=*vendor/* .
191-
working-directory: ${{ inputs.path }}
191+
working-directory: ${{ inputs.path }}
192+
193+
integration_test:
194+
runs-on: ${{ matrix.os }}
195+
strategy:
196+
matrix: ${{ fromJSON(inputs.matrix) }}
197+
fail-fast: ${{ inputs.fail-fast }}
198+
services: ${{ matrix.services }}
199+
steps:
200+
- uses: actions/checkout@v6
201+
202+
- uses: graycoreio/github-actions-magento2/setup-magento@main
203+
id: setup-magento
204+
with:
205+
php-version: ${{ matrix.php }}
206+
tools: composer:v${{ matrix.composer }}
207+
mode: extension
208+
magento_version: ${{ matrix.magento }}
209+
magento_repository: ${{ inputs.magento_repository }}
210+
composer_auth: ${{ secrets.composer_auth }}
211+
212+
- uses: graycoreio/github-actions-magento2/cache-magento@main
213+
with:
214+
mode: extension
215+
composer_cache_key: ${{ inputs.composer_cache_key }}
216+
217+
- name: Add extension repository
218+
working-directory: ${{ steps.setup-magento.outputs.path }}
219+
run: composer config repositories.local path ${{ github.workspace }}/${{ inputs.path }}
220+
221+
- name: Get package name
222+
id: package
223+
run: echo "name=$(jq -r .name ${{ github.workspace }}/${{ inputs.path }}/composer.json)" >> $GITHUB_OUTPUT
224+
225+
- name: Require extension
226+
working-directory: ${{ steps.setup-magento.outputs.path }}
227+
run: composer require "${{ steps.package.outputs.name }}:@dev" --no-install
228+
env:
229+
COMPOSER_AUTH: ${{ secrets.composer_auth }}
230+
231+
- name: Composer install
232+
working-directory: ${{ steps.setup-magento.outputs.path }}
233+
run: composer install
234+
env:
235+
COMPOSER_AUTH: ${{ secrets.composer_auth }}
236+
237+
- uses: graycoreio/github-actions-magento2/get-magento-version@main
238+
id: magento-version
239+
with:
240+
working-directory: ${{ steps.setup-magento.outputs.path }}
241+
242+
- name: Replace Configuration Settings for env
243+
working-directory: ${{ steps.setup-magento.outputs.path }}/dev/tests/integration
244+
run: |
245+
sed -i "s/'db-host' => 'localhost'/'db-host' => '127.0.0.1'/" etc/install-config-mysql.php.dist
246+
sed -i "s/'db-user' => 'root'/'db-user' => 'user'/" etc/install-config-mysql.php.dist
247+
sed -i "s/'db-password' => '123123q'/'db-password' => 'password'/" etc/install-config-mysql.php.dist
248+
sed -i "s/'elasticsearch-host' => 'localhost'/'elasticsearch-host' => '127.0.0.1'/" etc/install-config-mysql.php.dist
249+
sed -i "s/'amqp-host' => 'localhost'/'amqp-host' => '127.0.0.1'/" etc/install-config-mysql.php.dist
250+
251+
- name: Enable log-bin-trust-function-creators
252+
run: |
253+
mysql -h127.0.0.1 -uroot -prootpassword -e "SET GLOBAL log_bin_trust_function_creators = 1;"
254+
255+
- name: Configure phpunit.xml.dist
256+
working-directory: ${{ steps.setup-magento.outputs.path }}
257+
run: |
258+
## Add the testsuite
259+
cat > /tmp/testsuite.xml << 'EOF'
260+
<testsuite name="Extension_Integration_Tests">
261+
<directory>../../../vendor/${{ steps.package.outputs.name }}/Test/Integration</directory>
262+
</testsuite>
263+
EOF
264+
sed -i '/<testsuites>/r /tmp/testsuite.xml' dev/tests/integration/phpunit.xml.dist
265+
266+
## Disable allure (See https://github.com/magento/magento2/issues/36702 )
267+
## (╯°□°)╯︵ ┻━┻
268+
sed -i '/<extensions>/,/<\/extensions>/d' dev/tests/integration/phpunit.xml.dist
269+
270+
- name: Run Integration Tests
271+
working-directory: ${{ steps.setup-magento.outputs.path }}/dev/tests/integration
272+
run: ../../../vendor/bin/phpunit -c phpunit.xml.dist --testsuite Extension_Integration_Tests
273+
274+
- name: Upload test sandbox dir
275+
uses: actions/upload-artifact@v4
276+
if: failure()
277+
with:
278+
name: sandbox-data-${{ steps.magento-version.outputs.version }}
279+
path: ${{ steps.setup-magento.outputs.path }}/dev/tests/integration/tmp/sandbox-*
280+
retention-days: 3

0 commit comments

Comments
 (0)