Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@
/phpstan.neon.dist export-ignore
/phpstan.shopware-6.7.1.0.neon.dist export-ignore
/phpunit.xml.dist export-ignore
/phpunit.xml export-ignore
/phpunit.cache export-ignore
/rector.php export-ignore
/composer.lock export-ignore
/AGENTS.md export-ignore
/magi.toml export-ignore
75 changes: 75 additions & 0 deletions .github/action/phpunit/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: 'PHPUnit'
description: 'Setup Shopware with this extension and run the plugin unit test suite'

inputs:
extension-name:
description: 'Shopware extension directory and plugin name'
required: true
shopware-github-token:
description: 'Token used for checking out Shopware'
required: true
php-version:
description: 'PHP version used by the Shopware setup action'
required: true
shopware-version:
description: 'Shopware version used by the Shopware setup action'
required: true
install:
description: 'Whether the Shopware setup action should install Shopware and activate the plugin'
required: false
default: 'true'
allow-insecure-versions:
description: 'Whether the Shopware setup action should allow insecure Shopware versions'
required: false
default: 'false'

runs:
using: 'composite'
steps:
- name: 'Setup Shopware and Extension'
uses: shopware/github-actions/setup-extension@main
with:
extensionName: ${{ inputs.extension-name }}
shopware-github-token: ${{ inputs.shopware-github-token }}
phpVersion: ${{ inputs.php-version }}
shopwareVersion: ${{ inputs.shopware-version }}
node-version: 22
skip-js-build: true
install: ${{ inputs.install }}
env: test
keep-composer-tools: true
allow-insecure-versions: ${{ inputs.allow-insecure-versions }}
extraRepositories: |
{
"${{ inputs.extension-name }}": {
"type": "path",
"url": "custom/plugins/${{ inputs.extension-name }}",
"symlink": true
}
}

- name: 'Validate composer.json and composer.lock'
working-directory: custom/plugins/${{ inputs.extension-name }}
shell: bash
run: composer validate

- name: 'Read PHPUnit version constraint'
id: phpunit-version
working-directory: custom/plugins/${{ inputs.extension-name }}
shell: bash
run: |
constraint=$(jq -r '.["require-dev"]["phpunit/phpunit"] // empty' composer.json)
if [ -z "$constraint" ]; then
echo 'Missing require-dev constraint for phpunit/phpunit in composer.json'
exit 1
fi
echo "constraint=$constraint" >> "$GITHUB_OUTPUT"

- name: 'Require PHPUnit'
shell: bash
run: composer require --dev "phpunit/phpunit:${{ steps.phpunit-version.outputs.constraint }}" --with-dependencies

- name: 'Run Unit Tests'
working-directory: custom/plugins/${{ inputs.extension-name }}
shell: bash
run: ../../../vendor/bin/phpunit --testdox --testsuite unit
54 changes: 54 additions & 0 deletions .github/action/shopware-version-matrix/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: 'Get Shopware Build Matrix'
description: 'Build Shopware version matrix from endoflife.date (maintained releases) with a fixed minimum version'

inputs:
minimum-version:
description: 'Minimum Shopware version that must always be included'
required: false
default: 'v6.7.1.0'
minimum-minor:
description: 'Minimum Shopware minor line to include (for example 7 for 6.7)'
required: false
default: '6.7'

outputs:
matrix:
description: 'JSON array of Shopware versions'
value: ${{ steps.fetch-versions.outputs.matrix }}

runs:
using: composite
steps:
- name: Fetch and Filter Versions
id: fetch-versions
shell: bash
run: |
set -euo pipefail

MIN_VERSION='${{ inputs.minimum-version }}'
MIN_MINOR='${{ inputs.minimum-minor }}'

if [[ "${MIN_VERSION}" != v* ]]; then
MIN_VERSION="v${MIN_VERSION}"
fi

LATEST_VERSIONS=$(
curl -fsSL 'https://endoflife.date/api/v1/products/shopware' \
| jq -r --argjson minMinor "${MIN_MINOR}" '
.result.releases
| map(
select(
.isMaintained == true
and ((.name | tonumber) >= $minMinor)
)
| .latest.name
) | .[] ' \
| sed 's/^/v/'
)

MATRIX=$(
printf '%s\n%s\n' "${MIN_VERSION}" "${LATEST_VERSIONS}" \
| jq -Rsc 'split("\n") | map(select(length > 0))'
)

echo "matrix=${MATRIX}" >> "$GITHUB_OUTPUT"
81 changes: 81 additions & 0 deletions .github/workflows/action-phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Reusable PHPUnit

on:
workflow_call:
inputs:
extension-name:
description: 'Shopware extension directory and plugin name'
required: true
type: string
php-version:
description: 'PHP version used by the Shopware setup action'
required: true
type: string
shopware-version:
description: 'Shopware version used by the Shopware setup action'
required: true
type: string
install:
description: 'Whether the Shopware setup action should install Shopware and activate the plugin'
required: false
type: string
default: 'true'
allow-insecure-versions:
description: 'Whether the Shopware setup action should allow insecure Shopware versions'
required: false
type: string
default: 'false'

jobs:
phpunit:
name: PHPUnit
runs-on: ubuntu-latest

