mirror of
https://github.com/graycoreio/github-actions-magento2.git
synced 2026-06-08 19:46:41 +00:00
244 lines
8.6 KiB
YAML
244 lines
8.6 KiB
YAML
name: MageCheck Store
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
path:
|
|
type: string
|
|
required: false
|
|
default: "."
|
|
description: "The folder of the Magento store that you are testing."
|
|
|
|
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.
|
|
|
|
store_artifact_name:
|
|
type: string
|
|
required: false
|
|
default: ""
|
|
description: "If provided, download store files from this artifact instead of using actions/checkout."
|
|
|
|
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_matrix:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
resolved: ${{ steps.resolve.outputs.resolved }}
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
if: inputs.store_artifact_name == ''
|
|
|
|
- uses: actions/download-artifact@v8
|
|
if: inputs.store_artifact_name != ''
|
|
with:
|
|
name: ${{ inputs.store_artifact_name }}
|
|
path: ${{ inputs.path }}
|
|
|
|
- uses: graycoreio/github-actions-magento2/get-magento-version@v8.3.0
|
|
id: get-magento-version
|
|
with:
|
|
working-directory: ${{ inputs.path }}
|
|
|
|
- uses: graycoreio/github-actions-magento2/supported-version@v8.3.0
|
|
id: supported-version
|
|
with:
|
|
project: ${{ steps.get-magento-version.outputs.supported_version_project }}
|
|
kind: custom
|
|
custom_versions: ${{ steps.get-magento-version.outputs.project }}:${{ fromJSON(steps.get-magento-version.outputs.version) }}
|
|
|
|
- uses: graycoreio/github-actions-magento2/resolve-check-config@v8.3.0
|
|
id: resolve
|
|
with:
|
|
kind: store
|
|
matrix: ${{ steps.supported-version.outputs.matrix }}
|
|
|
|
unit-test:
|
|
runs-on: ${{ matrix.os }}
|
|
needs: compute_matrix
|
|
if: ${{ fromJSON(needs.compute_matrix.outputs.resolved)['unit-test'].enabled != false }}
|
|
strategy:
|
|
matrix: ${{ fromJSON(needs.compute_matrix.outputs.resolved)['unit-test'].matrix }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
if: inputs.store_artifact_name == ''
|
|
|
|
- uses: actions/download-artifact@v8
|
|
if: inputs.store_artifact_name != ''
|
|
with:
|
|
name: ${{ inputs.store_artifact_name }}
|
|
path: ${{ inputs.path }}
|
|
|
|
- uses: graycoreio/github-actions-magento2/setup-magento@v8.3.0
|
|
id: setup-magento
|
|
with:
|
|
php-version: ${{ matrix.php }}
|
|
tools: composer:v${{ matrix.composer }}
|
|
mode: store
|
|
working-directory: ${{ inputs.path }}
|
|
composer_auth: ${{ secrets.composer_auth }}
|
|
|
|
- uses: graycoreio/github-actions-magento2/cache-magento@v8.3.0
|
|
with:
|
|
composer_cache_key: ${{ inputs.composer_cache_key }}
|
|
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 }}
|
|
|
|
- name: Configure phpunit.xml.dist
|
|
working-directory: ${{ steps.setup-magento.outputs.path }}
|
|
run: |
|
|
mkdir -p app/code
|
|
|
|
cat > /tmp/testsuite.xml << 'EOF'
|
|
<testsuite name="Store_Unit_Tests">
|
|
<directory>../../../app/code/*/*/Test/Unit</directory>
|
|
</testsuite>
|
|
EOF
|
|
sed -i '/<testsuites>/r /tmp/testsuite.xml' dev/tests/unit/phpunit.xml.dist
|
|
|
|
## PHPUnit 12 (Magento 2.4.9) implicitly enables failOnEmptyTestSuite when --testsuite is passed.
|
|
## Default it off only when the consumer hasn't set it themselves, so we don't clobber explicit configuration.
|
|
if ! grep -q 'failOnEmptyTestSuite=' dev/tests/unit/phpunit.xml.dist; then
|
|
sed -i 's|<phpunit |<phpunit failOnEmptyTestSuite="false" |' dev/tests/unit/phpunit.xml.dist
|
|
fi
|
|
|
|
## Disable allure (See https://github.com/magento/magento2/issues/36702 )
|
|
sed -i '/<extensions>/,/<\/extensions>/d' dev/tests/unit/phpunit.xml.dist
|
|
|
|
- name: Run unit tests
|
|
working-directory: ${{ steps.setup-magento.outputs.path }}
|
|
run: vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist --testsuite Store_Unit_Tests
|
|
|
|
coding-standard:
|
|
runs-on: ${{ matrix.os }}
|
|
needs: compute_matrix
|
|
if: ${{ fromJSON(needs.compute_matrix.outputs.resolved)['coding-standard'].enabled != false }}
|
|
strategy:
|
|
matrix: ${{ fromJSON(needs.compute_matrix.outputs.resolved)['coding-standard'].matrix }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
if: inputs.store_artifact_name == ''
|
|
|
|
- uses: actions/download-artifact@v8
|
|
if: inputs.store_artifact_name != ''
|
|
with:
|
|
name: ${{ inputs.store_artifact_name }}
|
|
path: ${{ inputs.path }}
|
|
|
|
- uses: graycoreio/github-actions-magento2/setup-magento@v8.3.0
|
|
id: setup-magento
|
|
with:
|
|
php-version: ${{ matrix.php }}
|
|
tools: composer:v${{ matrix.composer }}
|
|
mode: store
|
|
working-directory: ${{ inputs.path }}
|
|
composer_auth: ${{ secrets.composer_auth }}
|
|
|
|
- uses: graycoreio/github-actions-magento2/cache-magento@v8.3.0
|
|
with:
|
|
composer_cache_key: ${{ inputs.composer_cache_key }}
|
|
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 }}
|
|
|
|
- name: Create default phpcs.xml if none exists
|
|
working-directory: ${{ steps.setup-magento.outputs.path }}
|
|
run: |
|
|
mkdir -p app/code
|
|
if [ ! -f .phpcs.xml ] && [ ! -f phpcs.xml ] && [ ! -f .phpcs.xml.dist ] && [ ! -f phpcs.xml.dist ]; then
|
|
cat > phpcs.xml << 'EOF'
|
|
<ruleset name="Store">
|
|
<rule ref="Magento2"/>
|
|
<file>app/code</file>
|
|
</ruleset>
|
|
EOF
|
|
fi
|
|
|
|
- uses: graycoreio/github-actions-magento2/coding-standard@v8.3.0
|
|
with:
|
|
path: ${{ steps.setup-magento.outputs.path }}
|
|
composer_auth: ${{ secrets.composer_auth }}
|
|
|
|
smoke-test:
|
|
runs-on: ${{ matrix.os }}
|
|
needs: compute_matrix
|
|
if: ${{ fromJSON(needs.compute_matrix.outputs.resolved)['smoke-test'].enabled != false }}
|
|
services: ${{ matrix.services }}
|
|
strategy:
|
|
matrix: ${{ fromJSON(needs.compute_matrix.outputs.resolved)['smoke-test'].matrix }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
if: inputs.store_artifact_name == ''
|
|
|
|
- uses: actions/download-artifact@v8
|
|
if: inputs.store_artifact_name != ''
|
|
with:
|
|
name: ${{ inputs.store_artifact_name }}
|
|
path: ${{ inputs.path }}
|
|
|
|
- uses: graycoreio/github-actions-magento2/setup-magento@v8.3.0
|
|
id: setup-magento
|
|
with:
|
|
php-version: ${{ matrix.php }}
|
|
tools: composer:v${{ matrix.composer }}
|
|
mode: store
|
|
working-directory: ${{ inputs.path }}
|
|
composer_auth: ${{ secrets.composer_auth }}
|
|
|
|
- uses: graycoreio/github-actions-magento2/cache-magento@v8.3.0
|
|
with:
|
|
composer_cache_key: ${{ inputs.composer_cache_key }}
|
|
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 }}
|
|
|
|
- uses: graycoreio/github-actions-magento2/setup-install@v8.3.0
|
|
id: setup-install
|
|
with:
|
|
services: ${{ toJSON(matrix.services) }}
|
|
path: ${{ steps.setup-magento.outputs.path }}
|
|
container_id: ${{ job.services['php-fpm'].id }}
|
|
extra_args: --magento-init-params=MAGE_MODE=developer
|
|
|
|
- uses: graycoreio/github-actions-magento2/configure-service-nginx@v8.3.0
|
|
with:
|
|
container_id: ${{ job.services.nginx.id }}
|
|
magento_path: ${{ inputs.path }}
|
|
|
|
- uses: graycoreio/github-actions-magento2/smoke-test@v8.3.0
|
|
with:
|
|
kind: page
|
|
|
|
- uses: graycoreio/github-actions-magento2/smoke-test@v8.3.0
|
|
with:
|
|
kind: graphql |