name: plugin-checks # Plugin-agnostic: nothing below names this plugin. Name, version and paths come from composer.json. # shopware-cli is 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 steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: '20' - name: Install shopware-cli run: | curl -sL https://github.com/shopware/shopware-cli/releases/latest/download/shopware-cli_Linux_x86_64.tar.gz | tar -xz -C /tmp shopware-cli sudo install /tmp/shopware-cli /usr/local/bin/shopware-cli || install /tmp/shopware-cli /usr/local/bin/shopware-cli - name: Validate extension run: shopware-cli extension validate . package: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: actions/setup-node@v4 with: node-version: '20' - name: Install shopware-cli run: | curl -sL https://github.com/shopware/shopware-cli/releases/latest/download/shopware-cli_Linux_x86_64.tar.gz | tar -xz -C /tmp shopware-cli sudo install /tmp/shopware-cli /usr/local/bin/shopware-cli || install /tmp/shopware-cli /usr/local/bin/shopware-cli - 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: | 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 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 steps: - uses: actions/checkout@v4 with: path: plugin-src - uses: shivammathur/setup-php@v2 env: runner: self-hosted # non-GitHub runner (act): without this setup-php hangs with: php-version: '8.3' extensions: gd, intl, pdo_mysql, zip, curl, mbstring, dom, xml, fileinfo, sodium, bcmath tools: composer - 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"