mirror of
https://github.com/graycoreio/github-actions-magento2.git
synced 2026-06-08 19:46:41 +00:00
d5c744e155
BREAKING CHANGE: Much of the "setup" that's built-into the command is removed in favor of a leaner action. This also includes the "on PR, only diff PR contents" behavior. This can be restored, but it shouldn't be the default and should be done as an input. Fix SEVERITY_FLAGS construction which exited 1 under bash -e when severity inputs were empty, causing CI failures.
248 lines
9.4 KiB
YAML
248 lines
9.4 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: "_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:
|
|
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:
|
|
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
|
|
|
|
- uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: ${{ matrix.php }}
|
|
tools: composer:v${{ matrix.composer }}
|
|
coverage: none
|
|
|
|
- uses: graycoreio/github-actions-magento2/coding-standard@main
|
|
with:
|
|
path: ${{ 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:
|
|
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 |