Skip to content

feat: support asset caching for extension zip#1114

Merged
Soner (shyim) merged 1 commit into
mainfrom
feat/extension-zip-asset-caching
Jun 20, 2026
Merged

feat: support asset caching for extension zip#1114
Soner (shyim) merged 1 commit into
mainfrom
feat/extension-zip-asset-caching

Conversation

@shyim

Copy link
Copy Markdown
Member

What

Adds 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.

build:
  zip:
    assets:
      enabled: true
      enable_asset_caching: true

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 set EnableAssetCaching, so caching — including the already-configurable additional_caches — was silently inert during extension zip. Only project ci ever turned it on.

How

  • internal/extension/config.go — add EnableAssetCaching to ConfigBuildZipAssets (yaml: enable_asset_caching).
  • cmd/extension/extension_zip.go — wire it into the AssetBuildConfig passed to BuildAssetsForExtensions.
  • 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 configured additional_caches will only start caching once they set enable_asset_caching: true.

Notes (deliberately out of scope)

  • The cache key (sw-cli-<shopwareVersion>-<contentHash>) does not include the CLI/esbuild version — a CLI upgrade alone won't bust the cache. Same as the existing project ci path, so not a regression; can be added separately if desired.
  • The opt-in is a global flag on the zip path (zip builds one extension at a time). Making a per-extension flag also apply under project ci would require moving the boolean into the per-source entry — not done here.

Verification

  • go build ./..., go vet ./internal/extension/... ./cmd/extension/... — clean
  • go test ./internal/extension/ — passes (new tests included)
  • gofmt — clean

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.
@shyim Soner (shyim) marked this pull request as ready for review June 20, 2026 08:19
@shyim Soner (shyim) merged commit 5464a55 into main Jun 20, 2026
3 checks passed
@shyim Soner (shyim) deleted the feat/extension-zip-asset-caching branch June 20, 2026 08:21

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant