- drop the separate validate job (the zip is validated after packaging); same in release - shared scripts/ci/assert-built-assets.sh (BusyBox-safe), now also used by release - actions/cache for npm, shopware-cli and composer - phpunit: shopware-cli image instead of a 4.5 min apt install; MariaDB 10.11 (11.4 broke Shopware's migrations: Duplicate column 'sorter_key') - protect-main.sh: drop the removed validate context Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
95 lines
3.6 KiB
YAML
95 lines
3.6 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:
|
|
# Packages the extension (builds admin/storefront assets) and validates the resulting zip,
|
|
# which is the artifact that ships. A separate directory validate would only repeat these checks.
|
|
package:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: ghcr.io/shopware/shopware-cli:latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
- uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.npm
|
|
~/.cache/shopware-cli
|
|
key: swcli-${{ runner.os }}-${{ hashFiles('composer.json', 'src/Resources/app/**/package*.json') }}
|
|
restore-keys: swcli-${{ runner.os }}-
|
|
- 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: Assert built JS is in the zip
|
|
run: scripts/ci/assert-built-assets.sh .build/package.zip
|
|
|
|
phpunit:
|
|
runs-on: ubuntu-latest
|
|
# Same image as above: it already ships PHP, Composer and Node, so no apt install.
|
|
container:
|
|
image: ghcr.io/shopware/shopware-cli:latest
|
|
services:
|
|
database:
|
|
# Shopware 6.6 supports MariaDB 10.11 / MySQL 8; 11.4 broke Shopware's own migrations.
|
|
image: mariadb:10.11
|
|
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
|
|
- uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cache/composer
|
|
~/.composer/cache
|
|
key: composer-${{ runner.os }}-shopware-6.6-${{ hashFiles('plugin-src/composer.json') }}
|
|
restore-keys: composer-${{ runner.os }}-shopware-6.6-
|
|
- name: Toolchain
|
|
run: php -v && composer --version && php -m | tr '\n' ' '
|
|
- 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=$(php -r 'echo json_decode(file_get_contents("plugin-src/composer.json"), true)["extra"]["shopware-plugin-class"];')
|
|
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"
|