steps:
- name: 'Setup Shopware and Extension'
uses: shopware/github-actions/setup-extension@main
with:
extensionName: ${{ inputs.extension-name }}
shopware-github-token: ${{ github.token }}
phpVersion: ${{ inputs.php-version }}
shopwareVersion: ${{ inputs.shopware-version }}
node-version: 22
skip-js-build: true
install: ${{ inputs.install }}
env: test
keep-composer-tools: true
allow-insecure-versions: ${{ inputs.allow-insecure-versions }}
extraRepositories: |
{
"${{ inputs.extension-name }}": {
"type": "path",
"url": "custom/plugins/${{ inputs.extension-name }}",
"symlink": true
}
}

- name: 'Validate composer.json and composer.lock'
working-directory: custom/plugins/${{ inputs.extension-name }}
shell: bash
run: composer validate

- name: 'Read PHPUnit version constraint'
id: phpunit-version
working-directory: custom/plugins/${{ inputs.extension-name }}
shell: bash
run: |
constraint=$(jq -r '.["require-dev"]["phpunit/phpunit"] // empty' composer.json)
if [ -z "$constraint" ]; then
echo 'Missing require-dev constraint for phpunit/phpunit in composer.json'
exit 1
fi
echo "constraint=$constraint" >> "$GITHUB_OUTPUT"

- name: 'Require PHPUnit'
shell: bash
run: composer require --dev "phpunit/phpunit:${{ steps.phpunit-version.outputs.constraint }}" --with-dependencies

- name: 'Run Unit Tests'
working-directory: custom/plugins/${{ inputs.extension-name }}
shell: bash
run: ../../../vendor/bin/phpunit --testdox --testsuite unit
54 changes: 54 additions & 0 deletions .github/workflows/apply-coding-standard.app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Apply Coding Standard

on:
push:
branches:
- main
paths:
- 'src/**'

permissions:
contents: write
pull-requests: write

jobs:
php-coding-standard:
name: 'Apply PHP Coding Standard'
runs-on: ubuntu-latest
steps:
- name: 'Checkout Code'
uses: actions/checkout@v4

- name: 'Setup PHP'
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
tools: composer

- name: 'Validate composer.json and composer.lock'
shell: bash
run: composer validate

- name: 'Install Composer Dependencies'
shell: bash
run: composer install --prefer-dist --no-progress --no-interaction --optimize-autoloader

- name: 'ECS PHP Code'
shell: bash
run: composer lint:fix

- name: 'Create pull-request'
uses: peter-evans/create-pull-request@v7
with:
commit-message: "[automated] Apply Coding Standard"
branch: 'automated-apply-coding-standards'
title: '[automated] Apply Coding Standard'
labels: 'automated'
delete-branch: true
token: ${{ secrets.GITHUB_TOKEN }}

- name: 'Enable Pull Request Merge when ready'
if: steps.cpr.outputs.pull-request-operation == 'created'
run: gh pr merge --auto "${{ steps.cpr.outputs.pull-request-number }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59 changes: 59 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: PHPStan Matrix

on:
push:
branches:
- main
- develop
paths:
- 'src/**'
pull_request:
branches:
- main
- develop
paths:
- 'src/**'

jobs:
phpstan:
name: 'PHP ${{ matrix.phpVersion }} | Shopware ${{ matrix.shopwareVersion }}'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
phpVersion: ['8.3', '8.4']
shopware:
- version: '6.7.1.0'
phpstanConfig: 'phpstan.shopware-6.7.1.0.neon.dist'
- version: '^6.7.1'
phpstanConfig: 'phpstan.neon.dist'

steps:
- name: 'Checkout code'
uses: actions/checkout@v6

- name: 'Setup PHP'
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.phpVersion }}'
tools: composer
coverage: 'xdebug3'

- name: 'Validate composer.json and composer.lock'
shell: bash
run: composer validate

- name: 'Set Shopware Version'
shell: bash
run: >
composer require --no-interaction --no-update
shopware/core:${{ matrix.shopware.version }}

- name: 'Install Composer Dependencies'
shell: bash
run: >
composer install --prefer-dist --no-progress --no-interaction --optimize-autoloader

- name: Run phpstan
shell: bash
run: vendor/bin/phpstan --configuration=${{ matrix.shopware.phpstanConfig }} --memory-limit=-1 --error-format=github
45 changes: 45 additions & 0 deletions .github/workflows/shopware-store-compliance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Shopware Store Compliance

on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop

jobs:
extension-verifier:
name: Extension Verifier
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v6

- name: 'Setup PHP'
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
tools: composer
coverage: 'xdebug3'

- name: 'Install Composer Dependencies'
shell: bash
run: composer install --prefer-dist --no-progress --no-interaction --optimize-autoloader

# inspired by https://github.com/shopware/github-actions/blob/main/extension-verifier/action.yml
- name: Install Shopware-CLI
uses: shopware/shopware-cli-action@v1

- name: Run verifier
if: inputs.action == 'check'
shell: bash
run: shopware-cli extension validate --store-compliance .

- name: Run formatter
if: inputs.action == 'format'
shell: bash
run: shopware-cli extension format . --dry-run
Loading