34 Commits
Author SHA1 Message Date
haylanandClaude Bot 391db5b621 docs: match CLAUDE.md to the idempotent release and registry repack
plugin-checks / version-changelog (pull_request) Successful in 22s
plugin-checks / package (pull_request) Successful in 1m12s
plugin-checks / phpunit (pull_request) Canceled after 3m1s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-04 00:50:20 +02:00
haylanandClaude Bot 8afe30b476 test: assert plugin logs to injected PSR logger
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-04 00:50:19 +02:00
haylanandClaude Bot 5f8cc9bdad docs: refresh CLAUDE.md and compliance spec after guideline PR
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-04 00:49:57 +02:00
haylanandClaude Bot c08d27c8e1 fix(release): repack the zip root-level for the Composer registry; make release steps idempotent
Gitea's registry answered 400 'composer.json file is missing' for the shopware-cli zip
(single top-level folder). Repack the same prebuilt content with composer.json at the root.
Drop the tag-exists skip guard so a half-finished release can be re-run; reuse an existing
release/asset. Bump to 0.1.1.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-04 00:49:53 +02:00
haylan 85980ee3bf Merge pull request 'feat: align plugin and pipeline with Shopware guidelines' (!13) from ci/shopware-guideline-compliance into main
release / release (push) Failing after 11s
Reviewed-on: #13
2026-10-03 22:46:17 +00:00
haylanandClaude Bot 8a72751a14 ci: single Shopware install into shopware_test; serialize releases
plugin-checks / version-changelog (pull_request) Successful in 16s
plugin-checks / package (pull_request) Successful in 1m1s
plugin-checks / phpunit (pull_request) Successful in 6m2s
DATABASE_URL already ends in _test so the TestBootstrapper finds an installed DB and
skips its own migration run; FORCE_INSTALL (which failed with an unknown database) removed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-04 00:36:22 +02:00
haylanandClaude Bot 233f3eb17f ci: merge version check into plugin-checks, share packaging as a composite action
plugin-checks / version-changelog (pull_request) Successful in 22s
plugin-checks / package (pull_request) Successful in 1m8s
plugin-checks / phpunit (pull_request) Failing after 1m53s
- one PR workflow (plugin-checks) with version-changelog, package, phpunit jobs
- .gitea/actions/package: package + validate + assert, used by PR and release
- phpunit: FORCE_INSTALL so the TestBootstrapper installs its own test DB
- protect-main.sh: required context is now plugin-checks / version-changelog

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-04 00:32:16 +02:00
haylanandClaude Bot 37aba5d2f0 ci: cache the Shopware project, drop duplicate install, reuse the tested zip in release
version-changelog / version-changelog (pull_request) Successful in 24s
plugin-checks / package (pull_request) Successful in 1m18s
plugin-checks / phpunit (pull_request) Failing after 1m33s
- phpunit: cache the prepared project (vendor + phpunit) monthly via cache restore/save;
  drop system:install/plugin:install (TestBootstrapper installs into its own test DB, so
  every migration ran twice, ~5.5 min each); relax InnoDB durability on the CI database
- package: save the tested zip keyed by the commit's tree hash; release restores it and
  only re-packages on a miss, but always validates and asserts the zip
