feat: align plugin and pipeline with Shopware guidelines #13
No files matched your search
@@ -1,7 +1,8 @@
|
|||||||
name: plugin-checks
|
name: plugin-checks
|
||||||
|
|
||||||
# Plugin-agnostic: nothing below names this plugin. Name, version and paths come from composer.json.
|
# 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.
|
# shopware-cli runs from its official Docker image, intentionally unpinned (latest); a red build
|
||||||
|
# after a CLI release means fix the config.
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
@@ -11,15 +12,8 @@ permissions:
|
|||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
validate:
|
# Packages the extension (builds admin/storefront assets) and validates the resulting zip,
|
||||||
runs-on: ubuntu-latest
|
# which is the artifact that ships. A separate directory validate would only repeat these checks.
|
||||||
container:
|
|
||||||
image: ghcr.io/shopware/shopware-cli:latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Validate extension
|
|
||||||
run: shopware-cli extension validate .
|
|
||||||
|
|
||||||
package:
|
package:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
@@ -28,33 +22,29 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
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
|
- name: Package extension
|
||||||
run: shopware-cli extension package . --output-directory .build --filename package.zip --git-commit "$GITHUB_SHA"
|
run: shopware-cli extension package . --output-directory .build --filename package.zip --git-commit "$GITHUB_SHA"
|
||||||
- name: Validate packaged zip
|
- name: Validate packaged zip
|
||||||
run: shopware-cli extension validate .build/package.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
|
- name: Assert built JS is in the zip
|
||||||
run: |
|
run: scripts/ci/assert-built-assets.sh .build/package.zip
|
||||||
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:
|
phpunit:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# shivammathur/setup-php hangs on this runner, so PHP comes from Debian bookworm (8.2) via apt.
|
# Same image as above: it already ships PHP, Composer and Node, so no apt install.
|
||||||
container:
|
container:
|
||||||
image: node:20-bookworm
|
image: ghcr.io/shopware/shopware-cli:latest
|
||||||
services:
|
services:
|
||||||
database:
|
database:
|
||||||
image: mariadb:11.4
|
# Shopware 6.6 supports MariaDB 10.11 / MySQL 8; 11.4 broke Shopware's own migrations.
|
||||||
|
image: mariadb:10.11
|
||||||
env:
|
env:
|
||||||
MARIADB_ROOT_PASSWORD: root
|
MARIADB_ROOT_PASSWORD: root
|
||||||
env:
|
env:
|
||||||
@@ -67,10 +57,15 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
path: plugin-src
|
path: plugin-src
|
||||||
- name: Install PHP and tools
|
- uses: actions/cache@v4
|
||||||
run: |
|
with:
|
||||||
apt-get update -q
|
path: |
|
||||||
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
|
~/.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
|
- name: Wait for the database
|
||||||
run: |
|
run: |
|
||||||
for i in $(seq 60); do
|
for i in $(seq 60); do
|
||||||
@@ -81,7 +76,7 @@ jobs:
|
|||||||
- name: Resolve plugin name
|
- name: Resolve plugin name
|
||||||
run: |
|
run: |
|
||||||
# plugin directory name = short class name of extra.shopware-plugin-class
|
# plugin directory name = short class name of extra.shopware-plugin-class
|
||||||
CLASS=$(jq -r '.extra["shopware-plugin-class"]' plugin-src/composer.json)
|
CLASS=$(php -r 'echo json_decode(file_get_contents("plugin-src/composer.json"), true)["extra"]["shopware-plugin-class"];')
|
||||||
echo "PLUGIN_NAME=${CLASS##*\\}" >> "$GITHUB_ENV"
|
echo "PLUGIN_NAME=${CLASS##*\\}" >> "$GITHUB_ENV"
|
||||||
- name: Create Shopware 6.6 project
|
- name: Create Shopware 6.6 project
|
||||||
run: composer create-project shopware/production:6.6.* shopware --no-interaction --no-scripts
|
run: composer create-project shopware/production:6.6.* shopware --no-interaction --no-scripts
|
||||||
|
|||||||
@@ -49,9 +49,14 @@ jobs:
|
|||||||
echo "skip=false" >> "$GITHUB_OUTPUT"
|
echo "skip=false" >> "$GITHUB_OUTPUT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Validate extension
|
- uses: actions/cache@v4
|
||||||
if: steps.meta.outputs.skip == 'false'
|
if: steps.meta.outputs.skip == 'false'
|
||||||
run: shopware-cli extension validate .
|
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 (prebuilt admin/storefront assets)
|
- name: Package extension (prebuilt admin/storefront assets)
|
||||||
if: steps.meta.outputs.skip == 'false'
|
if: steps.meta.outputs.skip == 'false'
|
||||||
@@ -63,6 +68,10 @@ jobs:
|
|||||||
if: steps.meta.outputs.skip == 'false'
|
if: steps.meta.outputs.skip == 'false'
|
||||||
run: shopware-cli extension validate ".build/${{ steps.meta.outputs.zip }}"
|
run: shopware-cli extension validate ".build/${{ steps.meta.outputs.zip }}"
|
||||||
|
|
||||||
|
- name: Assert built JS is in the zip
|
||||||
|
if: steps.meta.outputs.skip == 'false'
|
||||||
|
run: scripts/ci/assert-built-assets.sh ".build/${{ steps.meta.outputs.zip }}"
|
||||||
|
|
||||||
- name: Extract changelog section
|
- name: Extract changelog section
|
||||||
if: steps.meta.outputs.skip == 'false'
|
if: steps.meta.outputs.skip == 'false'
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -36,14 +36,13 @@ on branches `research/shopware-guideline-checklist`, `research/shopware-cli-ci-b
|
|||||||
Jobs (all required checks on `main`):
|
Jobs (all required checks on `main`):
|
||||||
`pr-version-check.yml` (job `version-changelog`) is unchanged apart from `permissions:`; its name keeps the existing required context. New `plugin-checks.yml`:
|
`pr-version-check.yml` (job `version-changelog`) is unchanged apart from `permissions:`; its name keeps the existing required context. New `plugin-checks.yml`:
|
||||||
|
|
||||||
1. `validate` - install `shopware-cli`, `extension validate .` (hard gate, no `|| true`).
|
1. `package` - `extension package` with `--git-commit "$GITHUB_SHA"`, `extension validate` on the resulting zip (hard gate; replaces a separate directory validate, which only repeats those checks), then `scripts/ci/assert-built-assets.sh` (built admin/storefront JS present when sources exist). All shopware-cli jobs run in `ghcr.io/shopware/shopware-cli:latest`; npm and shopware-cli caches via `actions/cache`.
|
||||||
2. `package` - `extension package` with `--git-commit "$GITHUB_SHA"`, then assert the zip contains built admin JS (`Resources/public/administration/js`) when an admin entry exists.
|
2. `phpunit` - `composer create-project shopware/production` (6.6.x) + MariaDB service, copy the plugin into `custom/plugins`, install/activate, run phpunit. Runs in the same `shopware-cli` image (PHP and Composer included; `shivammathur/setup-php` hangs on this runner and apt installs cost ~4.5 min). MariaDB 10.11, because 11.4 broke Shopware's own migrations.
|
||||||
3. `phpunit` - `composer create-project shopware/production` (6.6.x) + MariaDB service, copy the plugin into `custom/plugins`, install/activate, run phpunit. PHP from the Debian bookworm container (8.2), because `shivammathur/setup-php` hangs on this runner.
|
|
||||||
|
|
||||||
### Release workflow (`.gitea/workflows/release.yml`)
|
### Release workflow (`.gitea/workflows/release.yml`)
|
||||||
|
|
||||||
On push to `main`, guarded against re-release by an existing tag:
|
On push to `main`, guarded against re-release by an existing tag:
|
||||||
validate -> `extension package --git-commit "$GITHUB_SHA"` -> **validate the zip** -> create the Gitea
|
`extension package --git-commit "$GITHUB_SHA"` -> **validate the zip** -> assert built assets -> create the Gitea
|
||||||
release via API (`POST /repos/{owner}/{repo}/releases`, creates the tag) with the zip as asset ->
|
release via API (`POST /repos/{owner}/{repo}/releases`, creates the tag) with the zip as asset ->
|
||||||
upload the same zip to the Composer registry -> link package to repository.
|
upload the same zip to the Composer registry -> link package to repository.
|
||||||
Removes the manual `git tag` step, the `akkuman` action and the `git archive` zip. Packaging happens
|
Removes the manual `git tag` step, the `akkuman` action and the `git archive` zip. Packaging happens
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Assert that a packaged extension zip contains the built admin/storefront JS when the sources exist.
|
||||||
|
# Usage: scripts/ci/assert-built-assets.sh <zip> (run from the repo root; BusyBox-safe: uses unzip -l)
|
||||||
|
set -euo pipefail
|
||||||
|
ZIP="${1:?usage: assert-built-assets.sh <zip>}"
|
||||||
|
LIST=$(unzip -l "$ZIP")
|
||||||
|
|
||||||
|
check() { # <label> <entry-glob-prefix> <expected path in zip>
|
||||||
|
local label="$1" entry="$2" expected="$3"
|
||||||
|
if [ -f "${entry}/main.js" ] || [ -f "${entry}/main.ts" ]; then
|
||||||
|
echo "$LIST" | grep -q "$expected" || { echo "::error::${label} entry exists but the zip has no built ${label} JS (${expected})"; exit 1; }
|
||||||
|
echo "ok: ${label} JS is in the zip"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check admin src/Resources/app/administration/src "Resources/public/administration/js/"
|
||||||
|
check storefront src/Resources/app/storefront/src "Resources/app/storefront/dist/"
|
||||||
@@ -10,7 +10,6 @@ tea api -X PATCH "repos/${REPO}/branch_protections/main" -d '{
|
|||||||
"enable_status_check": true,
|
"enable_status_check": true,
|
||||||
"status_check_contexts": [
|
"status_check_contexts": [
|
||||||
"version-changelog / version-changelog (pull_request)",
|
"version-changelog / version-changelog (pull_request)",
|
||||||
"plugin-checks / validate (pull_request)",
|
|
||||||
"plugin-checks / package (pull_request)",
|
"plugin-checks / package (pull_request)",
|
||||||
"plugin-checks / phpunit (pull_request)"
|
"plugin-checks / phpunit (pull_request)"
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in new issue
Block a user