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: 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@v8.0.0-rc.1 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 - run: composer update --no-install working-directory: ${{ steps.setup-magento.outputs.path }} - uses: graycoreio/github-actions-magento2/cache-magento@v8.0.0-rc.1 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' ../../../vendor/${{ steps.package.outputs.name }}/Test/Unit EOF sed -i '//r /tmp/testsuite.xml' dev/tests/unit/phpunit.xml.dist ## Disable allure (See https://github.com/magento/magento2/issues/36702 ) ## (╯°□°)╯︵ ┻━┻ sed -i '//,/<\/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@v8.0.0-rc.1 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 }} - uses: graycoreio/github-actions-magento2/cache-magento@v8.0.0-rc.1 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@v8.0.0-rc.1 with: path: ${{ steps.setup-magento.outputs.path }} 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/cache-magento@v8.0.0-rc.1 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@v8.0.0-rc.1 with: path: ${{ inputs.path }} composer_auth: ${{ secrets.composer_auth }} 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@v8.0.0-rc.1 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 }} - uses: graycoreio/github-actions-magento2/cache-magento@v8.0.0-rc.1 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@v8.0.0-rc.1 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' ../../../vendor/${{ steps.package.outputs.name }}/Test/Integration EOF sed -i '//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