mirror of
https://github.com/graycoreio/github-actions-magento2.git
synced 2026-06-08 19:46:41 +00:00
309 lines
12 KiB
YAML
309 lines
12 KiB
YAML
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: ""
|
|
description: A key to version the composer cache. Can be incremented if you need to bust the cache.
|
|
|
|
stamp:
|
|
type: boolean
|
|
required: false
|
|
default: false
|
|
description: "Cache the vendor/ directory in addition to the Composer download cache."
|
|
|
|
secrets:
|
|
composer_auth:
|
|
required: false
|
|
description: "Your composer credentials (typically a stringified json object of the contents of your auth.json)"
|
|
|
|
jobs:
|
|
compute_resolved:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
resolved: ${{ steps.resolve.outputs.resolved }}
|
|
steps:
|
|
- uses: graycoreio/github-actions-magento2/resolve-check-config@main
|
|
id: resolve
|
|
with:
|
|
kind: extension
|
|
matrix: ${{ inputs.matrix }}
|
|
|
|
unit-test-extension:
|
|
runs-on: ${{ matrix.os }}
|
|
needs: compute_resolved
|
|
if: ${{ fromJSON(needs.compute_resolved.outputs.resolved)['unit-test-extension'].enabled != false }}
|
|
strategy:
|
|
matrix: ${{ fromJSON(needs.compute_resolved.outputs.resolved)['unit-test-extension'].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 }}
|
|
|
|
- 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 }}
|
|
|
|
- run: composer update --no-install
|
|
working-directory: ${{ steps.setup-magento.outputs.path }}
|
|
env:
|
|
COMPOSER_AUTH: ${{ secrets.composer_auth }}
|
|
|
|
- uses: graycoreio/github-actions-magento2/cache-magento@main
|
|
with:
|
|
composer_cache_key: ${{ inputs.composer_cache_key && format('{0} | {1}', inputs.composer_cache_key, matrix.magento) || matrix.magento }}
|
|
working-directory: ${{ steps.setup-magento.outputs.path }}
|
|
stamp: ${{ inputs.stamp }}
|
|
|
|
- name: Composer install
|
|
working-directory: ${{ steps.setup-magento.outputs.path }}
|
|
run: composer install
|
|
env:
|
|
COMPOSER_AUTH: ${{ secrets.composer_auth }}
|
|
COMPOSER_MIRROR_PATH_REPOS: 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_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 }}
|
|
needs: compute_resolved
|
|
if: ${{ fromJSON(needs.compute_resolved.outputs.resolved)['compile-extension'].enabled != false }}
|
|
strategy:
|
|
matrix: ${{ fromJSON(needs.compute_resolved.outputs.resolved)['compile-extension'].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 }}
|
|
|
|
- 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 }}
|
|
|
|
- run: composer update --no-install
|
|
working-directory: ${{ steps.setup-magento.outputs.path }}
|
|
env:
|
|
COMPOSER_AUTH: ${{ secrets.composer_auth }}
|
|
|
|
- uses: graycoreio/github-actions-magento2/cache-magento@main
|
|
with:
|
|
composer_cache_key: ${{ inputs.composer_cache_key && format('{0} | {1}', inputs.composer_cache_key, matrix.magento) || matrix.magento }}
|
|
working-directory: ${{ steps.setup-magento.outputs.path }}
|
|
stamp: ${{ inputs.stamp }}
|
|
|
|
- name: Composer install
|
|
working-directory: ${{ steps.setup-magento.outputs.path }}
|
|
run: composer install
|
|
env:
|
|
COMPOSER_AUTH: ${{ secrets.composer_auth }}
|
|
COMPOSER_MIRROR_PATH_REPOS: 1
|
|
|
|
- uses: graycoreio/github-actions-magento2/setup-di-compile@main
|
|
with:
|
|
path: ${{ steps.setup-magento.outputs.path }}
|
|
|
|
compute_latest_matrix:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
matrix: ${{ steps.supported-version.outputs.matrix }}
|
|
steps:
|
|
- uses: graycoreio/github-actions-magento2/supported-version@main
|
|
id: supported-version
|
|
with:
|
|
kind: latest
|
|
|
|
coding-standard:
|
|
runs-on: ${{ matrix.os }}
|
|
needs: compute_latest_matrix
|
|
strategy:
|
|
matrix: ${{ fromJSON(needs.compute_latest_matrix.outputs.matrix) }}
|
|
fail-fast: ${{ inputs.fail-fast }}
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: ${{ matrix.php }}
|
|
tools: composer:v${{ matrix.composer }}
|
|
coverage: none
|
|
|
|
- uses: graycoreio/github-actions-magento2/cache-magento@main
|
|
with:
|
|
composer_cache_key: ${{ inputs.composer_cache_key && format('{0} | {1}', inputs.composer_cache_key, matrix.magento) || matrix.magento }}
|
|
|
|
- uses: graycoreio/github-actions-magento2/coding-standard@main
|
|
with:
|
|
path: ${{ inputs.path }}
|
|
composer_auth: ${{ secrets.composer_auth }}
|
|
|
|
integration_test:
|
|
runs-on: ${{ matrix.os }}
|
|
needs: compute_resolved
|
|
if: ${{ fromJSON(needs.compute_resolved.outputs.resolved)['integration_test'].enabled != false }}
|
|
strategy:
|
|
matrix: ${{ fromJSON(needs.compute_resolved.outputs.resolved)['integration_test'].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 }}
|
|
|
|
- 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 }}
|
|
|
|
- run: composer update --no-install
|
|
working-directory: ${{ steps.setup-magento.outputs.path }}
|
|
env:
|
|
COMPOSER_AUTH: ${{ secrets.composer_auth }}
|
|
|
|
- uses: graycoreio/github-actions-magento2/cache-magento@main
|
|
with:
|
|
composer_cache_key: ${{ inputs.composer_cache_key && format('{0} | {1}', inputs.composer_cache_key, matrix.magento) || matrix.magento }}
|
|
working-directory: ${{ steps.setup-magento.outputs.path }}
|
|
stamp: ${{ inputs.stamp }}
|
|
|
|
- name: Composer install
|
|
working-directory: ${{ steps.setup-magento.outputs.path }}
|
|
run: composer install
|
|
env:
|
|
COMPOSER_AUTH: ${{ secrets.composer_auth }}
|
|
COMPOSER_MIRROR_PATH_REPOS: 1
|
|
|
|
- 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@v7
|
|
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 |