Replaces the curl/tar install and setup-node steps; the image ships the CLI plus its PHP/Node toolchain. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
100 lines
4.0 KiB
YAML
100 lines
4.0 KiB
YAML
name: plugin-checks
|
|
|
|
# Plugin-agnostic: nothing below names this plugin. Name, version and paths come from composer.json.
|
|
# shopware-cli runs from its official Docker image, intentionally unpinned (latest); a red build after a CLI release means fix the config.
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
validate:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: ghcr.io/shopware/shopware-cli:latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Validate extension
|
|
run: shopware-cli extension validate .
|
|
|
|
package:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: ghcr.io/shopware/shopware-cli:latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Package extension
|
|
run: shopware-cli extension package . --output-directory .build --filename package.zip --git-commit "$GITHUB_SHA"
|
|
- name: Validate packaged zip
|
|
run: shopware-cli extension validate .build/package.zip
|
|
- name: Ensure helper tools (jq, curl, unzip)
|
|
run: |
|
|
command -v jq >/dev/null && command -v curl >/dev/null && command -v unzip >/dev/null && exit 0
|
|
(apt-get update -q && apt-get install -y -q --no-install-recommends jq curl unzip) || apk add --no-cache jq curl unzip
|
|
- name: Assert built JS is in the zip
|
|
run: |
|
|
set -e
|
|
LIST=$(unzip -Z1 .build/package.zip)
|
|
if [ -f src/Resources/app/administration/src/main.js ] || [ -f src/Resources/app/administration/src/main.ts ]; then
|
|
echo "$LIST" | grep -q 'Resources/public/administration/js/' || { echo "::error::admin entry exists but the zip has no built admin JS"; exit 1; }
|
|
fi
|
|
if [ -f src/Resources/app/storefront/src/main.js ] || [ -f src/Resources/app/storefront/src/main.ts ]; then
|
|
echo "$LIST" | grep -q 'Resources/app/storefront/dist/' || { echo "::error::storefront entry exists but the zip has no built storefront JS"; exit 1; }
|
|
fi
|
|
|
|
phpunit:
|
|
runs-on: ubuntu-latest
|
|
# shivammathur/setup-php hangs on this runner, so PHP comes from Debian bookworm (8.2) via apt.
|
|
container:
|
|
image: node:20-bookworm
|
|
services:
|
|
database:
|
|
image: mariadb:11.4
|
|
env:
|
|
MARIADB_ROOT_PASSWORD: root
|
|
env:
|
|
DATABASE_URL: mysql://root:root@database:3306/shopware
|
|
APP_ENV: test
|
|
APP_URL: http://localhost
|
|
COMPOSER_MEMORY_LIMIT: '-1'
|
|
COMPOSER_ALLOW_SUPERUSER: '1'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
path: plugin-src
|
|
- name: Install PHP and tools
|
|
run: |
|
|
apt-get update -q
|
|
apt-get install -y -q --no-install-recommends php-cli php-gd php-intl php-mysql php-zip php-curl php-mbstring php-xml php-bcmath composer unzip jq git ca-certificates
|
|
- name: Wait for the database
|
|
run: |
|
|
for i in $(seq 60); do
|
|
(echo > /dev/tcp/database/3306) 2>/dev/null && exit 0
|
|
sleep 2
|
|
done
|
|
echo "::error::database service did not come up"; exit 1
|
|
- name: Resolve plugin name
|
|
run: |
|
|
# plugin directory name = short class name of extra.shopware-plugin-class
|
|
CLASS=$(jq -r '.extra["shopware-plugin-class"]' plugin-src/composer.json)
|
|
echo "PLUGIN_NAME=${CLASS##*\\}" >> "$GITHUB_ENV"
|
|
- name: Create Shopware 6.6 project
|
|
run: composer create-project shopware/production:6.6.* shopware --no-interaction --no-scripts
|
|
- name: Install Shopware and the plugin
|
|
working-directory: shopware
|
|
run: |
|
|
set -e
|
|
composer require --dev phpunit/phpunit:^10 --no-interaction
|
|
bin/console system:install --basic-setup --create-database --force --no-interaction
|
|
cp -r ../plugin-src "custom/plugins/${PLUGIN_NAME}"
|
|
bin/console plugin:refresh
|
|
bin/console plugin:install --activate "${PLUGIN_NAME}"
|
|
- name: Run phpunit
|
|
working-directory: shopware
|
|
run: vendor/bin/phpunit -c "custom/plugins/${PLUGIN_NAME}/phpunit.xml"
|