feat: support asset caching for extension zip#1114
Conversation
Add an `enable_asset_caching` opt-in to `build.zip.assets` in .shopware-extension.yml so `extension zip` reuses the existing asset cache machinery, mirroring the `asset_caching` setting already available for `project ci`. The cache layer is environment-agnostic (GitHub Actions cache in CI, disk cache otherwise) and already runs inside BuildAssetsForExtensions, but the zip path never set EnableAssetCaching, so caching (including additional_caches) was inert during zip. The flag is off by default, so existing behavior is unchanged unless explicitly enabled.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6112ce0934
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
| } | ||
|
|
||
| assetBuildConfig := extension.AssetBuildConfig{ | ||
| EnableAssetCaching: extCfg.Build.Zip.Assets.EnableAssetCaching, |
There was a problem hiding this comment.
Use stable paths for zip asset cache keys
When extension zip runs with enable_asset_caching: true, the sources passed below come from tempExt under a fresh os.MkdirTemp directory for every invocation, but GetContentHash includes the collected absolute file paths in the hash. That means the same extension content gets a different cache key on each zip build, so restore always misses and the new opt-in cache only stores redundant entries instead of speeding up subsequent extension zip runs.
Useful? React with 👍 / 👎.
What
Adds an
enable_asset_cachingopt-in tobuild.zip.assetsin.shopware-extension.yml, soextension zipreuses the existing asset cache machinery — mirroring theasset_cachingsetting already available forproject ci.Why
The cache layer is environment-agnostic (GitHub Actions cache in CI, disk cache otherwise) and already runs inside
BuildAssetsForExtensions(restore + store). But the zip path never setEnableAssetCaching, so caching — including the already-configurableadditional_caches— was silently inert duringextension zip. Onlyproject ciever turned it on.How
internal/extension/config.go— addEnableAssetCachingtoConfigBuildZipAssets(yaml:enable_asset_caching).cmd/extension/extension_zip.go— wire it into theAssetBuildConfigpassed toBuildAssetsForExtensions.internal/extension/config_schema.json— add the matching schema property (hand-maintained, embedded).internal/extension/asset_cache_test.go— tests for store/restore round-trip, disabled-is-no-op, and source-change busts the cache key.Behavior / compatibility
Off by default (zero value
false). Existing extensions are unaffected unless they explicitly opt in. Extensions that already configuredadditional_cacheswill only start caching once they setenable_asset_caching: true.Notes (deliberately out of scope)
sw-cli-<shopwareVersion>-<contentHash>) does not include the CLI/esbuild version — a CLI upgrade alone won't bust the cache. Same as the existingproject cipath, so not a regression; can be added separately if desired.project ciwould require moving the boolean into the per-source entry — not done here.Verification
go build ./...,go vet ./internal/extension/... ./cmd/extension/...— cleango test ./internal/extension/— passes (new tests included)gofmt— clean