- cancel superseded PR runs (concurrency)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-04 00:29:17 +02:00
haylanandClaude Bot 9f760cb6b0 chore: mark CI scripts executable
version-changelog / version-changelog (pull_request) Successful in 53s
plugin-checks / package (pull_request) Successful in 1m43s
plugin-checks / phpunit (pull_request) Failing after 14m43s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-04 00:15:33 +02:00
haylanandClaude Bot ff69377749 ci: dedupe validate into package, add caches, run phpunit in the shopware-cli image
version-changelog / version-changelog (pull_request) Successful in 51s
plugin-checks / package (pull_request) Failing after 1m26s
plugin-checks / phpunit (pull_request) Failing after 3m3s
- drop the separate validate job (the zip is validated after packaging); same in release
- shared scripts/ci/assert-built-assets.sh (BusyBox-safe), now also used by release
- actions/cache for npm, shopware-cli and composer
- phpunit: shopware-cli image instead of a 4.5 min apt install; MariaDB 10.11
  (11.4 broke Shopware's migrations: Duplicate column 'sorter_key')
- protect-main.sh: drop the removed validate context

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-04 00:15:25 +02:00
haylanandClaude Bot c3b242675e ci: run shopware-cli jobs in the official Docker image
version-changelog / version-changelog (pull_request) Successful in 59s
plugin-checks / validate (pull_request) Successful in 3m1s
plugin-checks / package (pull_request) Failing after 3m47s
plugin-checks / phpunit (pull_request) Failing after 6m38s
Replaces the curl/tar install and setup-node steps; the image ships the
CLI plus its PHP/Node toolchain.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-04 00:07:07 +02:00
haylanandClaude Bot 1ec194b464 ci: PHP via apt in a bookworm container, retry shopware-cli download
plugin-checks / validate (pull_request) Successful in 1m49s
version-changelog / version-changelog (pull_request) Successful in 1m55s
plugin-checks / package (pull_request) Successful in 2m15s
plugin-checks / phpunit (pull_request) Failing after 10m31s
setup-php hangs on the runner even with runner=self-hosted; the CLI download
returned a non-gzip body once under concurrent load.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-04 00:03:12 +02:00
haylanandClaude Bot 221ffece3f ci: fix hanging setup-php, wait for DB manually, add compatibility_date
version-changelog / version-changelog (pull_request) Successful in 26s
plugin-checks / validate (pull_request) Failing after 1m45s
plugin-checks / package (pull_request) Failing after 1m45s
plugin-checks / phpunit (pull_request) Canceled after 11m9s
- validate job needs no PHP (the package job already validates without it)
- phpunit: runner=self-hosted so setup-php does not hang under act; replace the
  unhealthy service healthcheck with a TCP wait loop
- .config/shopware-extension.yml: set compatibility_date

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-03 23:51:10 +02:00
haylan 54eeab70aa fix(plugin): reword descriptions, add transparent icon variant
version-changelog / version-changelog (pull_request) Successful in 42s
plugin-checks / package (pull_request) Successful in 1m38s
plugin-checks / phpunit (pull_request) Failing after 1m59s
plugin-checks / validate (pull_request) Canceled after 16m9s
2026-10-03 23:46:11 +02:00
haylanandClaude Bot 89a445f900 fix: satisfy shopware-cli validate (description length, icon under 30kb)
version-changelog / version-changelog (pull_request) Successful in 38s
plugin-checks / package (pull_request) Successful in 1m35s
plugin-checks / phpunit (pull_request) Failing after 2m1s
plugin-checks / validate (pull_request) Successful in 15m51s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-03 23:37:03 +02:00
haylanandClaude Bot a551034442 ci: plugin-agnostic PR checks and package-then-release pipeline
version-changelog / version-changelog (pull_request) Successful in 50s
plugin-checks / package (pull_request) Failing after 1m50s
plugin-checks / validate (pull_request) Failing after 31m29s
plugin-checks / phpunit (pull_request) Canceled after 33m2s
- plugin-checks workflow: shopware-cli validate, package + built-JS assertion, phpunit
- release: validate, package from the merge commit, validate the zip, create the release
  via the Gitea API, publish the same zip to the Composer registry
- scripts/protect-main.sh sets required status checks via tea api
- bump to 0.1.0

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-03 23:28:15 +02:00
haylanandClaude Bot 8efaef2042 feat(plugin): align with Shopware plugin guidelines
- add dedicated monolog channel aeon_dump_manager and log dump jobs
- migrate services.xml/routes.php to YAML
- require PHP ^8.2
- add extension icon and .config/shopware-extension.yml
- drop empty lifecycle overrides

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-03 23:26:21 +02:00
haylanandClaude Bot 29974928d2 docs(spec): add Shopware guideline compliance spec
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-03 23:22:23 +02:00
haylan 36ef203797 Merge pull request 'chore:(composer): namespace fix' (!12) from namespace-fix into main
release / release (push) Successful in 54s
Reviewed-on: #12
2026-09-21 19:31:07 +00:00
haylan ba2d1ec1d6 chroe(changelog): version dump
version-changelog / version-changelog (pull_request) Successful in 18s
2026-09-21 21:30:19 +02:00
haylan d117444bae chore(bump): version
version-changelog / version-changelog (pull_request) Failing after 4s
2026-09-21 21:29:04 +02:00
haylan 58df03216d chore:(composer): namespace fix
version-changelog / version-changelog (pull_request) Failing after 5s
2026-09-21 21:27:58 +02:00
haylan 29402a35ac Merge pull request 'ci: link published Composer packages to this repository' (!11) from ci/link-package-fix into main
release / release (push) Successful in 50s
2026-09-21 18:40:29 +00:00
haylan 63134f7de4 chore(release): bump to 0.0.4 for the Composer package-link fix
version-changelog / version-changelog (pull_request) Successful in 6s
2026-09-21 20:40:03 +02:00
haylan b8b8ee6284 ci: treat HTTP 400 (already linked) as expected on the package-link step 2026-09-21 20:39:10 +02:00
haylan b93217cc51 test: verify RELEASE_TOKEN can call the package-link endpoint 2026-09-21 20:11:54 +02:00
haylan 61b4b2b1af ci: link the published Composer package to this repository 2026-09-21 20:10:55 +02:00
haylan ec5c40c9f2 Merge pull request 'feat(dump): date-range filter, sortable columns, native date formatting' (!10) from feat/dump-list-view into main
release / release (push) Successful in 1m1s
2026-09-21 18:00:42 +00:00
haylan 56ada0cedc Merge remote-tracking branch 'origin/main' into feat/dump-list-view
version-changelog / version-changelog (pull_request) Successful in 5s
# Conflicts:
#	composer.json
2026-09-21 19:59:19 +02:00
haylan f50154b96b chore(release): bump to 0.0.3 for the date-range filter release 2026-09-21 19:58:04 +02:00
haylanandClaude Bot 5a482b49bb feat(dump): add date-range filter, sortable columns, and native date formatting to admin list
- Wires the backend from/to filter into the UI via sw-filter-panel with
  a hand-built date-filter config (no DAL entity needed — sw-filter-panel's
  only external dependency, filterService, persists through the generic
  user_config entity, not one for the filtered resource).
- Makes the datetime and sizeBytes columns sortable (ascending/descending)
  using the same Mixin.getByName('listing') core list pages use, which
  also persists sort state in the URL query string.
- Replaces the ad hoc `new Date(value).toLocaleString()` with
  Shopware.Utils.format.date, matching the existing fileSize formatting
  and respecting the admin's locale/timezone.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-17 12:39:23 +02:00
haylanandClaude Bot 6094b6f49c test(dump): replace @dataProvider annotations with #[DataProvider] attributes
The installed PHPUnit (12.x, ahead of this plugin's ^10.0 dev
constraint) no longer parses the @dataProvider PHPDoc annotation,
so both tests silently ran their data-provider method with zero
arguments and failed with ArgumentCountError.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-17 12:39:08 +02:00
haylanandClaude Bot e5c3a5b28f fix(dump): normalize date-filter bounds to the app timezone before applying day boundary
The admin date filter can send a naive local date string for "from" but
a UTC Z-suffixed instant for "to" (sw-date-filter widens it client-side
via Date#toISOString()). Comparing those directly against dump
timestamps (parsed in PHP's default timezone) shifted the effective
cutoff by the timezone offset. Re-express both bounds in the app's
default timezone before applying the day boundary.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-17 12:38:54 +02:00
haylan f967ef7544 feat(dump): filter admin dump list by from/to date range
Adds optional from/to query params to the dumps list endpoint and
DumpLister::list(), and bumps the plugin version to 0.0.2.
2026-09-17 12:38:39 +02:00
33 changed files with 930 additions and 273 deletions

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
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
- .claude
- .scratch
- .wayfinder
- src/Resources/config/plugin-transparent.png
validation:
ignore: []
+35
View File
@@ -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 }}"
+148
View File
@@ -0,0 +1,148 @@
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
with:
fetch-depth: 0
- name: Check version bump and changelog entry
run: |
set -e
PR_VERSION=$(grep -m1 '"version"' composer.json | sed -E 's/.*"version"[[:space:]]*:[[:space:]]*"([^"]+)".*/\1/')
MAIN_VERSION=$(git show origin/main:composer.json | grep -m1 '"version"' | sed -E 's/.*"version"[[:space:]]*:[[:space:]]*"([^"]+)".*/\1/')
echo "main version: $MAIN_VERSION"
echo "PR version: $PR_VERSION"
if [ "$MAIN_VERSION" = "$PR_VERSION" ]; then
echo "::error::composer.json version ($PR_VERSION) was not bumped from main ($MAIN_VERSION)"
exit 1
fi
HIGHEST=$(printf '%s\n%s\n' "$MAIN_VERSION" "$PR_VERSION" | sort -V | tail -n1)
if [ "$HIGHEST" != "$PR_VERSION" ]; then
echo "::error::composer.json version ($PR_VERSION) is not greater than main's ($MAIN_VERSION)"
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: version bumped to $PR_VERSION 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
- name: Month stamp (refreshes the cached project monthly)
id: stamp
run: echo "month=$(date +%Y-%m)" >> "$GITHUB_OUTPUT"
# The project (incl. vendor/ and phpunit) does not depend on the plugin, so it is cached on its own.
- name: Restore prepared Shopware project
id: project
uses: actions/cache/restore@v4
with:
path: shopware
key: shopware-6.6-prepared-${{ steps.stamp.outputs.month }}
- name: Create Shopware 6.6 project
if: steps.project.outputs.cache-hit != 'true'
run: |
set -e
composer create-project shopware/production:6.6.* shopware --no-interaction --no-scripts
composer require --dev phpunit/phpunit:^10 --no-interaction --no-scripts -d shopware
- name: Save prepared Shopware project
if: steps.project.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: shopware
key: shopware-6.6-prepared-${{ steps.stamp.outputs.month }}
- 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 migrations)
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");'
- 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}"
# One install into shopware_test; the bootstrapper sees an installed DB, skips its own install and
# only activates the plugin (tests/TestBootstrap.php forces plugin installation).
- name: Install Shopware (once)
working-directory: shopware
run: bin/console system:install --basic-setup --create-database --force --no-interaction
- name: Run phpunit
working-directory: shopware
run: vendor/bin/phpunit -c "custom/plugins/${PLUGIN_NAME}/phpunit.xml"
-40
View File
@@ -1,40 +0,0 @@
name: version-changelog
on:
pull_request:
branches: [main]
jobs:
version-changelog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check version bump and changelog entry
run: |
set -e
PR_VERSION=$(grep -m1 '"version"' composer.json | sed -E 's/.*"version"[[:space:]]*:[[:space:]]*"([^"]+)".*/\1/')
MAIN_VERSION=$(git show origin/main:composer.json | grep -m1 '"version"' | sed -E 's/.*"version"[[:space:]]*:[[:space:]]*"([^"]+)".*/\1/')
echo "main version: $MAIN_VERSION"
echo "PR version: $PR_VERSION"
if [ "$MAIN_VERSION" = "$PR_VERSION" ]; then
echo "::error::composer.json version ($PR_VERSION) was not bumped from main ($MAIN_VERSION)"
exit 1
fi
HIGHEST=$(printf '%s\n%s\n' "$MAIN_VERSION" "$PR_VERSION" | sort -V | tail -n1)
if [ "$HIGHEST" != "$PR_VERSION" ]; then
echo "::error::composer.json version ($PR_VERSION) is not greater than main's ($MAIN_VERSION)"
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: version bumped to $PR_VERSION and documented in CHANGELOG.md"
+112 -59
View File
@@ -1,100 +1,153 @@
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]
env:
SERVER_URL: https://git.arthurerlich.de
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 and guard against re-release
id: version
- name: Determine version, tag and file names
id: meta
run: |
set -e
VERSION=$(grep -m1 '"version"' composer.json | sed -E 's/.*"version"[[:space:]]*:[[:space:]]*"([^"]+)".*/\1/')
VERSION=$(jq -r .version composer.json)
PACKAGE_NAME=$(jq -r .name composer.json)
REPO_NAME="${GITHUB_REPOSITORY#*/}"
TAG="v${VERSION}"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
if git ls-remote --tags origin "refs/tags/${TAG}" | grep -q "${TAG}"; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "Tag ${TAG} already exists, nothing to release."
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
{
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
if: steps.version.outputs.skip == 'false'
run: |
awk -v ver="${{ steps.version.outputs.version }}" '
awk -v ver="${{ steps.meta.outputs.version }}" '
BEGIN { found=0 }
/^## \[/ {
if (found) exit
if ($0 ~ "\[" ver "\]") { found=1; next }
if ($0 ~ "\\[" ver "\\]") { found=1; next }
}
found { print }
' CHANGELOG.md > release-notes.md
cat release-notes.md
- name: Create and push tag
if: steps.version.outputs.skip == 'false'
- name: Create Gitea release (creates the tag) and upload the zip
env:
TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: |
git config user.name "gitea-actions"
git config user.email "actions@git.arthurerlich.de"
git tag "${{ steps.version.outputs.tag }}"
git push origin "${{ steps.version.outputs.tag }}"
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
- name: Install shopware-cli
if: steps.version.outputs.skip == 'false'
# 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: |
curl -sL -o /tmp/shopware-cli.tar.gz \
https://github.com/shopware/shopware-cli/releases/latest/download/shopware-cli_Linux_x86_64.tar.gz
mkdir -p /tmp/swcli-extract
tar -xzf /tmp/shopware-cli.tar.gz -C /tmp/swcli-extract
cp /tmp/swcli-extract/shopware-cli /usr/local/bin/shopware-cli
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 }}"
(cd "$ROOT" && zip -qr "$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: Validate extension (informational only, does not gate the release)
if: steps.version.outputs.skip == 'false'
run: shopware-cli extension validate . || true
- name: Package Store-style zip for the Gitea Release asset
if: steps.version.outputs.skip == 'false'
run: |
shopware-cli extension package . --output-directory .build \
--filename "AeonDumpManager-${{ steps.version.outputs.tag }}.zip"
- name: Build root-level zip for the Composer registry
if: steps.version.outputs.skip == 'false'
run: git archive --format=zip -o "composer-package-${{ steps.version.outputs.tag }}.zip" "${{ steps.version.outputs.tag }}"
- name: Create Gitea Release
if: steps.version.outputs.skip == 'false'
uses: akkuman/gitea-release-action@v1
with:
server_url: ${{ env.SERVER_URL }}
token: ${{ secrets.RELEASE_TOKEN }}
tag_name: ${{ steps.version.outputs.tag }}
name: ${{ steps.version.outputs.tag }}
body_path: release-notes.md
files: .build/AeonDumpManager-${{ steps.version.outputs.tag }}.zip
- name: Publish to Composer registry
if: steps.version.outputs.skip == 'false'
- name: Publish to the Composer registry
run: |
STATUS=$(curl -s -o /tmp/composer-publish.log -w "%{http_code}" \
-u "haylan:${{ secrets.RELEASE_TOKEN }}" \
-T "composer-package-${{ steps.version.outputs.tag }}.zip" \
"https://git.arthurerlich.de/api/packages/haylan/composer")
-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
+55 -12
View File
@@ -5,6 +5,53 @@ All notable changes to AeonDumpManager will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [0.1.1] - 2026-10-04
### Fixed
- Release pipeline: the Composer registry rejected the packaged zip (`composer.json file is missing`) because `shopware-cli` zips wrap everything in a top-level folder. The same prebuilt content is now repacked root-level for the registry upload.
- Release steps are idempotent (existing release and asset are reused, registry 409 counts as published) and the "tag exists -> skip" guard is gone, so a failed release can be re-run to completion.
## [0.1.0] - 2026-10-03
### 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 both the Gitea Release and the Composer registry; 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.
### Added
- Dedicated `aeon_dump_manager` monolog channel; dump jobs, deletions and purges are logged.
- Extension icon and `.config/shopware-extension.yml`.
### Removed
- Empty plugin lifecycle overrides.
## [0.0.5] - 2026-09-21
### 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
@@ -16,18 +63,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `main` is now a protected branch: no direct pushes, merges require the version/changelog check
to pass.
## [Unreleased]
## [0.0.1] - 2026-09-15
### Added
- List, create, and delete SQL database dumps from a Settings admin page (nested under Settings, per
Shopware's [Add Menu Entry](https://developer.shopware.com/docs/v6.6/guides/plugins/plugins/administration/routing-navigation/add-menu-entry.html)
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`
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
on a recurring scheduled task.
- Admin UI dump creation runs asynchronously via Symfony Messenger with a polling progress bar; console
creation runs synchronously.
- ACL-gated (`aeon_dump_manager.viewer`/`.creator`/`.deleter`), enforced both client-side and
server-side.
- 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.
+30 -4
View File
@@ -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
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`.
- 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
its tag, e.g. `console.command` or `shopware.scheduled.task`).
- 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/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
@@ -51,6 +53,10 @@ 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
to bootstrap against — they are not runnable as an isolated PHP package.
In CI (`phpunit` job) a Shopware 6.6 project is prepared once (`composer create-project` + phpunit,
cached monthly), the plugin is copied into `custom/plugins`, and `system:install` runs once into
`shopware_test` (MariaDB 10.11 service), so the bootstrapper only activates the plugin.
```bash
vendor/bin/phpunit # full suite
vendor/bin/phpunit --filter TestClassName # single test class
@@ -59,14 +65,34 @@ vendor/bin/phpunit tests/SomeTest.php # single file
## 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.6.0` (from `composer.json`); `phpunit/phpunit` `^10.0` as the only
dev dependency.
- 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` (every PR into
`main` must bump `composer.json` version and add 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
- 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.
- 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.
+7 -7
View File
@@ -1,9 +1,9 @@
{
"name": "aeon/dump-manager",
"name": "arthurerlich/aeon-dump-manager",
"description": "Export database dumps for Shopware 6 environments.",
"type": "shopware-platform-plugin",
"license": "MIT",
"version": "0.0.2",
"version": "0.1.1",
"keywords": [
"shopware",
"shopware6",
@@ -25,7 +25,7 @@
"source": "https://git.arthurerlich.de/haylan/AeonDumpManager"
},
"require": {
"php": "^8.1",
"php": "^8.2",
"shopware/core": "~6.6.0"
},
"require-dev": {
@@ -35,12 +35,12 @@
"shopware-plugin-class": "AeonDumpManager\\AeonDumpManager",
"copyright": "(c) by Arthur Erlich",
"label": {
"de-DE": "Aeon Dump Manager",
"en-GB": "Aeon Dump Manager"
"de-DE": "Dump Manager",
"en-GB": "Dump Manager"
},
"description": {
"de-DE": "Verwaltet Datenbank-Dumps für Shopware 6 Entwicklungsumgebungen.",
"en-GB": "Manages database dumps for Shopware 6 development environments."
"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": "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": {
"de-DE": "https://arthurerlich.de",
@@ -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.
+17
View File
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
# Assert that a packaged extension zip contains the built admin/storefront JS when the sources exist.
# Usage: scripts/ci/assert-built-assets.sh <zip> (run from the repo root; BusyBox-safe: uses unzip -l)
set -euo pipefail
ZIP="${1:?usage: assert-built-assets.sh <zip>}"
LIST=$(unzip -l "$ZIP")
check() { # <label> <entry-glob-prefix> <expected path in zip>
local label="$1" entry="$2" expected="$3"
if [ -f "${entry}/main.js" ] || [ -f "${entry}/main.ts" ]; then
echo "$LIST" | grep -q "$expected" || { echo "::error::${label} entry exists but the zip has no built ${label} JS (${expected})"; exit 1; }
echo "ok: ${label} JS is in the zip"
fi
}
check admin src/Resources/app/administration/src "Resources/public/administration/js/"
check storefront src/Resources/app/storefront/src "Resources/app/storefront/dist/"
+16
View File
@@ -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
View File
@@ -4,17 +4,33 @@ namespace AeonDumpManager;
use Doctrine\DBAL\Connection;
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\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
{
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
@@ -29,29 +45,4 @@ class AeonDumpManager extends Plugin
$connection = $this->container->get(Connection::class);
$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
{
}
}
+33 -2
View File
@@ -11,6 +11,7 @@ use Shopware\Core\Framework\Routing\ApiRouteScope;
use Shopware\Core\PlatformRequest;
use Symfony\Component\HttpFoundation\HeaderUtils;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -39,16 +40,46 @@ class DumpController
defaults: [PlatformRequest::ATTRIBUTE_ACL => ['aeon_dump_manager.viewer']],
methods: ['GET']
)]
public function list(): JsonResponse
public function list(Request $request): JsonResponse
{
$dumps = array_map(
static fn ($dumpFile) => $dumpFile->jsonSerialize(),
$this->dumpLister->list()
$this->dumpLister->list(
$this->parseBoundDate($request->query->get('from'), false),
$this->parseBoundDate($request->query->get('to'), true),
)
);
return new JsonResponse(['dumps' => $dumps]);
}
/**
* The admin's date filter sends mixed shapes: the "from" bound is a naive local
* date string with no timezone marker (e.g. "2026-03-01T00:00:00"), while
* sw-date-filter widens "to" to end-of-day client-side via `Date#toISOString()`,
* which is always UTC (e.g. "2026-03-01T23:59:59.000Z"). Re-expressing both in
* PHP's default timezone (the same one DumpFilenameParser uses) before applying
* our own day-boundary keeps the calendar day the user actually picked, regardless
* of which shape arrived. An empty bound (no date set) stays null so the range is
* open on that side.
*/
private function parseBoundDate(?string $value, bool $endOfDay): ?\DateTimeImmutable
{
if ($value === null || trim($value) === '') {
return null;
}
try {
$dateTime = (new \DateTimeImmutable($value))->setTimezone(new \DateTimeZone(date_default_timezone_get()));
} catch (\Exception) {
return null;
}
return $endOfDay
? $dateTime->setTime(23, 59, 59)
: $dateTime->setTime(0, 0, 0);
}
#[Route(
path: '/api/_action/aeon-dump-manager/dumps',
name: 'api.action.aeon_dump_manager.dumps.create',
@@ -5,6 +5,7 @@ namespace AeonDumpManager\MessageQueue\Handler;
use AeonDumpManager\MessageQueue\Message\CreateDumpMessage;
use AeonDumpManager\Service\DumpJobStatusService;
use AeonDumpManager\Service\DumpService;
use Psr\Log\LoggerInterface;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
#[AsMessageHandler]
@@ -13,6 +14,7 @@ class CreateDumpHandler
public function __construct(
private readonly DumpService $dumpService,
private readonly DumpJobStatusService $jobStatus,
private readonly LoggerInterface $logger,
) {
}
@@ -20,10 +22,12 @@ class CreateDumpHandler
{
$jobId = $message->getJobId();
$this->jobStatus->markRunning($jobId);
$this->logger->info('Dump job started.', ['jobId' => $jobId]);
try {
$this->dumpService->createAsync($jobId, $this->jobStatus);
} catch (\Throwable $exception) {
$this->logger->error('Dump job failed.', ['jobId' => $jobId, 'exception' => $exception]);
$this->jobStatus->markFailed($jobId, $exception->getMessage());
}
}
@@ -14,14 +14,24 @@
<template #content>
<div class="aeon-dump-manager-list__content">
<sw-filter-panel
:filters="listFilters"
:defaults="defaultFilters"
:store-key="storeKey"
@criteria-changed="onCriteriaChanged"
/>
<sw-data-grid
:data-source="dumps"
:data-source="sortedDumps"
:columns="columns"
:is-loading="isLoading"
:show-selection="acl.can('aeon_dump_manager.deleter')"
:full-page="true"
:sort-by="sortBy"
:sort-direction="sortDirection"
identifier="filename"
@selection-change="onSelectionChange"
@column-sort="onSortColumn"
>
<template #bulk>
<a
@@ -11,6 +11,12 @@ interface PendingJob {
const CREATE_MODAL_AUTO_CLOSE_MS = 1500;
interface DateRangeCriteria {
type: string;
field: string;
parameters?: { gte?: string; lte?: string };
}
interface ComponentData {
dumps: DumpFile[];
isLoading: boolean;
@@ -18,6 +24,12 @@ interface ComponentData {
deleteFilenames: string[] | null;
selection: Record<string, DumpFile>;
pollTimer: number | null;
dateFrom: string | null;
dateTo: string | null;
sortBy: string;
sortDirection: string;
storeKey: string;
defaultFilters: string[];
}
interface ComponentInstance extends ComponentData {
@@ -25,17 +37,25 @@ interface ComponentInstance extends ComponentData {
$tc: (key: string, count?: number, values?: Record<string, unknown>) => string;
createNotificationError: (options: { message: string }) => void;
createNotificationSuccess: (options: { message: string }) => void;
loadList: () => Promise<void>;
getList: () => Promise<void>;
stopPolling: () => void;
pollJobStatus: (jobId: string) => void;
selectionCount: number;
sortedDumps: DumpFile[];
listFilters: Record<string, unknown>[];
}
Component.register('aeon-dump-manager-list', {
template,
// Provides createNotificationSuccess/createNotificationError, used below.
mixins: [Mixin.getByName('notification')],
mixins: [
// Provides createNotificationSuccess/createNotificationError, used below.
Mixin.getByName('notification'),
// Provides sortBy/sortDirection state, onSortColumn(), and route-query
// persistence for them (same mixin sw-product-list etc. use) — our own
// data() below overrides the defaults to keep "newest first".
Mixin.getByName('listing'),
],
inject: ['aeonDumpManagerApiService', 'acl'],
@@ -47,27 +67,56 @@ Component.register('aeon-dump-manager-list', {
deleteFilenames: null,
selection: {},
pollTimer: null,
dateFrom: null,
dateTo: null,
sortBy: 'datetime',
sortDirection: 'DESC',
storeKey: 'grid.filter.aeon-dump-manager',
defaultFilters: ['datetime'],
};
},
computed: {
listFilters(this: ComponentInstance) {
return [
{
name: 'datetime',
type: 'date-filter',
property: 'datetime',
label: this.$tc('aeon-dump-manager.list.columnDatetime'),
dateType: 'date',
fromFieldLabel: this.$tc('aeon-dump-manager.list.filterFromLabel'),
toFieldLabel: this.$tc('aeon-dump-manager.list.filterToLabel'),
fromPlaceholder: this.$tc('aeon-dump-manager.list.filterFromPlaceholder'),
toPlaceholder: this.$tc('aeon-dump-manager.list.filterToPlaceholder'),
showTimeframe: false,
},
];
},
columns() {
return [
{
property: 'datetime',
dataIndex: 'datetime',
label: this.$tc('aeon-dump-manager.list.columnDatetime'),
allowResize: true,
sortable: true,
},
{
property: 'filename',
dataIndex: 'filename',
label: this.$tc('aeon-dump-manager.list.columnFilename'),
allowResize: true,
sortable: true,
},
{
property: 'sizeBytes',
dataIndex: 'sizeBytes',
label: this.$tc('aeon-dump-manager.list.columnSize'),
align: 'right',
allowResize: true,
sortable: true,
},
];
},
@@ -75,10 +124,27 @@ Component.register('aeon-dump-manager-list', {
selectionCount(this: ComponentInstance): number {
return Object.keys(this.selection).length;
},
},
created(this: ComponentInstance) {
this.loadList();
sortedDumps(this: ComponentInstance): DumpFile[] {
const direction = this.sortDirection === 'ASC' ? 1 : -1;
return [...this.dumps].sort((a, b) => {
let compareVal: number;
switch (this.sortBy) {
case 'sizeBytes':
compareVal = a.sizeBytes - b.sizeBytes;
break;
case 'datetime':
compareVal = new Date(a.datetime).getTime() - new Date(b.datetime).getTime();
break;
default:
compareVal = a.filename.localeCompare(b.filename, undefined, { numeric: true });
}
return compareVal * direction;
});
},
},
beforeDestroy(this: ComponentInstance) {
@@ -86,10 +152,10 @@ Component.register('aeon-dump-manager-list', {
},
methods: {
loadList(this: ComponentInstance): Promise<void> {
getList(this: ComponentInstance): Promise<void> {
this.isLoading = true;
return this.aeonDumpManagerApiService.getList()
return this.aeonDumpManagerApiService.getList({ from: this.dateFrom, to: this.dateTo })
.then((response) => {
this.dumps = response.dumps;
})
@@ -99,7 +165,15 @@ Component.register('aeon-dump-manager-list', {
},
formatDatetime(value: string): string {
return new Date(value).toLocaleString();
return Shopware.Utils.format.date(value);
},
onCriteriaChanged(this: ComponentInstance, criteria: DateRangeCriteria[]) {
const range = criteria.find((filter) => filter.type === 'range' && filter.field === 'datetime');
this.dateFrom = range?.parameters?.gte ?? null;
this.dateTo = range?.parameters?.lte ?? null;
this.getList();
},
formatSize(bytes: number): string {
@@ -133,7 +207,7 @@ Component.register('aeon-dump-manager-list', {
if (job.status === 'done') {
this.stopPolling();
this.loadList();
this.getList();
window.setTimeout(() => {
this.pendingJob = null;
}, CREATE_MODAL_AUTO_CLOSE_MS);
@@ -196,19 +270,19 @@ Component.register('aeon-dump-manager-list', {
// Optimistic UI update: pull the rows out immediately rather than
// waiting on a full reload, so the grid never looks stale even if
// loadList() is slow or a later delete in the batch fails.
// getList() is slow or a later delete in the batch fails.
this.dumps = this.dumps.filter((dumpFile) => !filenames.includes(dumpFile.filename));
this.selection = {};
return Promise.all(filenames.map((filename) => this.aeonDumpManagerApiService.remove(filename)))
.then(() => this.loadList())
.then(() => this.getList())
.catch((error: Error) => {
this.createNotificationError({
message: this.$tc('aeon-dump-manager.list.deleteFailed', 0, { error: error.message }),
});
// A delete failed after the optimistic removal — reload to
// show the real state rather than leave a wrong guess on screen.
return this.loadList();
return this.getList();
});
},
},
@@ -8,6 +8,10 @@
"columnFilename": "Name",
"columnDatetime": "Erstellt am",
"columnSize": "Größe",
"filterFromLabel": "Von",
"filterFromPlaceholder": "Startdatum auswählen...",
"filterToLabel": "Bis",
"filterToPlaceholder": "Enddatum auswählen...",
"buttonCreate": "Dump erstellen",
"buttonDownload": "Herunterladen",
"buttonDelete": "Löschen",
@@ -8,6 +8,10 @@
"columnFilename": "Name",
"columnDatetime": "Created at",
"columnSize": "Size",
"filterFromLabel": "From",
"filterFromPlaceholder": "Select start date...",
"filterToLabel": "To",
"filterToPlaceholder": "Select end date...",
"buttonCreate": "Create dump",
"buttonDownload": "Download",
"buttonDelete": "Delete",
@@ -43,9 +43,12 @@ export default class DumpApiService extends ApiService {
super(httpClient, loginService, apiEndpoint);
}
getList(): Promise<DumpList> {
getList(filter: { from?: string | null; to?: string | null } = {}): Promise<DumpList> {
return this.httpClient
.get('/_action/aeon-dump-manager/dumps', { headers: this.getBasicHeaders() })
.get('/_action/aeon-dump-manager/dumps', {
headers: this.getBasicHeaders(),
params: { from: filter.from ?? undefined, to: filter.to ?? undefined },
})
.then((response: unknown) => ApiService.handleResponse(response));
}
@@ -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

-7
View File
@@ -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');
};
+3
View File
@@ -0,0 +1,3 @@
aeon_dump_manager_controllers:
resource: ../../Controller/*Controller.php
type: attribute
-88
View File
@@ -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>
+92
View File
@@ -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'
+9 -1
View File
@@ -18,7 +18,7 @@ class DumpLister
/**
* @return DumpFile[] newest first
*/
public function list(): array
public function list(?\DateTimeImmutable $from = null, ?\DateTimeImmutable $to = null): array
{
$dumps = [];
@@ -33,6 +33,14 @@ class DumpLister
continue;
}
if ($from !== null && $datetime < $from) {
continue;
}
if ($to !== null && $datetime > $to) {
continue;
}
$dumps[] = new DumpFile($filename, $datetime, $item->fileSize());
}
+8
View File
@@ -6,6 +6,7 @@ use AeonDumpManager\Service\Exception\DumpNotFoundException;
use AeonDumpManager\Struct\DumpFile;
use Doctrine\DBAL\Connection;
use League\Flysystem\FilesystemOperator;
use Psr\Log\LoggerInterface;
use Shopware\Core\System\SystemConfig\SystemConfigService;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;
@@ -24,6 +25,7 @@ class DumpService
private readonly Connection $connection,
private readonly SystemConfigService $systemConfigService,
private readonly DumpFilenameParser $filenameParser,
private readonly LoggerInterface $logger,
) {
}
@@ -69,6 +71,7 @@ class DumpService
}
$this->aeonDumpManagerFilesystemPrivate->delete($path);
$this->logger->info('Dump deleted.', ['filename' => $filename]);
}
/**
@@ -100,6 +103,7 @@ class DumpService
foreach ($excess as $dumpFile) {
$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) {
if ($dumpFile->datetime < $threshold) {
$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()) {
@unlink($tempPath);
$this->logger->error('Dump process failed.', ['exitCode' => $process->getExitCode()]);
throw new ProcessFailedException($process);
}
@@ -153,6 +159,8 @@ class DumpService
fclose($stream);
@unlink($tempPath);
$this->logger->info('Dump created.', ['filename' => $filename, 'sizeBytes' => $sizeBytes]);
return new DumpFile($filename, $dateTime, $sizeBytes);
}
@@ -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']);
}
}
+2 -3
View File
@@ -3,6 +3,7 @@
namespace AeonDumpManager\Tests\Service;
use AeonDumpManager\Service\DumpFilenameParser;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class DumpFilenameParserTest extends TestCase
@@ -29,9 +30,7 @@ class DumpFilenameParserTest extends TestCase
self::assertEquals($dateTime, $this->parser->parse($filename));
}
/**
* @dataProvider invalidFilenameProvider
*/
#[DataProvider('invalidFilenameProvider')]
public function testParseRejectsInvalidFilenames(string $filename): void
{
self::assertNull($this->parser->parse($filename));
+66
View File
@@ -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);
}
}
}
+2 -3
View File
@@ -3,13 +3,12 @@
namespace AeonDumpManager\Tests\Service;
use AeonDumpManager\Service\MySqlVariant;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class MySqlVariantTest extends TestCase
{
/**
* @dataProvider versionProvider
*/
#[DataProvider('versionProvider')]
public function testIsMariaDb(string $version, bool $expected): void
{
self::assertSame($expected, MySqlVariant::isMariaDb($version));
+16
View File
@@ -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];
}
}