Skip to content

[plugin] Refactor lambda-build packaging into a pluggable ArchiveBackend (ZIP today, OCI-ready)#681

Merged
sebsto merged 2 commits into
mainfrom
refactor/archive-backend
Jun 29, 2026
Merged

[plugin] Refactor lambda-build packaging into a pluggable ArchiveBackend (ZIP today, OCI-ready)#681
sebsto merged 2 commits into
mainfrom
refactor/archive-backend

Conversation

@sebsto

@sebsto sebsto commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Introduces a pluggable archive backend abstraction for lambda-build, mirroring
the existing build-backend design (#679). Packaging the built binaries into a
deployable artifact was hard-coded to ZIP inside Builder.swift; it is now behind
an ArchiveBackend protocol with one implementation today (ZIP, the existing code
moved verbatim) and a stubbed seam for OCI images in the future.

Internal refactor: the default behaviour is unchanged (ZIP), no public Swift API
changes, and the output ZIP layout / path is identical.

What changed

  • ArchiveBackend protocol (ArchiveBackends/ArchiveBackend.swift) — owns what
    kind of artifact
    is produced from the built binaries. It's the packaging
    counterpart to BuildBackend (which owns how the binaries are built); Builder
    selects and sequences the two.
  • ZipArchiveBackend (ArchiveBackends/ZipArchiveBackend.swift) — the existing
    Builder.package(...) body, moved unchanged, with zipToolPath injected via init.
  • ArchiveFormat enum (ArchiveFormat.swift) — the parsed --archive-format
    value (zip | oci), mirroring CrossCompileMethod: parse(...) (defaults to
    zip, case-insensitive), isSupported (oci → false), and a new
    BuilderErrors.unsupportedArchiveFormat case.
  • --archive-format zip|oci flag — parsed into BuilderConfiguration, with a
    makeArchiveBackend() factory (following the same on-configuration factory
    convention as makeCrossCompileBackend()). oci is recognised but throws a
    "not yet supported" error. Help text and the verbose config dump updated.
  • Builder.build(...) now ends with configuration.makeArchiveBackend().archive(...)
    instead of the inline package(...) method (which is removed).
  • Directory rename: Backends/BuildBackends/, so the two families read as
    parallel siblings: BuildBackends/ and ArchiveBackends/.

Adding OCI later

Add OCIArchiveBackend: ArchiveBackend under ArchiveBackends/, then flip the oci
case in ArchiveFormat.isSupported and makeArchiveBackend(). No other changes.

Testing

  • New ArchiveBackendTests.swift: ArchiveFormat.parse (default/case-insensitive/
    oci-unsupported/unknown), makeArchiveBackend() selection (zip → ZipArchiveBackend),
    and ZipArchiveBackend.archive run against a temp build dir asserting the .zip and
    relocated bootstrap are produced.
  • All AWSLambdaPluginHelperTests pass (90 tests); swift build and
    swift format lint --strict clean.
  • End-to-end: --archive-format oci fails fast with the stub error; zip/default
    produce a byte-for-byte identical artifact to before.

@sebsto sebsto self-assigned this Jun 29, 2026
@sebsto sebsto added 🆕 semver/minor Adds new public API. 🔨 semver/patch No public API change. and removed 🆕 semver/minor Adds new public API. 🔨 semver/patch No public API change. labels Jun 29, 2026
@sebsto sebsto changed the title Refactor lambda-build packaging into a pluggable ArchiveBackend (ZIP today, OCI-ready) [plugin] Refactor lambda-build packaging into a pluggable ArchiveBackend (ZIP today, OCI-ready) Jun 29, 2026
@sebsto sebsto merged commit 06191b2 into main Jun 29, 2026
53 checks passed
@sebsto sebsto deleted the refactor/archive-backend branch June 29, 2026 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🆕 semver/minor Adds new public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant