Compare commits
47
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea252ecf6c | ||
|
|
8b13c5b3c8 | ||
|
|
fa464bc20d | ||
|
|
4abd77103e | ||
|
|
1176d3c87d | ||
|
|
bfb88a25b8 | ||
|
|
7f3e77a3e9 | ||
|
|
8b2c2278d2 | ||
|
|
18844718d2 | ||
|
|
eb2a3172e5 | ||
|
|
953f4ee579 | ||
|
|
391db5b621 | ||
|
|
8afe30b476 | ||
|
|
5f8cc9bdad | ||
|
|
c08d27c8e1 | ||
|
|
85980ee3bf | ||
|
|
8a72751a14 | ||
|
|
233f3eb17f | ||
|
|
37aba5d2f0 | ||
|
|
9f760cb6b0 | ||
|
|
ff69377749 | ||
|
|
c3b242675e | ||
|
|
1ec194b464 | ||
|
|
221ffece3f | ||
|
|
54eeab70aa | ||
|
|
89a445f900 | ||
|
|
a551034442 | ||
|
|
8efaef2042 | ||
|
|
29974928d2 | ||
|
|
36ef203797 | ||
|
|
ba2d1ec1d6 | ||
|
|
d117444bae | ||
|
|
58df03216d | ||
|
|
29402a35ac | ||
|
|
63134f7de4 | ||
|
|
b8b8ee6284 | ||
|
|
b93217cc51 | ||
|
|
61b4b2b1af | ||
|
|
ec5c40c9f2 | ||
|
|
56ada0cedc | ||
|
|
f50154b96b | ||
|
|
7aa11b0396 | ||
|
|
161c35dc8a | ||
|
|
a1f0160ab9 | ||
|
|
1ee83aad37 | ||
|
|
b2c2a8d80b | ||
|
|
31b9e61adb |
No files matched your search
@@ -0,0 +1,24 @@
|
|||||||
|
compatibility_date: 2026-02-11
|
||||||
|
# shopware-cli extension configuration (build/package/validate)
|
||||||
|
build:
|
||||||
|
zip:
|
||||||
|
pack:
|
||||||
|
excludes:
|
||||||
|
paths:
|
||||||
|
- tests
|
||||||
|
- docs
|
||||||
|
- scripts
|
||||||
|
- phpunit.xml
|
||||||
|
- docker-compose.yml
|
||||||
|
- skills-lock.json
|
||||||
|
- AGENTS.md
|
||||||
|
- CLAUDE.md
|
||||||
|
- QWEN.md
|
||||||
|
- .config
|
||||||
|
- .gitea
|
||||||
|
- .claude
|
||||||
|
- .scratch
|
||||||
|
- .wayfinder
|
||||||
|
- src/Resources/config/plugin-transparent.png
|
||||||
|
validation:
|
||||||
|
ignore: []
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
name: package-extension
|
||||||
|
description: >-
|
||||||
|
Package the Shopware extension with shopware-cli (builds admin/storefront assets), validate the
|
||||||
|
zip and assert it contains the built JS. Shared by the PR checks and the release workflow.
|
||||||
|
Must run in the ghcr.io/shopware/shopware-cli image, after actions/checkout.
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
filename:
|
||||||
|
description: Name of the zip written to .build/
|
||||||
|
default: package.zip
|
||||||
|
build:
|
||||||
|
description: "'false' skips packaging (a prebuilt zip is already in .build/) and only validates it"
|
||||||
|
default: 'true'
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- uses: actions/cache@v4
|
||||||
|
if: inputs.build == 'true'
|
||||||
|
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
|
||||||
|
if: inputs.build == 'true'
|
||||||
|
shell: bash
|
||||||
|
run: shopware-cli extension package . --output-directory .build --filename "${{ inputs.filename }}" --git-commit "$GITHUB_SHA"
|
||||||
|
- name: Validate packaged zip
|
||||||
|
shell: bash
|
||||||
|
run: shopware-cli extension validate ".build/${{ inputs.filename }}"
|
||||||
|
- name: Assert built JS is in the zip
|
||||||
|
shell: bash
|
||||||
|
run: scripts/ci/assert-built-assets.sh ".build/${{ inputs.filename }}"
|
||||||
@@ -0,0 +1,184 @@
|
|||||||
|
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
|
||||||
|
|
||||||
|
# A new push to the PR cancels the superseded run.
|
||||||
|
concurrency:
|
||||||
|
group: plugin-checks-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
# Every PR into main must bump the version and document it in CHANGELOG.md.
|
||||||
|
version-changelog:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# The version must be higher than the latest *published release* (not just higher than main), so main can
|
||||||
|
# carry a version whose release failed or was withdrawn without blocking the next PR.
|
||||||
|
- name: Check version is unreleased and changelog entry exists
|
||||||
|
env:
|
||||||
|
TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
PR_VERSION=$(grep -m1 '"version"' composer.json | sed -E 's/.*"version"[[:space:]]*:[[:space:]]*"([^"]+)".*/\1/')
|
||||||
|
LATEST=$(curl -sf -H "Authorization: token ${TOKEN}" "${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases?limit=100" \
|
||||||
|
| jq -r '.[].tag_name' | sed 's/^v//' | sort -V | tail -n1)
|
||||||
|
LATEST="${LATEST:-0.0.0}"
|
||||||
|
|
||||||
|
echo "latest release: $LATEST"
|
||||||
|
echo "PR version: $PR_VERSION"
|
||||||
|
|
||||||
|
if [ "$PR_VERSION" = "$LATEST" ] || [ "$(printf '%s\n%s\n' "$LATEST" "$PR_VERSION" | sort -V | tail -n1)" != "$PR_VERSION" ]; then
|
||||||
|
echo "::error::composer.json version ($PR_VERSION) is not greater than the latest release ($LATEST)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! grep -qF "## [$PR_VERSION]" CHANGELOG.md; then
|
||||||
|
echo "::error::CHANGELOG.md is missing a '## [$PR_VERSION]' heading"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "OK: $PR_VERSION is unreleased and documented in CHANGELOG.md"
|
||||||
|
|
||||||
|
# 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: ./.gitea/actions/package
|
||||||
|
# The release workflow reuses this tested zip when main ends up with the same tree
|
||||||
|
# (it falls back to packaging again otherwise).
|
||||||
|
- name: Tree hash of the packaged commit
|
||||||
|
id: tree
|
||||||
|
run: echo "hash=$(git rev-parse "${GITHUB_SHA}^{tree}")" >> "$GITHUB_OUTPUT"
|
||||||
|
- name: Save tested zip for the release
|
||||||
|
uses: actions/cache/save@v4
|
||||||
|
with:
|
||||||
|
path: .build/package.zip
|
||||||
|
key: plugin-zip-${{ steps.tree.outputs.hash }}
|
||||||
|
|
||||||
|
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:
|
||||||
|
# Already the *_test name: Shopware's TestBootstrapper would otherwise append _test and run every migration a second time.
|
||||||
|
DATABASE_URL: mysql://root:root@database:3306/shopware_test
|
||||||
|
APP_ENV: test
|
||||||
|
APP_URL: http://localhost
|
||||||
|
APP_SECRET: ci-secret-not-for-production
|
||||||
|
INSTANCE_ID: ci
|
||||||
|
COMPOSER_MEMORY_LIMIT: '-1'
|
||||||
|
COMPOSER_ALLOW_SUPERUSER: '1'
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
path: plugin-src
|
||||||
|
# The cache key follows the Shopware version: a new release inside the plugin's supported range changes
|
||||||
|
# the key, so the old project + database are never reused. Bump -v1 to force a refresh by hand.
|
||||||
|
- name: Resolve the latest Shopware Version
|
||||||
|
id: sw
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
# The plugin's own constraint (require.shopware/core, e.g. ~6.6.0) decides which versions are acceptable;
|
||||||
|
# Composer lists the matching ones newest first, the first stable one is the latest.
|
||||||
|
CONSTRAINT=$(php -r 'echo json_decode(file_get_contents("plugin-src/composer.json"), true)["require"]["shopware/core"];')
|
||||||
|
VERSION=$(composer show shopware/core "$CONSTRAINT" --all --format=json --no-interaction 2>/dev/null \
|
||||||
|
| php -r '$d = json_decode(stream_get_contents(STDIN), true); foreach ($d["versions"] as $v) { if (preg_match("/^v?\d+(\.\d+)+$/", $v)) { echo ltrim($v, "v"); exit; } }')
|
||||||
|
test -n "$VERSION" || { echo "::error::could not resolve a Shopware version for ${CONSTRAINT}"; exit 1; }
|
||||||
|
echo "Shopware ${VERSION} (constraint ${CONSTRAINT})"
|
||||||
|
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||||
|
# Project (vendor/, phpunit, config) and the installed database as a SQL dump. Neither depends on the plugin.
|
||||||
|
- name: Restore Shopware project and database
|
||||||
|
id: shopware
|
||||||
|
uses: actions/cache/restore@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
shopware
|
||||||
|
!shopware/var/cache
|
||||||
|
!shopware/var/log
|
||||||
|
shopware-db.sql.gz
|
||||||
|
key: shopware-${{ steps.sw.outputs.version }}-installed-v1
|
||||||
|
- name: Create Shopware project
|
||||||
|
if: steps.shopware.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
composer create-project "shopware/production:${{ steps.sw.outputs.version }}" shopware --no-interaction --no-scripts
|
||||||
|
composer require --dev phpunit/phpunit:^10 --no-interaction --no-scripts -d shopware
|
||||||
|
- name: Ensure the MariaDB client
|
||||||
|
run: |
|
||||||
|
command -v mariadb-dump >/dev/null || command -v mysqldump >/dev/null && exit 0
|
||||||
|
(apt-get update -q && apt-get install -y -q --no-install-recommends mariadb-client) || apk add --no-cache mariadb-client
|
||||||
|
- 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: Relax database durability (throwaway CI database, speeds up the install and the restore)
|
||||||
|
run: |
|
||||||
|
php -r '$p = new PDO("mysql:host=database;port=3306", "root", "root"); $p->exec("SET GLOBAL innodb_flush_log_at_trx_commit=0"); $p->exec("SET GLOBAL sync_binlog=0");'
|
||||||
|
# One install into shopware_test; the bootstrapper then sees an installed DB, skips its own install and
|
||||||
|
# only activates the plugin (tests/TestBootstrap.php forces plugin installation).
|
||||||
|
- name: Install Shopware
|
||||||
|
if: steps.shopware.outputs.cache-hit != 'true'
|
||||||
|
working-directory: shopware
|
||||||
|
run: bin/console system:install --basic-setup --create-database --force --no-interaction
|
||||||
|
- name: Dump the installed database
|
||||||
|
if: steps.shopware.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
DUMP=$(command -v mariadb-dump || command -v mysqldump)
|
||||||
|
"$DUMP" -h database -P 3306 -u root -proot --skip-ssl --single-transaction --routines --triggers \
|
||||||
|
--databases shopware_test | gzip > shopware-db.sql.gz
|
||||||
|
ls -l shopware-db.sql.gz
|
||||||
|
- name: Save Shopware project and database
|
||||||
|
if: steps.shopware.outputs.cache-hit != 'true'
|
||||||
|
uses: actions/cache/save@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
shopware
|
||||||
|
!shopware/var/cache
|
||||||
|
!shopware/var/log
|
||||||
|
shopware-db.sql.gz
|
||||||
|
key: shopware-${{ steps.sw.outputs.version }}-installed-v1
|
||||||
|
- name: Restore the database from the cache
|
||||||
|
if: steps.shopware.outputs.cache-hit == 'true'
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
CLIENT=$(command -v mariadb || command -v mysql)
|
||||||
|
gunzip -c shopware-db.sql.gz | "$CLIENT" -h database -P 3306 -u root -proot --skip-ssl
|
||||||
|
- name: Resolve plugin name and install the plugin sources
|
||||||
|
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"];')
|
||||||
|
PLUGIN_NAME="${CLASS##*\\}"
|
||||||
|
echo "PLUGIN_NAME=${PLUGIN_NAME}" >> "$GITHUB_ENV"
|
||||||
|
rm -rf "shopware/custom/plugins/${PLUGIN_NAME}"
|
||||||
|
cp -r plugin-src "shopware/custom/plugins/${PLUGIN_NAME}"
|
||||||
|
- name: Run phpunit
|
||||||
|
working-directory: shopware
|
||||||
|
run: vendor/bin/phpunit -c "custom/plugins/${PLUGIN_NAME}/phpunit.xml"
|
||||||
@@ -0,0 +1,154 @@
|
|||||||
|
name: release
|
||||||
|
|
||||||
|
# Plugin-agnostic: owner, repo, host, package name and version come from the `github` context
|
||||||
|
# and composer.json. shopware-cli runs from its official Docker image, intentionally unpinned (latest).
|
||||||
|
# RELEASE_TOKEN is the single token used for releases, assets and the Composer registry.
|
||||||
|
#
|
||||||
|
# Every step is idempotent (release/asset reuse, registry 409 = already published), so a failed run can
|
||||||
|
# simply be re-run and picks up where it stopped. There is deliberately no "tag exists -> skip" guard:
|
||||||
|
# it made a half-finished release (tag + release but no registry package) impossible to heal.
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
# Never run two releases at once; a second push waits instead of racing on the tag.
|
||||||
|
concurrency:
|
||||||
|
group: release
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ghcr.io/shopware/shopware-cli:latest
|
||||||
|
steps:
|
||||||
|
- name: Ensure helper tools (jq, curl, unzip, zip, git)
|
||||||
|
run: |
|
||||||
|
command -v jq >/dev/null && command -v curl >/dev/null && command -v unzip >/dev/null && command -v zip >/dev/null && command -v git >/dev/null && exit 0
|
||||||
|
(apt-get update -q && apt-get install -y -q --no-install-recommends jq curl unzip zip git) || apk add --no-cache jq curl unzip zip git
|
||||||
|
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
token: ${{ secrets.RELEASE_TOKEN }}
|
||||||
|
|
||||||
|
- name: Determine version, tag and file names
|
||||||
|
id: meta
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
VERSION=$(jq -r .version composer.json)
|
||||||
|
PACKAGE_NAME=$(jq -r .name composer.json)
|
||||||
|
REPO_NAME="${GITHUB_REPOSITORY#*/}"
|
||||||
|
TAG="v${VERSION}"
|
||||||
|
{
|
||||||
|
echo "version=${VERSION}"
|
||||||
|
echo "package_name=${PACKAGE_NAME}"
|
||||||
|
echo "tag=${TAG}"
|
||||||
|
echo "zip=${REPO_NAME}-${TAG}.zip"
|
||||||
|
} >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
# Reuse the zip the PR workflow already built and tested for this exact tree.
|
||||||
|
- name: Tree hash of this commit
|
||||||
|
id: tree
|
||||||
|
run: echo "hash=$(git rev-parse "${GITHUB_SHA}^{tree}")" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Restore the tested zip from the PR run
|
||||||
|
id: prebuilt
|
||||||
|
uses: actions/cache/restore@v4
|
||||||
|
with:
|
||||||
|
path: .build/package.zip
|
||||||
|
key: plugin-zip-${{ steps.tree.outputs.hash }}
|
||||||
|
|
||||||
|
- name: Name the prebuilt zip
|
||||||
|
if: steps.prebuilt.outputs.cache-hit == 'true'
|
||||||
|
run: mv .build/package.zip ".build/${{ steps.meta.outputs.zip }}"
|
||||||
|
|
||||||
|
# Packages only on a cache miss; always validates and asserts what ships (guards a bad cache entry).
|
||||||
|
- uses: ./.gitea/actions/package
|
||||||
|
with:
|
||||||
|
filename: ${{ steps.meta.outputs.zip }}
|
||||||
|
build: ${{ steps.prebuilt.outputs.cache-hit != 'true' }}
|
||||||
|
|
||||||
|
- name: Extract changelog section
|
||||||
|
run: |
|
||||||
|
awk -v ver="${{ steps.meta.outputs.version }}" '
|
||||||
|
BEGIN { found=0 }
|
||||||
|
/^## \[/ {
|
||||||
|
if (found) exit
|
||||||
|
if ($0 ~ "\\[" ver "\\]") { found=1; next }
|
||||||
|
}
|
||||||
|
found { print }
|
||||||
|
' CHANGELOG.md > release-notes.md
|
||||||
|
cat release-notes.md
|
||||||
|
|
||||||
|
- name: Create Gitea release (creates the tag) and upload the zip
|
||||||
|
env:
|
||||||
|
TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
|
||||||
|
TAG="${{ steps.meta.outputs.tag }}"
|
||||||
|
ZIP="${{ steps.meta.outputs.zip }}"
|
||||||
|
CODE=$(curl -s -o /tmp/release.json -w "%{http_code}" -H "Authorization: token ${TOKEN}" "${API}/releases/tags/${TAG}")
|
||||||
|
if [ "$CODE" = "200" ]; then
|
||||||
|
echo "Release ${TAG} already exists, reusing it."
|
||||||
|
else
|
||||||
|
BODY=$(jq -n --arg tag "$TAG" --arg sha "$GITHUB_SHA" --rawfile notes release-notes.md \
|
||||||
|
'{tag_name:$tag, target_commitish:$sha, name:$tag, body:$notes}')
|
||||||
|
curl -sf -H "Authorization: token ${TOKEN}" -H "Content-Type: application/json" -d "$BODY" "${API}/releases" > /tmp/release.json
|
||||||
|
fi
|
||||||
|
RELEASE_ID=$(jq -r .id /tmp/release.json)
|
||||||
|
echo "release id: ${RELEASE_ID}"
|
||||||
|
if jq -e --arg n "$ZIP" '.assets[]? | select(.name == $n)' /tmp/release.json > /dev/null; then
|
||||||
|
echo "Asset ${ZIP} already uploaded."
|
||||||
|
else
|
||||||
|
curl -sf -H "Authorization: token ${TOKEN}" -F "attachment=@.build/${ZIP}" \
|
||||||
|
"${API}/releases/${RELEASE_ID}/assets?name=${ZIP}" > /dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Gitea's Composer registry needs composer.json at the zip root, but shopware-cli zips wrap
|
||||||
|
# everything in one top-level folder (the registry answers 400 "composer.json file is missing").
|
||||||
|
# Same prebuilt content, repacked root-level.
|
||||||
|
- name: Repack the zip for the Composer registry
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
rm -rf /tmp/repack && mkdir /tmp/repack
|
||||||
|
unzip -q ".build/${{ steps.meta.outputs.zip }}" -d /tmp/repack
|
||||||
|
if [ -f /tmp/repack/composer.json ]; then
|
||||||
|
ROOT=/tmp/repack
|
||||||
|
else
|
||||||
|
ROOT=$(find /tmp/repack -mindepth 1 -maxdepth 1 -type d | head -1)
|
||||||
|
fi
|
||||||
|
test -f "$ROOT/composer.json" || { echo "::error::no composer.json found in the packaged zip"; exit 1; }
|
||||||
|
OUT="$PWD/.build/composer-${{ steps.meta.outputs.zip }}"
|
||||||
|
# explicit file list with the leading "./" stripped, so entries are stored as "composer.json", "src/..."
|
||||||
|
(cd "$ROOT" && find . -mindepth 1 | sed 's|^\./||' | zip -q "$OUT" -@)
|
||||||
|
unzip -l "$OUT" | grep -E ' composer\.json$' > /dev/null || { echo "::error::repacked zip has no root-level composer.json"; exit 1; }
|
||||||
|
echo "repacked: $OUT"
|
||||||
|
|
||||||
|
- name: Publish to the Composer registry
|
||||||
|
run: |
|
||||||
|
STATUS=$(curl -s -o /tmp/composer-publish.log -w "%{http_code}" \
|
||||||
|
-u "${GITHUB_REPOSITORY_OWNER}:${{ secrets.RELEASE_TOKEN }}" \
|
||||||
|
-T ".build/composer-${{ steps.meta.outputs.zip }}" \
|
||||||
|
"${GITHUB_SERVER_URL}/api/packages/${GITHUB_REPOSITORY_OWNER}/composer")
|
||||||
|
cat /tmp/composer-publish.log
|
||||||
|
if [ "$STATUS" != "201" ] && [ "$STATUS" != "409" ]; then
|
||||||
|
echo "Unexpected HTTP status $STATUS publishing to the Composer registry"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Link Composer package to this repository
|
||||||
|
run: |
|
||||||
|
ENCODED_NAME=$(printf '%s' "${{ steps.meta.outputs.package_name }}" | sed 's#/#%2F#g')
|
||||||
|
STATUS=$(curl -s -o /dev/null -w "%{http_code}" -u "${GITHUB_REPOSITORY_OWNER}:${{ secrets.RELEASE_TOKEN }}" -X POST \
|
||||||
|
"${GITHUB_SERVER_URL}/api/v1/packages/${GITHUB_REPOSITORY_OWNER}/composer/${ENCODED_NAME}/-/link/${GITHUB_REPOSITORY#*/}")
|
||||||
|
echo "link status: $STATUS"
|
||||||
|
if [ "$STATUS" != "201" ] && [ "$STATUS" != "400" ]; then
|
||||||
|
echo "::warning::Unexpected status linking the Composer package to this repository (HTTP $STATUS) - not fatal, release already published"
|
||||||
|
fi
|
||||||
+1
-1
@@ -14,7 +14,7 @@ composer.phar
|
|||||||
|
|
||||||
# Frontend
|
# Frontend
|
||||||
*.vite/
|
*.vite/
|
||||||
**/public/administration/js/
|
**/public/administration/assets/
|
||||||
**/public/static/js/
|
**/public/static/js/
|
||||||
|
|
||||||
# Environment
|
# Environment
|
||||||
|
|||||||
+81
-14
@@ -7,19 +7,86 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [0.1.0] - 2026-11-02
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Requires Shopware 6.7 (`shopware/core ~6.7.0`); 6.6 stays on the 0.0.x line.
|
||||||
|
- Administration: the list page is registered lazily, uses Meteor components (`mt-button`, `mt-banner`, `mt-progress-bar`) and stops polling on `beforeUnmount` (Vue 3).
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- The admin build failed on a combined `import type` statement, so the Settings card never appeared.
|
||||||
|
- Delete did nothing and the create progress modal never showed: both modals sat outside `sw-page`'s named slots, which Vue 3 drops. They now live in `#content`.
|
||||||
|
- Creating a dump failed on MariaDB when only MySQL 8's `mysqldump` was installed (`Unknown table 'COLUMN_STATISTICS'`); it now passes `--column-statistics=0` in that case.
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- The Settings sidebar navigation entry; the plugin is reached through its card in Settings → System, like core settings modules.
|
||||||
|
|
||||||
|
## [0.0.6] - 2026-10-04
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Services and routes are now configured in YAML; the plugin requires PHP `^8.2`.
|
||||||
|
- Release pipeline: the packaged `shopware-cli` zip (with prebuilt assets) is validated and used for the Gitea Release; the Composer registry gets the same content repacked root-level (Gitea requires `composer.json` at the zip root). The release is created through the Gitea API after packaging, so a failed build no longer leaves an orphan tag.
|
||||||
|
- New PR checks: `shopware-cli` validate, package build and phpunit (with a cached Shopware project and database).
|
||||||
|
- The PR version check compares against the latest published release instead of the version on `main`.
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- List, create, and delete SQL database dumps from a Settings admin page (nested under Settings, per
|
- Dedicated `aeon_dump_manager` monolog channel; dump jobs, deletions and purges are logged.
|
||||||
Shopware's [Add Menu Entry](https://developer.shopware.com/docs/v6.6/guides/plugins/plugins/administration/routing-navigation/add-menu-entry.html)
|
- Extension icon and `.config/shopware-extension.yml`.
|
||||||
guide) and via `aeon:dump:list`/`aeon:dump:create`/`aeon:dump:remove` console commands.
|
|
||||||
- Dumps are created with `mysqldump`/`mariadb-dump` (auto-detected, with an optional `dumpBinaryName`
|
### Fixed
|
||||||
override), gzip-compressed, and stored in the plugin's private Flysystem mount.
|
|
||||||
- `maxDumps` auto-purges the oldest dump on creation; `retantionDays` purges dumps and stale job rows
|
- The packaged zip no longer contains `.gitea/` and `.config/`.
|
||||||
on a recurring scheduled task.
|
- Release steps are idempotent (existing release and asset are reused, registry 409 counts as published), so a failed release can be re-run to completion.
|
||||||
- Admin UI dump creation runs asynchronously via Symfony Messenger with a polling progress bar; console
|
|
||||||
creation runs synchronously.
|
### Removed
|
||||||
- ACL-gated (`aeon_dump_manager.viewer`/`.creator`/`.deleter`), enforced both client-side and
|
|
||||||
server-side.
|
- Empty plugin lifecycle overrides.
|
||||||
- Filter the dump list by a from/to date range, and sort the `datetime`/`sizeBytes` columns
|
|
||||||
ascending or descending. Dates are formatted with Shopware's locale/timezone-aware
|
## [0.0.5] - 2026-09-21
|
||||||
`Shopware.Utils.format.date`, matching the existing `fileSize` formatting.
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Changed namespace
|
||||||
|
|
||||||
|
## [0.0.4] - 2026-09-21
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Published Composer packages are now linked to this repository (previously the release workflow
|
||||||
|
published them without a repository association, so they did not appear under the repo's
|
||||||
|
Packages tab).
|
||||||
|
|
||||||
|
## [0.0.3] - 2026-09-17
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Filter the dump list by date range and sort by date or size; dates use Shopware's locale-aware
|
||||||
|
formatting.
|
||||||
|
|
||||||
|
## [0.0.2] - 2026-09-21
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Automated release pipeline: a pre-merge check enforcing a semver version bump and a matching
|
||||||
|
CHANGELOG entry on every PR into `main`, and a post-merge workflow that tags the release,
|
||||||
|
packages the plugin with `shopware-cli`, publishes a Gitea Release with the packaged zip, and
|
||||||
|
publishes the package to this Gitea instance's Composer registry.
|
||||||
|
- `main` is now a protected branch: no direct pushes, merges require the version/changelog check
|
||||||
|
to pass.
|
||||||
|
|
||||||
|
## [0.0.1] - 2026-09-15
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- List, create, delete, and download gzip-compressed SQL dumps from a Settings admin page (async
|
||||||
|
creation with a polling progress bar) or via the `aeon:dump:list`, `aeon:dump:create`, and
|
||||||
|
`aeon:dump:remove` console commands (sync). Dumps are produced with `mysqldump`/`mariadb-dump`
|
||||||
|
(auto-detected, overridable via `dumpBinaryName`) and stored in the plugin's private filesystem.
|
||||||
|
- Retention controls: `maxDumps` purges the oldest dump when the limit is reached; `retantionDays`
|
||||||
|
purges expired dumps and stale job rows via a scheduled task.
|
||||||
|
- ACL-gated by `aeon_dump_manager.viewer`/`.creator`/`.deleter`, enforced client- and server-side.
|
||||||
@@ -14,13 +14,15 @@ the full build spec live under `.scratch/admin-dump-manager/` and `.scratch/dump
|
|||||||
- Plugin bootstrap class: `src/AeonDumpManager.php` (extends `Shopware\Core\Framework\Plugin`) — this
|
- Plugin bootstrap class: `src/AeonDumpManager.php` (extends `Shopware\Core\Framework\Plugin`) — this
|
||||||
is the entry point Shopware calls for install/uninstall/activate/deactivate/update lifecycle hooks.
|
is the entry point Shopware calls for install/uninstall/activate/deactivate/update lifecycle hooks.
|
||||||
- Plugin class name is wired via `composer.json` → `extra.shopware-plugin-class`.
|
- Plugin class name is wired via `composer.json` → `extra.shopware-plugin-class`.
|
||||||
- Services are registered manually in `src/Resources/config/services.xml` (Symfony DI, XML format,
|
- Services are registered manually in `src/Resources/config/services.yaml` (Symfony DI, YAML format,
|
||||||
autowiring is not configured — every new service/command/task must be added here explicitly with
|
autowiring is not configured — every new service/command/task must be added here explicitly with
|
||||||
its tag, e.g. `console.command` or `shopware.scheduled.task`).
|
its tag, e.g. `console.command` or `shopware.scheduled.task`).
|
||||||
- Plugin store-config UI fields (e.g. `maxDumps`, `retantionDays`) are defined in
|
- Plugin store-config UI fields (e.g. `maxDumps`, `retantionDays`) are defined in
|
||||||
`src/Resources/config/config.xml` and read at runtime via Shopware's SystemConfigService.
|
`src/Resources/config/config.xml` and read at runtime via Shopware's SystemConfigService.
|
||||||
- `src/Resources/app/administration/` holds the admin UI module (Vue-based Shopware Administration
|
- `src/Resources/app/administration/` holds the admin UI module (Vue-based Shopware Administration
|
||||||
extension), currently just the `swag-example` scaffold module.
|
extension). The `aeon-dump-manager` module (`src/module/aeon-dump-manager/`) provides the list page
|
||||||
|
(`page/aeon-dump-manager-list`), en-GB/de-DE snippets and ACL privilege roles (`acl/`: `viewer`,
|
||||||
|
`creator`, `deleter`); `src/service/dump-api.service.ts` is the client for the dump API routes.
|
||||||
|
|
||||||
## Running the plugin
|
## Running the plugin
|
||||||
|
|
||||||
@@ -51,6 +53,12 @@ activates this plugin inside a real Shopware kernel for the test run (`KERNEL_CL
|
|||||||
`Shopware\Core\Kernel` in `phpunit.xml`). This means tests require a working Shopware installation/DB
|
`Shopware\Core\Kernel` in `phpunit.xml`). This means tests require a working Shopware installation/DB
|
||||||
to bootstrap against — they are not runnable as an isolated PHP package.
|
to bootstrap against — they are not runnable as an isolated PHP package.
|
||||||
|
|
||||||
|
In CI (`phpunit` job) the latest Shopware version allowed by the plugin's `require.shopware/core` constraint
|
||||||
|
is resolved with Composer. The prepared project (`composer create-project` + phpunit, then `system:install`
|
||||||
|
into `shopware_test` on a MariaDB 10.11 service) plus a SQL dump of the installed database are cached under
|
||||||
|
a key that contains that version, so a new Shopware release invalidates the cache. On a hit the dump is restored instead of reinstalling; the plugin
|
||||||
|
is then copied into `custom/plugins` and the bootstrapper only activates it.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
vendor/bin/phpunit # full suite
|
vendor/bin/phpunit # full suite
|
||||||
vendor/bin/phpunit --filter TestClassName # single test class
|
vendor/bin/phpunit --filter TestClassName # single test class
|
||||||
@@ -59,14 +67,35 @@ vendor/bin/phpunit tests/SomeTest.php # single file
|
|||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
- PHP `^8.1`, `shopware/core` `~6.6.0` (from `composer.json`); `phpunit/phpunit` `^10.0` as the only
|
- PHP `^8.2`, `shopware/core` `~6.7.0` (from `composer.json`); `phpunit/phpunit` `^10.0` as the only
|
||||||
dev dependency.
|
dev dependency.
|
||||||
- PSR-4 autoload: `AeonDumpManager\` → `src/`, `AeonDumpManager\Tests\` → `tests/`.
|
- PSR-4 autoload: `AeonDumpManager\` → `src/`, `AeonDumpManager\Tests\` → `tests/`.
|
||||||
|
|
||||||
|
## CI / release pipeline
|
||||||
|
|
||||||
|
Gitea workflows in `.gitea/`, plugin-agnostic (name/version 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.
|
||||||
|
|
||||||
|
- `workflows/plugin-checks.yml` (PRs into `main`) has three jobs: `version-changelog` (the
|
||||||
|
`composer.json` version must be greater than the latest published Gitea release and have a matching
|
||||||
|
`## [x.y.z]` CHANGELOG heading), `package`
|
||||||
|
(shared composite action `actions/package`: `shopware-cli extension package`, `extension validate` on
|
||||||
|
the zip, `scripts/ci/assert-built-assets.sh`), and `phpunit`. The package job caches the tested zip
|
||||||
|
keyed by the commit's tree hash.
|
||||||
|
- `workflows/release.yml` (push to `main`, serialized; every step is idempotent so a failed run can simply be re-run): reuses the
|
||||||
|
cached zip when the tree hash matches (else packages again, always re-validates), creates the Gitea
|
||||||
|
release + tag via API with the zip as asset, publishes a root-level repack of the zip to the Composer registry
|
||||||
|
(Gitea requires `composer.json` at the zip root), then links the
|
||||||
|
package to the repo. Uses `RELEASE_TOKEN`.
|
||||||
|
- Required checks on `main` (`plugin-checks / version-changelog|package|phpunit (pull_request)`) are set
|
||||||
|
once with `scripts/protect-main.sh` (`tea api`). Build excludes/validation live in
|
||||||
|
`.config/shopware-extension.yml`. Background: `docs/spec/shopware-guideline-compliance.md`.
|
||||||
|
|
||||||
## Adding functionality
|
## Adding functionality
|
||||||
|
|
||||||
- New console commands go in `src/Command/`, new scheduled tasks in `src/ScheduledTask/` — both must
|
- New console commands go in `src/Command/`, new scheduled tasks in `src/ScheduledTask/` — both must
|
||||||
be registered in `src/Resources/config/services.xml` with the appropriate tag or Shopware will not
|
be registered in `src/Resources/config/services.yaml` with the appropriate tag or Shopware will not
|
||||||
discover them.
|
discover them.
|
||||||
- Scheduled tasks need a matching handler (tagged `messenger.message_handler`) to actually run; a bare
|
- Scheduled tasks need a matching handler (tagged `messenger.message_handler`) to actually run; a bare
|
||||||
`ScheduledTask` subclass like `ExampleTask` only defines the schedule, not the behavior.
|
`ScheduledTask` subclass like `ExampleTask` only defines the schedule, not the behavior.
|
||||||
+8
-8
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "aeon/dump-manager",
|
"name": "arthurerlich/aeon-dump-manager",
|
||||||
"description": "Export database dumps for Shopware 6 environments.",
|
"description": "Export database dumps for Shopware 6 environments.",
|
||||||
"type": "shopware-platform-plugin",
|
"type": "shopware-platform-plugin",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"version": "0.0.2",
|
"version": "0.1.0",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"shopware",
|
"shopware",
|
||||||
"shopware6",
|
"shopware6",
|
||||||
@@ -25,8 +25,8 @@
|
|||||||
"source": "https://git.arthurerlich.de/haylan/AeonDumpManager"
|
"source": "https://git.arthurerlich.de/haylan/AeonDumpManager"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.1",
|
"php": "^8.2",
|
||||||
"shopware/core": "~6.6.0"
|
"shopware/core": "~6.7.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^10.0"
|
"phpunit/phpunit": "^10.0"
|
||||||
@@ -35,12 +35,12 @@
|
|||||||
"shopware-plugin-class": "AeonDumpManager\\AeonDumpManager",
|
"shopware-plugin-class": "AeonDumpManager\\AeonDumpManager",
|
||||||
"copyright": "(c) by Arthur Erlich",
|
"copyright": "(c) by Arthur Erlich",
|
||||||
"label": {
|
"label": {
|
||||||
"de-DE": "Aeon Dump Manager",
|
"de-DE": "Dump Manager",
|
||||||
"en-GB": "Aeon Dump Manager"
|
"en-GB": "Dump Manager"
|
||||||
},
|
},
|
||||||
"description": {
|
"description": {
|
||||||
"de-DE": "Verwaltet Datenbank-Dumps für Shopware 6 Entwicklungsumgebungen.",
|
"de-DE": "Für Datenbank-Backups in Shopware 6 Umgebungen erzeugt Dump Manager komprimierte SQL-Dumps per Backend oder Konsole, listet und löscht sie und räumt alte Dumps automatisch auf.",
|
||||||
"en-GB": "Manages database dumps for Shopware 6 development environments."
|
"en-GB": "To get a database dump for Shopware 6 environments, Dump Manager creates compressed SQL dumps from the admin or console, lists and deletes them, and purges old dumps automatically."
|
||||||
},
|
},
|
||||||
"manufacturerLink": {
|
"manufacturerLink": {
|
||||||
"de-DE": "https://arthurerlich.de",
|
"de-DE": "https://arthurerlich.de",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
shopware:
|
shopware:
|
||||||
image: dockware/shopware:6.6.10.12
|
image: dockware/shopware:6.7.14.2
|
||||||
container_name: shopware
|
container_name: shopware
|
||||||
ports:
|
ports:
|
||||||
- "80:80" # Shop / Admin / Adminer / Mailcatcher (all served via path on this port)
|
- "80:80" # Shop / Admin / Adminer / Mailcatcher (all served via path on this port)
|
||||||
|
|||||||
@@ -0,0 +1,167 @@
|
|||||||
|
# Research: shopware-cli changelog handling and the PHP floor for a Shopware 6.6 plugin
|
||||||
|
|
||||||
|
Sources are primary only: `shopware/shopware-cli` source (main branch, fetched 2026-10-04),
|
||||||
|
`shopware/docs` (the repo behind developer.shopware.com, main), and `shopware/shopware` tags.
|
||||||
|
Paths below are relative to those repos. Refs are branch heads or tags as noted; no commit SHAs
|
||||||
|
were pinned.
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
- **`extension package --release` does not parse CHANGELOG.md.** It only generates one, from git commits, and only if `changelog.enabled: true` is set in `.config/shopware-extension.yml`. Our pipeline does not pass `--release`.
|
||||||
|
- **Parsing happens elsewhere:** in `account producer extension upload` (Store push) and in `extension get-changelog`. The parser treats every line starting with `#` as a version key.
|
||||||
|
- **Our Keep-a-Changelog file is not compatible with that parser.** The key becomes `# [0.1.0] - 2026-10-03`, never `0.1.0`, so the Store upload would fail with "english changelog is missing". This only matters if we later use `account producer extension upload`; today we publish to Gitea and a Composer registry.
|
||||||
|
- **Minimal fix if we ever upload to the Store:** add `CHANGELOG_en-GB.md` with `# x.y.z` headings and flat bullets, with no `###` sub-headings. Keep `CHANGELOG.md` for humans; the localized file wins for `en-GB`.
|
||||||
|
- **PHP:** Shopware 6.6.x requires `~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0` (6.6.0.0 was `~8.2.0 || ~8.3.0`). Our `php: ^8.2` is consistent but broader than core; it is harmless because `shopware/core ~6.6.0` already pins the effective range.
|
||||||
|
- **Recommendation:** keep `^8.2` or use `>=8.2`. Do not copy core's tilde list. Shopware's own docs skeleton declares no `php` at all, only `shopware/core`.
|
||||||
|
|
||||||
|
## Q1. Changelog handling
|
||||||
|
|
||||||
|
### 1.1 What the parser does (verified in source)
|
||||||
|
|
||||||
|
File: `internal/extension/changelog.go` (shopware-cli, main).
|
||||||
|
|
||||||
|
File discovery and locale:
|
||||||
|
|
||||||
|
```go
|
||||||
|
files, err := filepath.Glob(path + "/CHANGELOG*.md")
|
||||||
|
...
|
||||||
|
language := strings.Trim(strings.ReplaceAll(strings.ReplaceAll(filepath.Base(file), "CHANGELOG", ""), ".md", ""), "_")
|
||||||
|
if len(language) == 0 { language = "en-GB" }
|
||||||
|
```
|
||||||
|
|
||||||
|
- `CHANGELOG.md` maps to `en-GB`.
|
||||||
|
- `CHANGELOG_en-GB.md` maps to `en-GB`, and `CHANGELOG_de-DE.md` maps to `de-DE`.
|
||||||
|
- If both `CHANGELOG.md` and `CHANGELOG_en-GB.md` exist, both land in the same map slot. `filepath.Glob` returns lexically sorted names and `.` sorts before `_`, so `CHANGELOG_en-GB.md` is processed last and overwrites. This ordering is inferred from Go's documented sorted-directory behaviour; I did not run it.
|
||||||
|
|
||||||
|
Section splitting (`parseMarkdownChangelog`):
|
||||||
|
|
||||||
|
```go
|
||||||
|
for _, line := range strings.Split(content, "\n") {
|
||||||
|
if strings.HasPrefix(line, "#") {
|
||||||
|
...
|
||||||
|
currentVersion = strings.Trim(strings.TrimPrefix(line, "#"), " ")
|
||||||
|
```
|
||||||
|
|
||||||
|
- Every line that starts with `#`, at any heading depth, starts a new "version" section.
|
||||||
|
- The key is the line minus one leading `#`, with spaces trimmed. Only a single `#` is removed.
|
||||||
|
- The body is converted to HTML with goldmark via `internal/markdown`. Headings inside bodies are rendered as `<span class="hN">`.
|
||||||
|
- Upstream's own tests use this exact shape: `"# 1.0.0\n\n- Test\n- Test2\n# 2.0.0\n- Test3\n- Test4\n"` (`internal/extension/changelog_test.go`).
|
||||||
|
|
||||||
|
Version lookup (`parseExtensionMarkdownChangelog`):
|
||||||
|
|
||||||
|
- The key looked up is `ext.GetVersion().String()`, which is the plain version from `composer.json`, for example `0.1.0`.
|
||||||
|
- `changelogs["en-GB"][version]` must exist, or it returns an error ("english changelog is missing").
|
||||||
|
- `de-DE` is optional and falls back to the English file. If a `de-DE` file exists but lacks the version, it errors.
|
||||||
|
- The docs agree: "The zip file contains a `CHANGELOG*.md` file with a changelog entry for the new version. Having a German changelog is optional." (`products/tools/cli/shopware-account-commands/releasing-extension-to-shopware-store.md`).
|
||||||
|
|
||||||
|
### 1.2 Where it is used
|
||||||
|
|
||||||
|
`GetChangelog()` is called in only two non-test places:
|
||||||
|
|
||||||
|
- `internal/account-api/producer_store_upload.go`: `account producer extension upload` sends `de_DE` and `en_GB` texts as the Store changelog.
|
||||||
|
- `cmd/extension/extension_changelog.go`: `extension get-changelog`.
|
||||||
|
|
||||||
|
Not called from `cmd/extension/extension_package.go`, nor from validation: no `changelog` reference was found under `internal/validation`.
|
||||||
|
|
||||||
|
### 1.3 What `--release` does
|
||||||
|
|
||||||
|
`cmd/extension/extension_package.go`:
|
||||||
|
|
||||||
|
```go
|
||||||
|
extensionPackageCmd.Flags().BoolVar(&extensionReleaseMode, "release", false, "Prepare a release build: generate the changelog if enabled and, for apps, remove the secret from manifest.xml")
|
||||||
|
```
|
||||||
|
|
||||||
|
`internal/extension/zip.go`, `PrepareExtensionForRelease`:
|
||||||
|
|
||||||
|
```go
|
||||||
|
if ext.GetExtensionConfig().Changelog.Enabled {
|
||||||
|
...
|
||||||
|
changelogFile := fmt.Sprintf("# %s\n%s", v.String(), content)
|
||||||
|
os.WriteFile(path.Join(extensionRoot, "CHANGELOG_en-GB.md"), ...)
|
||||||
|
}
|
||||||
|
if ext.GetType() == "plugin" { return nil }
|
||||||
|
// apps only: remove setup/secret from manifest.xml
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Added:** a generated `CHANGELOG_en-GB.md`, containing `# <version>` plus one bullet per git commit between the last tag and the current commit (template `internal/changelog/changelog.tpl`). It only happens if `changelog.enabled: true`. The default is false (`internal/changelog/changelog.go`, `Enabled bool`).
|
||||||
|
- **Stripped:** the app secret in `manifest.xml`. This does not apply to plugins, which return early.
|
||||||
|
- **Not stripped or rewritten:** an existing `CHANGELOG.md` is left untouched. When enabled, the generated file overwrites any existing `CHANGELOG_en-GB.md`.
|
||||||
|
- This confirms `# x.y.z` is the format the tool itself writes.
|
||||||
|
- Docs on release mode and `changelog.enabled`: `products/tools/cli/extension-commands/build.md`, "Release mode" section.
|
||||||
|
|
||||||
|
### 1.4 Our repo
|
||||||
|
|
||||||
|
- `.gitea/actions/package/action.yml:29` runs `shopware-cli extension package . --output-directory .build --filename ... --git-commit "$GITHUB_SHA"`. There is no `--release`, and no `changelog:` key was found in `.config` or `.gitea`.
|
||||||
|
- The release notes come from our own awk in `.gitea/workflows/release.yml`, which matches `## [x.y.z]`. That is independent of shopware-cli.
|
||||||
|
- `CHANGELOG.md` uses `## [0.1.0] - 2026-10-03` and `### Added/Changed/...`.
|
||||||
|
|
||||||
|
### 1.5 Compatibility verdict
|
||||||
|
|
||||||
|
Walking `CHANGELOG.md` through `parseMarkdownChangelog` by hand (not executed):
|
||||||
|
|
||||||
|
- `## [0.1.0] - 2026-10-03` gives key `# [0.1.0] - 2026-10-03`, which never equals `0.1.0`.
|
||||||
|
- Each `### Added` and similar heading becomes its own bogus "version", so the entries under it are split off.
|
||||||
|
|
||||||
|
Result: **incompatible.** `account producer extension upload` and `extension get-changelog` would fail with "english changelog is missing". `extension package`, with or without `--release`, would not fail, because it does not call the parser. `extension validate` does not parse it either, as far as I could find.
|
||||||
|
|
||||||
|
Minimal change, only needed if we adopt Store upload:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
# 0.1.0
|
||||||
|
|
||||||
|
- Services and routes are now configured in YAML; the plugin requires PHP `^8.2`.
|
||||||
|
- Release pipeline: ...
|
||||||
|
```
|
||||||
|
|
||||||
|
- Put it in `CHANGELOG_en-GB.md` at the plugin root, with one `# <exact composer version>` section per release and flat bullets. Prefix bullets with Added/Changed/Fixed if the categories matter.
|
||||||
|
- No `###` sub-headings, and no brackets or dates in the heading.
|
||||||
|
- `CHANGELOG_de-DE.md` is optional.
|
||||||
|
- The alternative is to enable `changelog.enabled: true` plus `--release` and let the CLI generate it from commits. That would not use our hand-written entries.
|
||||||
|
- The packaged zip must contain the file. I did not verify whether `.config/shopware-extension.yml` pack excludes would remove it.
|
||||||
|
|
||||||
|
Not verified: the Store's own server-side handling of the changelog HTML. The CLI source only shows what is sent (`de_DE`/`en_GB` text), not what the Store renders. The Store API and backend are not public.
|
||||||
|
|
||||||
|
## Q2. PHP constraint
|
||||||
|
|
||||||
|
### 2.1 What Shopware 6.6 requires
|
||||||
|
|
||||||
|
`require.php` in `shopware/shopware` `src/Core/composer.json` and the root `composer.json`:
|
||||||
|
|
||||||
|
| Ref | `require.php` |
|
||||||
|
|---|---|
|
||||||
|
| `v6.6.0.0` | `"php": "~8.2.0 \|\| ~8.3.0"` |
|
||||||
|
| `v6.6.10.28` (latest 6.6 tag seen) | `"php": "~8.2.0 \|\| ~8.3.0 \|\| ~8.4.0 \|\| ~8.5.0"` |
|
||||||
|
|
||||||
|
- The `v6.6.10.28` root `composer.json` has the same line as core.
|
||||||
|
- A fetch of the `6.6.x` branch-head `composer.json` returned no usable content, so only the two tags above are verified.
|
||||||
|
- Official docs, `guides/hosting/index.md` ("Recommended stack and supported versions"): PHP minimum `8.2+`, recommended `8.4`.
|
||||||
|
- `guides/development/dev-environment.md`: "PHP Version | `8.2`, `8.3`, `8.4`, `8.5`".
|
||||||
|
- Fetching the rendered developer.shopware.com requirements page returned no PHP row. It defers to the hosting guide, which is the source above.
|
||||||
|
- The repo's own `CLAUDE.md` says PHP `^8.1`. That is stale for 6.6, since core requires 8.2+. It is outside this task's scope.
|
||||||
|
|
||||||
|
### 2.2 Is `php: ^8.2` right?
|
||||||
|
|
||||||
|
`composer.json` today:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"require": { "php": "^8.2", "shopware/core": "~6.6.0" }
|
||||||
|
```
|
||||||
|
|
||||||
|
- `^8.2` means `>=8.2.0 <9.0.0`. It is consistent with core's floor.
|
||||||
|
- It is wider than core's ceiling (`<8.6`). The plugin's PHP range is the intersection of its own constraint and core's. Because `shopware/core ~6.6.0` is also required, Composer resolves to core's tilde list anyway. The plugin constraint adds no extra restriction in practice.
|
||||||
|
- Copying core's `~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0` would only make sense if the plugin itself breaks on a specific PHP minor. That would also force a release every time Shopware adds a PHP minor.
|
||||||
|
- Practical conclusion: `^8.2` is fine and not too strict. `>=8.2` behaves the same in practice. The only real argument for changing it is wanting the plugin's PHP floor to stay visible in its own metadata, which `^8.2` already does.
|
||||||
|
|
||||||
|
### 2.3 What Shopware's skeletons recommend
|
||||||
|
|
||||||
|
- `guides/plugins/plugins/creating-plugins.md` (docs repo): the example plugin `composer.json` has only `"require": { "shopware/core": "~6.7.0" }`. There is no `php` key, and "Depending on other plugins" repeats the same shape.
|
||||||
|
- shopware-cli's scaffolding (`internal/extension/create.go`) does not set a `php` constraint; the only `"php"` hit in that package is a test fixture, `internal/extension/root_test.go:233`, with `">=8.1"`.
|
||||||
|
- So the official guidance is to constrain `shopware/core` and leave PHP to core. A plugin `php` constraint is optional. If you want one, mirroring the supported floor (`>=8.2` or `^8.2`) is reasonable.
|
||||||
|
- I did not find a `SwagPluginSkeleton` repo (fetching `shopware/SwagPluginSkeleton` returned 404).
|
||||||
|
|
||||||
|
## Could not verify
|
||||||
|
|
||||||
|
- That the Store's server-side processing matches what the CLI sends. The Store backend is not public.
|
||||||
|
- That `.config/shopware-extension.yml` pack excludes would keep or remove a `CHANGELOG_en-GB.md` in the zip.
|
||||||
|
- The exact ordering behaviour of `filepath.Glob` for the two `en-GB` files was inferred from Go's documented sorted results, not run.
|
||||||
|
- No source evidence of whether the Store accepts HTML headings; the CLI renders headings as `<span class="hN">` per a comment in `internal/markdown`.
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
# Spec: Shopware plugin guideline compliance (build/release pipeline)
|
||||||
|
|
||||||
|
Outcome of the Wayfinder map `.scratch/shopware-guideline-compliance/` (tickets 01-05; research evidence
|
||||||
|
on branches `research/shopware-guideline-checklist`, `research/shopware-cli-ci-behaviour`,
|
||||||
|
`research/gitea-28-pipeline-standards`). Target: **Store-ready** artifacts, published to Gitea only
|
||||||
|
(Gitea Release + Composer registry). Uploading to the Shopware Store is out of scope.
|
||||||
|
|
||||||
|
## 1. Principles
|
||||||
|
|
||||||
|
- Workflows are **plugin-agnostic**: no plugin name, package name, owner, repo or host is hard-coded;
|
||||||
|
all derive from `composer.json` and the `gitea` context. The same files must work unchanged for a
|
||||||
|
second plugin and be extractable to Gitea's shared-workflow repository later.
|
||||||
|
- One artifact: the `shopware-cli extension package` zip (prebuilt admin/storefront JS) is the Gitea
|
||||||
|
Release asset; the Composer registry gets the same content repacked root-level (the registry needs
|
||||||
|
`composer.json` at the zip root, see section 4).
|
||||||
|
- `shopware-cli` is intentionally **unpinned** (`latest`). Known tradeoff: a CLI release can turn PRs
|
||||||
|
red without a repo change; treat that as a signal to fix config.
|
||||||
|
- `RELEASE_TOKEN` is the only token (release, assets, registry publish, link). Workflows still declare
|
||||||
|
`permissions:`.
|
||||||
|
|
||||||
|
## 2. Plugin changes
|
||||||
|
|
||||||
|
| # | Change |
|
||||||
|
|---|--------|
|
||||||
|
| P1 | Commit `src/Resources/config/plugin.png` (256x256). Do not ship `plugin-transparent.png`. |
|
||||||
|
| P2 | Logging: monolog channel `aeon_dump_manager` (`Resources/config/packages/monolog.yaml`, `build()` in the plugin class loading `packages/*.yaml`); inject `monolog.logger.aeon_dump_manager` into `PurgeDumpsTaskHandler`, `DumpService`, `CreateDumpHandler`; log dump job start/finish/failure. |
|
||||||
|
| P3 | Migrate `services.xml` -> `services.yaml` and `routes.php` -> `routes.yaml`. No validation ignore for this. Update the "XML services" rule in `CLAUDE.md`. |
|
||||||
|
| P4 | `composer.json`: `php` -> `^8.2`. Verify Shopware 6.6's own PHP requirement. |
|
||||||
|
| P5 | Delete the empty lifecycle overrides in `AeonDumpManager`; keep `uninstall`. |
|
||||||
|
| P6 | `.config/shopware-extension.yml` for build excludes and validation settings (add ignores only for real, accepted findings). |
|
||||||
|
| P7 | Keep Keep-a-Changelog `CHANGELOG.md`; verify with a local `shopware-cli extension package --release` how the changelog is read. |
|
||||||
|
|
||||||
|
## 3. Pipeline
|
||||||
|
|
||||||
|
### PR workflows
|
||||||
|
|
||||||
|
Jobs (all required checks on `main`):
|
||||||
|
`plugin-checks.yml` (the former `pr-version-check.yml` was deleted; `version-changelog` is now a job in it):
|
||||||
|
|
||||||
|
0. `version-changelog` - version bump vs `main` and matching CHANGELOG heading.
|
||||||
|
|
||||||
|
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. `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.
|
||||||
|
|
||||||
|
### Release workflow (`.gitea/workflows/release.yml`)
|
||||||
|
|
||||||
|
On push to `main`, guarded against re-release by an existing tag:
|
||||||
|
`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 ->
|
||||||
|
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
|
||||||
|
before the tag exists, so a failed build leaves no orphan tag.
|
||||||
|
|
||||||
|
### Branch protection (one-time, manual)
|
||||||
|
|
||||||
|
`scripts/protect-main.sh` using `tea api PATCH repos/{owner}/{repo}/branch_protections/main` to set the
|
||||||
|
required status-check contexts (now `plugin-checks / version-changelog|package|phpunit (pull_request)`,
|
||||||
|
set on `main`). `tea branches protect` cannot set status checks. Not run by the pipeline.
|
||||||
|
|
||||||
|
## 4. Open items (status after the first pipeline run)
|
||||||
|
|
||||||
|
- Release POST creates a missing tag: **resolved** - the POST created the tag and release for v0.1.0 (release id 55).
|
||||||
|
- Meaning of HTTP 400 on the package-link endpoint: **open** (not evidenced yet).
|
||||||
|
- Whether bare `validate` runs PHPStan/ESLint; Node availability on the runner image: **open** (not evidenced; the zip validate passes in the `shopware-cli` image).
|
||||||
|
- Accepted size for `metadata.icon.size`; error-vs-warning rule list of validate: **resolved** - `validate` on the zip reports "No problems found", so the icon size is accepted.
|
||||||
|
- Whether `routes.php` is flagged by validate: **resolved** - not flagged ("No problems found"). `shopware-cli extension fix` correctness for the YAML migration: **open**.
|
||||||
|
- Exact status-check context names: **resolved** - final: `plugin-checks / version-changelog (pull_request)`, `plugin-checks / package (pull_request)`, `plugin-checks / phpunit (pull_request)`, set on `main`.
|
||||||
|
- **Finding:** the Composer registry rejected the `shopware-cli` zip with "composer.json file is missing"; Gitea needs `composer.json` at the zip root, while the `shopware-cli` zip nests everything in a top-level folder. Fix (implemented separately): repack the zip with the top-level folder stripped for the registry upload; the Release asset stays the `shopware-cli` zip.
|
||||||
|
|
||||||
|
## 5. Out of scope / later
|
||||||
|
|
||||||
|
Shopware Store upload; Gitea shared-workflow repository; phpunit lowest-version matrix; Store listing metadata.
|
||||||
Executable
+17
@@ -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/assets/"
|
||||||
|
check storefront src/Resources/app/storefront/src "Resources/app/storefront/dist/"
|
||||||
Executable
+16
@@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# One-time (re-runnable) setup: require the PR checks on `main` using the Gitea `tea` CLI.
|
||||||
|
# `tea branches protect` cannot set status-check contexts, hence `tea api`.
|
||||||
|
# Usage: scripts/protect-main.sh [owner/repo] (default: derived from the git remote)
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
REPO="${1:-$(git config --get remote.origin.url | sed -E 's#^.*[:/]([^/]+/[^/]+)$#\1#; s#\.git$##')}"
|
||||||
|
|
||||||
|
tea api -X PATCH "repos/${REPO}/branch_protections/main" -d '{
|
||||||
|
"enable_status_check": true,
|
||||||
|
"status_check_contexts": [
|
||||||
|
"plugin-checks / version-changelog (pull_request)",
|
||||||
|
"plugin-checks / package (pull_request)",
|
||||||
|
"plugin-checks / phpunit (pull_request)"
|
||||||
|
]
|
||||||
|
}'
|
||||||
+22
-31
@@ -4,17 +4,33 @@ namespace AeonDumpManager;
|
|||||||
|
|
||||||
use Doctrine\DBAL\Connection;
|
use Doctrine\DBAL\Connection;
|
||||||
use Shopware\Core\Framework\Plugin;
|
use Shopware\Core\Framework\Plugin;
|
||||||
use Shopware\Core\Framework\Plugin\Context\ActivateContext;
|
|
||||||
use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
|
|
||||||
use Shopware\Core\Framework\Plugin\Context\InstallContext;
|
|
||||||
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
|
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
|
||||||
use Shopware\Core\Framework\Plugin\Context\UpdateContext;
|
use Symfony\Component\Config\FileLocator;
|
||||||
|
use Symfony\Component\Config\Loader\DelegatingLoader;
|
||||||
|
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
use Symfony\Component\DependencyInjection\Loader\DirectoryLoader;
|
||||||
|
use Symfony\Component\DependencyInjection\Loader\GlobFileLoader;
|
||||||
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||||
|
|
||||||
class AeonDumpManager extends Plugin
|
class AeonDumpManager extends Plugin
|
||||||
{
|
{
|
||||||
public function install(InstallContext $installContext): void
|
public function build(ContainerBuilder $container): void
|
||||||
{
|
{
|
||||||
// Do stuff such as creating a new payment method
|
parent::build($container);
|
||||||
|
|
||||||
|
// Registers the dedicated monolog channel (Resources/config/packages/monolog.yaml)
|
||||||
|
$locator = new FileLocator('Resources/config');
|
||||||
|
$resolver = new LoaderResolver([
|
||||||
|
new YamlFileLoader($container, $locator),
|
||||||
|
new GlobFileLoader($container, $locator),
|
||||||
|
new DirectoryLoader($container, $locator),
|
||||||
|
]);
|
||||||
|
|
||||||
|
(new DelegatingLoader($resolver))->load(
|
||||||
|
\rtrim($this->getPath(), '/') . '/Resources/config/packages/*.yaml',
|
||||||
|
'glob'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function uninstall(UninstallContext $uninstallContext): void
|
public function uninstall(UninstallContext $uninstallContext): void
|
||||||
@@ -29,29 +45,4 @@ class AeonDumpManager extends Plugin
|
|||||||
$connection = $this->container->get(Connection::class);
|
$connection = $this->container->get(Connection::class);
|
||||||
$connection->executeStatement('DROP TABLE IF EXISTS `aeon_dump_manager_job`');
|
$connection->executeStatement('DROP TABLE IF EXISTS `aeon_dump_manager_job`');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function activate(ActivateContext $activateContext): void
|
|
||||||
{
|
|
||||||
// Activate entities, such as a new payment method
|
|
||||||
// Or create new entities here, because now your plugin is installed and active for sure
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deactivate(DeactivateContext $deactivateContext): void
|
|
||||||
{
|
|
||||||
// Deactivate entities, such as a new payment method
|
|
||||||
// Or remove previously created entities
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update(UpdateContext $updateContext): void
|
|
||||||
{
|
|
||||||
// Update necessary stuff, mostly non-database related
|
|
||||||
}
|
|
||||||
|
|
||||||
public function postInstall(InstallContext $installContext): void
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function postUpdate(UpdateContext $updateContext): void
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@ namespace AeonDumpManager\MessageQueue\Handler;
|
|||||||
use AeonDumpManager\MessageQueue\Message\CreateDumpMessage;
|
use AeonDumpManager\MessageQueue\Message\CreateDumpMessage;
|
||||||
use AeonDumpManager\Service\DumpJobStatusService;
|
use AeonDumpManager\Service\DumpJobStatusService;
|
||||||
use AeonDumpManager\Service\DumpService;
|
use AeonDumpManager\Service\DumpService;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
|
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
|
||||||
|
|
||||||
#[AsMessageHandler]
|
#[AsMessageHandler]
|
||||||
@@ -13,6 +14,7 @@ class CreateDumpHandler
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly DumpService $dumpService,
|
private readonly DumpService $dumpService,
|
||||||
private readonly DumpJobStatusService $jobStatus,
|
private readonly DumpJobStatusService $jobStatus,
|
||||||
|
private readonly LoggerInterface $logger,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,10 +22,12 @@ class CreateDumpHandler
|
|||||||
{
|
{
|
||||||
$jobId = $message->getJobId();
|
$jobId = $message->getJobId();
|
||||||
$this->jobStatus->markRunning($jobId);
|
$this->jobStatus->markRunning($jobId);
|
||||||
|
$this->logger->info('Dump job started.', ['jobId' => $jobId]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->dumpService->createAsync($jobId, $this->jobStatus);
|
$this->dumpService->createAsync($jobId, $this->jobStatus);
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
|
$this->logger->error('Dump job failed.', ['jobId' => $jobId, 'exception' => $exception]);
|
||||||
$this->jobStatus->markFailed($jobId, $exception->getMessage());
|
$this->jobStatus->markFailed($jobId, $exception->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import './acl';
|
import './acl';
|
||||||
import './page/aeon-dump-manager-list';
|
|
||||||
import deDE from './snippet/de-DE.json';
|
import deDE from './snippet/de-DE.json';
|
||||||
import enGB from './snippet/en-GB.json';
|
import enGB from './snippet/en-GB.json';
|
||||||
|
|
||||||
|
// Lazy (async) registration, as core does: the page chunk loads on first visit.
|
||||||
|
Shopware.Component.register('aeon-dump-manager-list', () => import('./page/aeon-dump-manager-list'));
|
||||||
|
|
||||||
Shopware.Module.register('aeon-dump-manager', {
|
Shopware.Module.register('aeon-dump-manager', {
|
||||||
type: 'plugin',
|
type: 'plugin',
|
||||||
name: 'DumpManager',
|
name: 'DumpManager',
|
||||||
@@ -27,27 +29,10 @@ Shopware.Module.register('aeon-dump-manager', {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
// Per https://developer.shopware.com/docs/v6.6/guides/plugins/plugins/administration/routing-navigation/add-menu-entry.html —
|
settingsItem: [{
|
||||||
// plugins can't register a first-level main-menu entry, so this nests
|
group: 'plugins',
|
||||||
// under the core 'sw-settings' navigation node. Clicking Settings in the
|
|
||||||
// main sidebar shows this as a sub-item, landing at #/sw/settings/.
|
|
||||||
navigation: [{
|
|
||||||
id: 'aeon-dump-manager-list',
|
|
||||||
label: 'aeon-dump-manager.general.mainMenuItemGeneral',
|
|
||||||
color: '#ff3d58',
|
|
||||||
path: 'aeon.dump.manager.list',
|
|
||||||
icon: 'regular-database',
|
|
||||||
parent: 'sw-settings',
|
|
||||||
position: 100,
|
|
||||||
privilege: 'aeon_dump_manager.viewer',
|
|
||||||
}],
|
|
||||||
|
|
||||||
// Also shown as a card on the Settings overview page's "System" group,
|
|
||||||
// next to Plugins/Cache — complements the navigation entry above.
|
|
||||||
settingsItem: {
|
|
||||||
group: 'system',
|
|
||||||
to: 'aeon.dump.manager.list',
|
to: 'aeon.dump.manager.list',
|
||||||
icon: 'regular-database',
|
icon: 'regular-database',
|
||||||
privilege: 'aeon_dump_manager.viewer',
|
privilege: 'aeon_dump_manager.viewer',
|
||||||
},
|
}],
|
||||||
});
|
});
|
||||||
+47
-46
@@ -1,7 +1,7 @@
|
|||||||
{% block aeon_dump_manager_list %}
|
{% block aeon_dump_manager_list %}
|
||||||
<sw-page class="aeon-dump-manager-list">
|
<sw-page class="aeon-dump-manager-list">
|
||||||
<template #smart-bar-actions>
|
<template #smart-bar-actions>
|
||||||
<sw-button
|
<mt-button
|
||||||
v-if="acl.can('aeon_dump_manager.creator')"
|
v-if="acl.can('aeon_dump_manager.creator')"
|
||||||
variant="primary"
|
variant="primary"
|
||||||
:is-loading="pendingJob !== null"
|
:is-loading="pendingJob !== null"
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
@click="onCreate"
|
@click="onCreate"
|
||||||
>
|
>
|
||||||
{{ $tc('aeon-dump-manager.list.buttonCreate') }}
|
{{ $tc('aeon-dump-manager.list.buttonCreate') }}
|
||||||
</sw-button>
|
</mt-button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #content>
|
<template #content>
|
||||||
@@ -75,50 +75,51 @@
|
|||||||
</template>
|
</template>
|
||||||
</sw-data-grid>
|
</sw-data-grid>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- sw-page has no default slot (Vue 3 drops unslotted content): modals must live in #content. -->
|
||||||
|
{% block aeon_dump_manager_list_progress_modal %}
|
||||||
|
<sw-modal
|
||||||
|
v-if="pendingJob !== null"
|
||||||
|
:title="$tc('aeon-dump-manager.list.progressTitle')"
|
||||||
|
variant="small"
|
||||||
|
class="aeon-dump-manager-list__progress-modal"
|
||||||
|
@modal-close="onCloseProgressModal"
|
||||||
|
>
|
||||||
|
<div class="aeon-dump-manager-list__progress-wrapper">
|
||||||
|
<template v-if="pendingJob.status === 'done'">
|
||||||
|
<mt-banner variant="positive">
|
||||||
|
{{ $tc('aeon-dump-manager.list.createSuccess') }}
|
||||||
|
</mt-banner>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="pendingJob.status === 'failed'">
|
||||||
|
<mt-banner variant="critical">
|
||||||
|
{{ $tc('aeon-dump-manager.list.createFailed', 0, { error: pendingJob.errorMessage || '' }) }}
|
||||||
|
</mt-banner>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<mt-progress-bar
|
||||||
|
:model-value="pendingJob.percent || 0"
|
||||||
|
:max-value="100"
|
||||||
|
/>
|
||||||
|
<span class="aeon-dump-manager-list__progress-text">
|
||||||
|
{{ $tc('aeon-dump-manager.list.progressText') }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</sw-modal>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
<sw-confirm-modal
|
||||||
|
v-if="deleteFilenames !== null"
|
||||||
|
:title="$tc('aeon-dump-manager.list.confirmDeleteTitle')"
|
||||||
|
:text="deleteFilenames.length > 1
|
||||||
|
? $tc('aeon-dump-manager.list.confirmDeleteTextMultiple', 0, { count: deleteFilenames.length })
|
||||||
|
: $tc('aeon-dump-manager.list.confirmDeleteText', 0, { filename: deleteFilenames[0] })"
|
||||||
|
type="delete"
|
||||||
|
@confirm="onConfirmDelete"
|
||||||
|
@cancel="onCancelDelete"
|
||||||
|
@close="onCancelDelete"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
{% block aeon_dump_manager_list_progress_modal %}
|
|
||||||
<sw-modal
|
|
||||||
v-if="pendingJob !== null"
|
|
||||||
:title="$tc('aeon-dump-manager.list.progressTitle')"
|
|
||||||
variant="small"
|
|
||||||
class="aeon-dump-manager-list__progress-modal"
|
|
||||||
@modal-close="onCloseProgressModal"
|
|
||||||
>
|
|
||||||
<div class="aeon-dump-manager-list__progress-wrapper">
|
|
||||||
<template v-if="pendingJob.status === 'done'">
|
|
||||||
<sw-alert variant="success">
|
|
||||||
{{ $tc('aeon-dump-manager.list.createSuccess') }}
|
|
||||||
</sw-alert>
|
|
||||||
</template>
|
|
||||||
<template v-else-if="pendingJob.status === 'failed'">
|
|
||||||
<sw-alert variant="error">
|
|
||||||
{{ $tc('aeon-dump-manager.list.createFailed', 0, { error: pendingJob.errorMessage || '' }) }}
|
|
||||||
</sw-alert>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<sw-progress-bar
|
|
||||||
:value="pendingJob.percent || 0"
|
|
||||||
:max-value="100"
|
|
||||||
/>
|
|
||||||
<span class="aeon-dump-manager-list__progress-text">
|
|
||||||
{{ $tc('aeon-dump-manager.list.progressText') }}
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
</sw-modal>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
<sw-confirm-modal
|
|
||||||
v-if="deleteFilenames !== null"
|
|
||||||
:title="$tc('aeon-dump-manager.list.confirmDeleteTitle')"
|
|
||||||
:text="deleteFilenames.length > 1
|
|
||||||
? $tc('aeon-dump-manager.list.confirmDeleteTextMultiple', 0, { count: deleteFilenames.length })
|
|
||||||
: $tc('aeon-dump-manager.list.confirmDeleteText', 0, { filename: deleteFilenames[0] })"
|
|
||||||
type="delete"
|
|
||||||
@confirm="onConfirmDelete"
|
|
||||||
@cancel="onCancelDelete"
|
|
||||||
@close="onCancelDelete"
|
|
||||||
/>
|
|
||||||
</sw-page>
|
</sw-page>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
+5
-4
@@ -1,7 +1,8 @@
|
|||||||
import template from './aeon-dump-manager-list.html.twig';
|
import template from './aeon-dump-manager-list.html.twig';
|
||||||
import type DumpApiService, { DumpFile, DumpJob } from '../../../../service/dump-api.service';
|
import type DumpApiService from '../../../../service/dump-api.service';
|
||||||
|
import type { DumpFile, DumpJob } from '../../../../service/dump-api.service';
|
||||||
|
|
||||||
const { Component, Mixin } = Shopware;
|
const { Mixin } = Shopware;
|
||||||
|
|
||||||
interface PendingJob {
|
interface PendingJob {
|
||||||
status: string;
|
status: string;
|
||||||
@@ -45,7 +46,7 @@ interface ComponentInstance extends ComponentData {
|
|||||||
listFilters: Record<string, unknown>[];
|
listFilters: Record<string, unknown>[];
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.register('aeon-dump-manager-list', {
|
export default Shopware.Component.wrapComponentConfig({
|
||||||
template,
|
template,
|
||||||
|
|
||||||
mixins: [
|
mixins: [
|
||||||
@@ -147,7 +148,7 @@ Component.register('aeon-dump-manager-list', {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeDestroy(this: ComponentInstance) {
|
beforeUnmount(this: ComponentInstance) {
|
||||||
this.stopPolling();
|
this.stopPolling();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
monolog:
|
||||||
|
channels: ['aeon_dump_manager']
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 53 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -1,7 +0,0 @@
|
|||||||
<?php declare(strict_types=1);
|
|
||||||
|
|
||||||
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
|
|
||||||
|
|
||||||
return function (RoutingConfigurator $routes): void {
|
|
||||||
$routes->import(__DIR__ . '/../../Controller/*Controller.php', 'attribute');
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
aeon_dump_manager_controllers:
|
||||||
|
resource: ../../Controller/*Controller.php
|
||||||
|
type: attribute
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
<?xml version="1.0" ?>
|
|
||||||
|
|
||||||
<container xmlns="http://symfony.com/schema/dic/services"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
|
||||||
|
|
||||||
<services>
|
|
||||||
<!-- Services -->
|
|
||||||
|
|
||||||
<service id="Symfony\Component\Process\ExecutableFinder"/>
|
|
||||||
|
|
||||||
<service id="aeon_dump_manager.dump_filename_parser" class="AeonDumpManager\Service\DumpFilenameParser"/>
|
|
||||||
|
|
||||||
<service id="aeon_dump_manager.dump_binary_locator" class="AeonDumpManager\Service\DumpBinaryLocator">
|
|
||||||
<argument type="service" id="Doctrine\DBAL\Connection"/>
|
|
||||||
<argument type="service" id="Shopware\Core\System\SystemConfig\SystemConfigService"/>
|
|
||||||
<argument type="service" id="Symfony\Component\Process\ExecutableFinder"/>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<service id="aeon_dump_manager.dump_job_status_service" class="AeonDumpManager\Service\DumpJobStatusService">
|
|
||||||
<argument type="service" id="Doctrine\DBAL\Connection"/>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<service id="aeon_dump_manager.dump_lister" class="AeonDumpManager\Service\DumpLister">
|
|
||||||
<argument type="service" id="aeon_dump_manager.filesystem.private"/>
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_filename_parser"/>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<service id="aeon_dump_manager.dump_service" class="AeonDumpManager\Service\DumpService">
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_lister"/>
|
|
||||||
<argument type="service" id="aeon_dump_manager.filesystem.private"/>
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_binary_locator"/>
|
|
||||||
<argument type="service" id="Doctrine\DBAL\Connection"/>
|
|
||||||
<argument type="service" id="Shopware\Core\System\SystemConfig\SystemConfigService"/>
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_filename_parser"/>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<!-- Async create job -->
|
|
||||||
|
|
||||||
<service id="aeon_dump_manager.message_queue.create_dump_handler" class="AeonDumpManager\MessageQueue\Handler\CreateDumpHandler">
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_service"/>
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_job_status_service"/>
|
|
||||||
<tag name="messenger.message_handler"/>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<!-- Retention -->
|
|
||||||
|
|
||||||
<service id="aeon_dump_manager.scheduled_task.purge_dumps_task" class="AeonDumpManager\ScheduledTask\PurgeDumpsTask">
|
|
||||||
<tag name="shopware.scheduled.task"/>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<service id="aeon_dump_manager.scheduled_task.purge_dumps_task_handler" class="AeonDumpManager\ScheduledTask\PurgeDumpsTaskHandler">
|
|
||||||
<argument type="service" id="scheduled_task.repository"/>
|
|
||||||
<argument type="service" id="logger"/>
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_service"/>
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_job_status_service"/>
|
|
||||||
<argument type="service" id="Shopware\Core\System\SystemConfig\SystemConfigService"/>
|
|
||||||
<tag name="messenger.message_handler" handles="AeonDumpManager\ScheduledTask\PurgeDumpsTask"/>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<!-- Console commands -->
|
|
||||||
|
|
||||||
<service id="aeon_dump_manager.command.dump_list" class="AeonDumpManager\Command\DumpListCommand">
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_lister"/>
|
|
||||||
<tag name="console.command"/>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<service id="aeon_dump_manager.command.dump_create" class="AeonDumpManager\Command\DumpCreateCommand">
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_service"/>
|
|
||||||
<tag name="console.command"/>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<service id="aeon_dump_manager.command.dump_remove" class="AeonDumpManager\Command\DumpRemoveCommand">
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_service"/>
|
|
||||||
<tag name="console.command"/>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<!-- Admin API controller -->
|
|
||||||
|
|
||||||
<service id="AeonDumpManager\Controller\DumpController" public="true">
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_lister"/>
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_service"/>
|
|
||||||
<argument type="service" id="aeon_dump_manager.dump_job_status_service"/>
|
|
||||||
<argument type="service" id="messenger.default_bus"/>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
</services>
|
|
||||||
</container>
|
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
services:
|
||||||
|
Symfony\Component\Process\ExecutableFinder: ~
|
||||||
|
|
||||||
|
aeon_dump_manager.dump_filename_parser:
|
||||||
|
class: AeonDumpManager\Service\DumpFilenameParser
|
||||||
|
|
||||||
|
aeon_dump_manager.dump_binary_locator:
|
||||||
|
class: AeonDumpManager\Service\DumpBinaryLocator
|
||||||
|
arguments:
|
||||||
|
- '@Doctrine\DBAL\Connection'
|
||||||
|
- '@Shopware\Core\System\SystemConfig\SystemConfigService'
|
||||||
|
- '@Symfony\Component\Process\ExecutableFinder'
|
||||||
|
|
||||||
|
aeon_dump_manager.dump_job_status_service:
|
||||||
|
class: AeonDumpManager\Service\DumpJobStatusService
|
||||||
|
arguments:
|
||||||
|
- '@Doctrine\DBAL\Connection'
|
||||||
|
|
||||||
|
aeon_dump_manager.dump_lister:
|
||||||
|
class: AeonDumpManager\Service\DumpLister
|
||||||
|
arguments:
|
||||||
|
- '@aeon_dump_manager.filesystem.private'
|
||||||
|
- '@aeon_dump_manager.dump_filename_parser'
|
||||||
|
|
||||||
|
aeon_dump_manager.dump_service:
|
||||||
|
class: AeonDumpManager\Service\DumpService
|
||||||
|
arguments:
|
||||||
|
- '@aeon_dump_manager.dump_lister'
|
||||||
|
- '@aeon_dump_manager.filesystem.private'
|
||||||
|
- '@aeon_dump_manager.dump_binary_locator'
|
||||||
|
- '@Doctrine\DBAL\Connection'
|
||||||
|
- '@Shopware\Core\System\SystemConfig\SystemConfigService'
|
||||||
|
- '@aeon_dump_manager.dump_filename_parser'
|
||||||
|
- '@monolog.logger.aeon_dump_manager'
|
||||||
|
|
||||||
|
# Async create job
|
||||||
|
aeon_dump_manager.message_queue.create_dump_handler:
|
||||||
|
class: AeonDumpManager\MessageQueue\Handler\CreateDumpHandler
|
||||||
|
arguments:
|
||||||
|
- '@aeon_dump_manager.dump_service'
|
||||||
|
- '@aeon_dump_manager.dump_job_status_service'
|
||||||
|
- '@monolog.logger.aeon_dump_manager'
|
||||||
|
tags:
|
||||||
|
- { name: messenger.message_handler }
|
||||||
|
|
||||||
|
# Retention
|
||||||
|
aeon_dump_manager.scheduled_task.purge_dumps_task:
|
||||||
|
class: AeonDumpManager\ScheduledTask\PurgeDumpsTask
|
||||||
|
tags:
|
||||||
|
- { name: shopware.scheduled.task }
|
||||||
|
|
||||||
|
aeon_dump_manager.scheduled_task.purge_dumps_task_handler:
|
||||||
|
class: AeonDumpManager\ScheduledTask\PurgeDumpsTaskHandler
|
||||||
|
arguments:
|
||||||
|
- '@scheduled_task.repository'
|
||||||
|
- '@monolog.logger.aeon_dump_manager'
|
||||||
|
- '@aeon_dump_manager.dump_service'
|
||||||
|
- '@aeon_dump_manager.dump_job_status_service'
|
||||||
|
- '@Shopware\Core\System\SystemConfig\SystemConfigService'
|
||||||
|
tags:
|
||||||
|
- { name: messenger.message_handler, handles: AeonDumpManager\ScheduledTask\PurgeDumpsTask }
|
||||||
|
|
||||||
|
# Console commands
|
||||||
|
aeon_dump_manager.command.dump_list:
|
||||||
|
class: AeonDumpManager\Command\DumpListCommand
|
||||||
|
arguments:
|
||||||
|
- '@aeon_dump_manager.dump_lister'
|
||||||
|
tags:
|
||||||
|
- { name: console.command }
|
||||||
|
|
||||||
|
aeon_dump_manager.command.dump_create:
|
||||||
|
class: AeonDumpManager\Command\DumpCreateCommand
|
||||||
|
arguments:
|
||||||
|
- '@aeon_dump_manager.dump_service'
|
||||||
|
tags:
|
||||||
|
- { name: console.command }
|
||||||
|
|
||||||
|
aeon_dump_manager.command.dump_remove:
|
||||||
|
class: AeonDumpManager\Command\DumpRemoveCommand
|
||||||
|
arguments:
|
||||||
|
- '@aeon_dump_manager.dump_service'
|
||||||
|
tags:
|
||||||
|
- { name: console.command }
|
||||||
|
|
||||||
|
# Admin API controller
|
||||||
|
AeonDumpManager\Controller\DumpController:
|
||||||
|
public: true
|
||||||
|
arguments:
|
||||||
|
- '@aeon_dump_manager.dump_lister'
|
||||||
|
- '@aeon_dump_manager.dump_service'
|
||||||
|
- '@aeon_dump_manager.dump_job_status_service'
|
||||||
|
- '@messenger.default_bus'
|
||||||
@@ -6,6 +6,7 @@ use AeonDumpManager\Service\Exception\DumpBinaryNotFoundException;
|
|||||||
use Doctrine\DBAL\Connection;
|
use Doctrine\DBAL\Connection;
|
||||||
use Shopware\Core\System\SystemConfig\SystemConfigService;
|
use Shopware\Core\System\SystemConfig\SystemConfigService;
|
||||||
use Symfony\Component\Process\ExecutableFinder;
|
use Symfony\Component\Process\ExecutableFinder;
|
||||||
|
use Symfony\Component\Process\Process;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Picks mariadb-dump/mysqldump depending on what the configured DB connection
|
* Picks mariadb-dump/mysqldump depending on what the configured DB connection
|
||||||
@@ -38,6 +39,19 @@ class DumpBinaryLocator
|
|||||||
throw DumpBinaryNotFoundException::create($binaryNames);
|
throw DumpBinaryNotFoundException::create($binaryNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<string> client-specific flags for the located binary
|
||||||
|
*/
|
||||||
|
public function extraArguments(string $binary): array
|
||||||
|
{
|
||||||
|
$version = new Process([$binary, '--version']);
|
||||||
|
$version->run();
|
||||||
|
|
||||||
|
return MySqlVariant::needsColumnStatisticsOff($version->getOutput(), $this->isMariaDb())
|
||||||
|
? ['--column-statistics=0']
|
||||||
|
: [];
|
||||||
|
}
|
||||||
|
|
||||||
private function isMariaDb(): bool
|
private function isMariaDb(): bool
|
||||||
{
|
{
|
||||||
// Connection::getServerVersion() is private in the DBAL version this
|
// Connection::getServerVersion() is private in the DBAL version this
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use AeonDumpManager\Service\Exception\DumpNotFoundException;
|
|||||||
use AeonDumpManager\Struct\DumpFile;
|
use AeonDumpManager\Struct\DumpFile;
|
||||||
use Doctrine\DBAL\Connection;
|
use Doctrine\DBAL\Connection;
|
||||||
use League\Flysystem\FilesystemOperator;
|
use League\Flysystem\FilesystemOperator;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
use Shopware\Core\System\SystemConfig\SystemConfigService;
|
use Shopware\Core\System\SystemConfig\SystemConfigService;
|
||||||
use Symfony\Component\Process\Exception\ProcessFailedException;
|
use Symfony\Component\Process\Exception\ProcessFailedException;
|
||||||
use Symfony\Component\Process\Process;
|
use Symfony\Component\Process\Process;
|
||||||
@@ -24,6 +25,7 @@ class DumpService
|
|||||||
private readonly Connection $connection,
|
private readonly Connection $connection,
|
||||||
private readonly SystemConfigService $systemConfigService,
|
private readonly SystemConfigService $systemConfigService,
|
||||||
private readonly DumpFilenameParser $filenameParser,
|
private readonly DumpFilenameParser $filenameParser,
|
||||||
|
private readonly LoggerInterface $logger,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,6 +71,7 @@ class DumpService
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->aeonDumpManagerFilesystemPrivate->delete($path);
|
$this->aeonDumpManagerFilesystemPrivate->delete($path);
|
||||||
|
$this->logger->info('Dump deleted.', ['filename' => $filename]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,6 +103,7 @@ class DumpService
|
|||||||
|
|
||||||
foreach ($excess as $dumpFile) {
|
foreach ($excess as $dumpFile) {
|
||||||
$this->aeonDumpManagerFilesystemPrivate->delete(DumpLister::path($dumpFile->filename));
|
$this->aeonDumpManagerFilesystemPrivate->delete(DumpLister::path($dumpFile->filename));
|
||||||
|
$this->logger->info('Dump removed: maxDumps exceeded.', ['filename' => $dumpFile->filename]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,6 +112,7 @@ class DumpService
|
|||||||
foreach ($this->dumpLister->list() as $dumpFile) {
|
foreach ($this->dumpLister->list() as $dumpFile) {
|
||||||
if ($dumpFile->datetime < $threshold) {
|
if ($dumpFile->datetime < $threshold) {
|
||||||
$this->aeonDumpManagerFilesystemPrivate->delete(DumpLister::path($dumpFile->filename));
|
$this->aeonDumpManagerFilesystemPrivate->delete(DumpLister::path($dumpFile->filename));
|
||||||
|
$this->logger->info('Dump removed: older than retention.', ['filename' => $dumpFile->filename]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,6 +148,7 @@ class DumpService
|
|||||||
|
|
||||||
if (!$process->isSuccessful()) {
|
if (!$process->isSuccessful()) {
|
||||||
@unlink($tempPath);
|
@unlink($tempPath);
|
||||||
|
$this->logger->error('Dump process failed.', ['exitCode' => $process->getExitCode()]);
|
||||||
|
|
||||||
throw new ProcessFailedException($process);
|
throw new ProcessFailedException($process);
|
||||||
}
|
}
|
||||||
@@ -153,6 +159,8 @@ class DumpService
|
|||||||
fclose($stream);
|
fclose($stream);
|
||||||
@unlink($tempPath);
|
@unlink($tempPath);
|
||||||
|
|
||||||
|
$this->logger->info('Dump created.', ['filename' => $filename, 'sizeBytes' => $sizeBytes]);
|
||||||
|
|
||||||
return new DumpFile($filename, $dateTime, $sizeBytes);
|
return new DumpFile($filename, $dateTime, $sizeBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,6 +173,7 @@ class DumpService
|
|||||||
$binary,
|
$binary,
|
||||||
'--single-transaction',
|
'--single-transaction',
|
||||||
'--quick',
|
'--quick',
|
||||||
|
...$this->dumpBinaryLocator->extraArguments($binary),
|
||||||
'-h', (string) ($params['host'] ?? '127.0.0.1'),
|
'-h', (string) ($params['host'] ?? '127.0.0.1'),
|
||||||
'-P', (string) ($params['port'] ?? 3306),
|
'-P', (string) ($params['port'] ?? 3306),
|
||||||
'-u', (string) ($params['user'] ?? 'root'),
|
'-u', (string) ($params['user'] ?? 'root'),
|
||||||
|
|||||||
@@ -14,4 +14,18 @@ class MySqlVariant
|
|||||||
{
|
{
|
||||||
return stripos($serverVersion, 'mariadb') !== false;
|
return stripos($serverVersion, 'mariadb') !== false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MySQL 8+ mysqldump queries information_schema.COLUMN_STATISTICS, which
|
||||||
|
* MariaDB lacks (error 1109); --column-statistics=0 skips it. MariaDB's own
|
||||||
|
* client (version string contains "MariaDB") and MySQL < 8 don't know the flag.
|
||||||
|
*/
|
||||||
|
public static function needsColumnStatisticsOff(string $clientVersion, bool $serverIsMariaDb): bool
|
||||||
|
{
|
||||||
|
return $serverIsMariaDb
|
||||||
|
&& !self::isMariaDb($clientVersion)
|
||||||
|
// MySQL < 8 prints "Ver 10.13 Distrib 5.7.x": the Distrib number is the real version.
|
||||||
|
&& (preg_match('/Distrib (\d+)\./', $clientVersion, $m) === 1 || preg_match('/\bVer (\d+)\./', $clientVersion, $m) === 1)
|
||||||
|
&& (int) $m[1] >= 8;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace AeonDumpManager\Tests\MessageQueue\Handler;
|
||||||
|
|
||||||
|
use AeonDumpManager\MessageQueue\Handler\CreateDumpHandler;
|
||||||
|
use AeonDumpManager\MessageQueue\Message\CreateDumpMessage;
|
||||||
|
use AeonDumpManager\Service\DumpJobStatusService;
|
||||||
|
use AeonDumpManager\Service\DumpService;
|
||||||
|
use AeonDumpManager\Tests\Support\RecordingLogger;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class CreateDumpHandlerTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testLogsStartOnSuccess(): void
|
||||||
|
{
|
||||||
|
$status = $this->createMock(DumpJobStatusService::class);
|
||||||
|
$status->expects(self::once())->method('markRunning')->with('job-1');
|
||||||
|
$status->expects(self::never())->method('markFailed');
|
||||||
|
$logger = new RecordingLogger();
|
||||||
|
|
||||||
|
(new CreateDumpHandler($this->createMock(DumpService::class), $status, $logger))(new CreateDumpMessage('job-1'));
|
||||||
|
|
||||||
|
self::assertCount(1, $logger->records);
|
||||||
|
self::assertSame('info', $logger->records[0]['level']);
|
||||||
|
self::assertSame('Dump job started.', $logger->records[0]['message']);
|
||||||
|
self::assertSame(['jobId' => 'job-1'], $logger->records[0]['context']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testLogsErrorAndMarksFailedWhenCreateThrows(): void
|
||||||
|
{
|
||||||
|
$exception = new \RuntimeException('boom');
|
||||||
|
$service = $this->createMock(DumpService::class);
|
||||||
|
$service->method('createAsync')->willThrowException($exception);
|
||||||
|
$status = $this->createMock(DumpJobStatusService::class);
|
||||||
|
$status->expects(self::once())->method('markFailed')->with('job-2', 'boom');
|
||||||
|
$logger = new RecordingLogger();
|
||||||
|
|
||||||
|
(new CreateDumpHandler($service, $status, $logger))(new CreateDumpMessage('job-2'));
|
||||||
|
|
||||||
|
self::assertCount(2, $logger->records);
|
||||||
|
self::assertSame('error', $logger->records[1]['level']);
|
||||||
|
self::assertSame('Dump job failed.', $logger->records[1]['message']);
|
||||||
|
self::assertSame('job-2', $logger->records[1]['context']['jobId']);
|
||||||
|
self::assertSame($exception, $logger->records[1]['context']['exception']);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace AeonDumpManager\Tests\Service;
|
||||||
|
|
||||||
|
use AeonDumpManager\Service\DumpBinaryLocator;
|
||||||
|
use AeonDumpManager\Service\DumpFilenameParser;
|
||||||
|
use AeonDumpManager\Service\DumpLister;
|
||||||
|
use AeonDumpManager\Service\DumpService;
|
||||||
|
use AeonDumpManager\Service\Exception\DumpNotFoundException;
|
||||||
|
use AeonDumpManager\Tests\Support\RecordingLogger;
|
||||||
|
use Doctrine\DBAL\Connection;
|
||||||
|
use League\Flysystem\FilesystemOperator;
|
||||||
|
use PHPUnit\Framework\MockObject\MockObject;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Shopware\Core\System\SystemConfig\SystemConfigService;
|
||||||
|
|
||||||
|
class DumpServiceLoggingTest extends TestCase
|
||||||
|
{
|
||||||
|
private const FILENAME = 'dump_2026-09-14_15-04-05.sql.gz';
|
||||||
|
|
||||||
|
private FilesystemOperator&MockObject $filesystem;
|
||||||
|
|
||||||
|
private RecordingLogger $logger;
|
||||||
|
|
||||||
|
private DumpService $service;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
$this->filesystem = $this->createMock(FilesystemOperator::class);
|
||||||
|
$this->logger = new RecordingLogger();
|
||||||
|
$this->service = new DumpService(
|
||||||
|
$this->createMock(DumpLister::class),
|
||||||
|
$this->filesystem,
|
||||||
|
$this->createMock(DumpBinaryLocator::class),
|
||||||
|
$this->createMock(Connection::class),
|
||||||
|
$this->createMock(SystemConfigService::class),
|
||||||
|
new DumpFilenameParser(),
|
||||||
|
$this->logger,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDeleteLogsInfo(): void
|
||||||
|
{
|
||||||
|
$this->filesystem->method('fileExists')->willReturn(true);
|
||||||
|
$this->filesystem->expects(self::once())->method('delete')->with(DumpLister::path(self::FILENAME));
|
||||||
|
|
||||||
|
$this->service->delete(self::FILENAME);
|
||||||
|
|
||||||
|
self::assertSame(
|
||||||
|
[['level' => 'info', 'message' => 'Dump deleted.', 'context' => ['filename' => self::FILENAME]]],
|
||||||
|
$this->logger->records
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDeleteMissingDumpDoesNotLog(): void
|
||||||
|
{
|
||||||
|
$this->filesystem->method('fileExists')->willReturn(false);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->service->delete(self::FILENAME);
|
||||||
|
self::fail('Expected DumpNotFoundException.');
|
||||||
|
} catch (DumpNotFoundException) {
|
||||||
|
self::assertSame([], $this->logger->records);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,4 +21,20 @@ class MySqlVariantTest extends TestCase
|
|||||||
yield 'mariadb without legacy prefix' => ['10.11.2-MariaDB', true];
|
yield 'mariadb without legacy prefix' => ['10.11.2-MariaDB', true];
|
||||||
yield 'mariadb lowercase' => ['10.11.2-mariadb', true];
|
yield 'mariadb lowercase' => ['10.11.2-mariadb', true];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[DataProvider('columnStatisticsProvider')]
|
||||||
|
public function testNeedsColumnStatisticsOff(string $clientVersion, bool $serverIsMariaDb, bool $expected): void
|
||||||
|
{
|
||||||
|
self::assertSame($expected, MySqlVariant::needsColumnStatisticsOff($clientVersion, $serverIsMariaDb));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function columnStatisticsProvider(): iterable
|
||||||
|
{
|
||||||
|
$mysql8 = 'mysqldump Ver 8.0.46-0ubuntu0.24.04.4 for Linux on x86_64 ((Ubuntu))';
|
||||||
|
yield 'mysql 8 client, mariadb server' => [$mysql8, true, true];
|
||||||
|
yield 'mysql 8 client, mysql server' => [$mysql8, false, false];
|
||||||
|
yield 'mysql 5.7 client, mariadb server' => ['mysqldump Ver 10.13 Distrib 5.7.44, for Linux (x86_64)', true, false];
|
||||||
|
yield 'mariadb client, mariadb server' => ['mariadb-dump from 11.4.2-MariaDB, client 10.19 for debian-linux-gnu (x86_64)', true, false];
|
||||||
|
yield 'mariadb legacy mysqldump name' => ['mysqldump Ver 10.19 Distrib 10.11.6-MariaDB, for debian-linux-gnu (x86_64)', true, false];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace AeonDumpManager\Tests\Support;
|
||||||
|
|
||||||
|
use Psr\Log\AbstractLogger;
|
||||||
|
|
||||||
|
class RecordingLogger extends AbstractLogger
|
||||||
|
{
|
||||||
|
/** @var list<array{level: string, message: string, context: array<mixed>}> */
|
||||||
|
public array $records = [];
|
||||||
|
|
||||||
|
public function log($level, string|\Stringable $message, array $context = []): void
|
||||||
|
{
|
||||||
|
$this->records[] = ['level' => (string) $level, 'message' => (string) $message, 'context' => $context];
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user