33 Commits
Author SHA1 Message Date
Manoj MahapatraandSebastien Stormacq 6aa43874c8 feat: Added support for apple container (#647)
<!--- Provide a general summary of your changes in the Title above -->

## Issue \#
<!--- If it fixes an issue, please link to the issue here -->
https://github.com/awslabs/swift-aws-lambda-runtime/issues/644

## Description of changes
<!--- Why is this change required? What problem does it solve? -->
- Added `--container-cli` option to the archive SwiftPM plugin so users
can choose Docker (default) or Apple container
- Implemented Apple container support by switching pull/run commands to
`container image pull` and `container run`
- Documented the Apple container path in readme.md
- swift test passed

## New/existing dependencies impact assessment, if applicable
<!--- No new dependencies were added to this change. -->
<!--- If any dependency was added / modified / removed,
THIRD-PARTY-LICENSES must be updated accordingly. -->
N/A

## Conventional Commits
<!--- Please use conventional commits to let us know what kind of change
this is.-->
<!--- More info can be found here:
https://www.conventionalcommits.org/en/v1.0.0/-->

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

---------

Co-authored-by: Sebastien Stormacq <stormacq@amazon.lu>
2026-02-23 16:57:15 +01:00
Sébastien Stormacq 22dd7012de Archive plugin supports Amazon Linux 2023 in addition to Amazon Linux 2 (#646)
Relax the check on Amazon Linux to also consider Amazon Linux 2023 and
future versions

Fix #645
2026-02-18 15:22:05 +01:00
Sebastien Stormacq d9aebab425 Update Plugin Spec doc to add Apple container 2026-02-17 17:10:23 +01:00
Sébastien StormacqandSebastien Stormacq 11ef057299 Fix more crashes in archive (#642)
## Issue #
Related to intermittent CI crashes with Signal 11 (SIGSEGV) during
`swift package archive` on Linux x86_64 (Ubuntu 24.04)

## Description of the changes
Replaces `FileHandle.readabilityHandler` with a manual blocking read
loop using `availableData` on a serial `DispatchQueue` in the
`Utils.execute` method of the AWSLambdaPackager plugin.

On Linux, `FileHandle.readabilityHandler`'s setter internally calls
`_bridgeAnythingToObjectiveC`, which triggers `swift_dynamicCast` /
`swift_conformsToProtocol`. When the Swift runtime is concurrently
resolving type metadata on other threads, this causes a bad pointer
dereference crash in `_dispatch_event_loop_drain`. The new approach uses
a `while` loop calling `availableData` (blocks until data arrives,
returns empty `Data` at EOF), completely avoiding the problematic
Foundation/ObjC bridging code paths.

## New/existing dependencies impact assessment, if applicable
No new dependencies were added to this change.

## Conventional Commits
`fix: replace FileHandle.readabilityHandler with manual read loop in
AWSLambdaPackager plugin`

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

---------

Co-authored-by: Sebastien Stormacq <stormacq@amazon.lu>
2026-02-17 08:52:43 +01:00
Sébastien StormacqandSebastien Stormacq 4a917a74de Fix crash on Linux when testing the archive plugin (#641)
Fix a rare crash in CI on the archive plugin.

The crash is a race condition in `PluginUtils.swift`'s execute method.
The code set a `terminationHandler` on the `Process` that called
`readToEnd()` on the pipe, while simultaneously the `readabilityHandler`
could still be firing on the same pipe's file handle. On Linux (x86_64,
Ubuntu 24.04 in CI), this race corrupts memory during Swift runtime
metadata resolution (`swift_conformsToProtocol,
_swift_getGenericMetadata`), which manifests as the `SIGSEGV` we're
seeing in `_dispatch_event_loop_drain`.

The fix:

I removed the `terminationHandler` entirely. Since `waitUntilExit()` is
already called synchronously, we know the process is done.
After `waitUntilExit()`, we set `readabilityHandler = nil` to stop the
async reads, then do one final `readToEnd()` on the output queue to
drain any remaining data.
This eliminates the race between the readability handler and the
termination handler competing over the same file handle.

Co-authored-by: Sebastien Stormacq <stormacq@amazon.lu>
2026-02-16 12:18:11 +01:00
Sébastien StormacqandSebastien Stormacq e58d89148c Replace standard documents and processes with AWS ones (#574)
- Adjust notice, security reporting, code of conduct, contribution
process to the standard AWS documents
- Adjust GitHub issue templates to AWS standard ones.
- Adjust the license header in all source files

---------

Co-authored-by: Sebastien Stormacq <stormacq@amazon.lu>
2025-10-21 23:27:30 +02:00
Sébastien StormacqandSebastien Stormacq dee635267b change references from /swift-server to /awslabs (#591)
Change Examples, README, and doc to refer to https://github.org/awslabs
instead of https://github.org/swift-server

---------

Co-authored-by: Sebastien Stormacq <stormacq@amazon.lu>
2025-10-17 16:46:58 +02:00
Sébastien Stormacq bf2385ae08 Plugin v2 proposal (#448)
A proposal for a new set of SwiftPM plugins to facilitate the
scaffolding, build, archive, and deployment of Lambda functions.

This is a call for comments to finalize the design before starting an
actual implementation
2025-07-02 14:20:37 +02:00
Sébastien Stormacq 7322a3694a [plugin] Fix #505 : resources are not included in the archive on Linux (#506)
Resources are not included in the archive on Linux
 https://github.com/swift-server/swift-aws-lambda-runtime/issues/505

In addition, the script that checks if the resources are correctly
included in an archive when building on Linux is not working.
It failed to detected missing resources.

This patch fix both the plugin and the  CI script
2025-03-17 11:24:07 +01:00
mattcorey 64b417926d Instructions for customizing the output path are incorrect (#484)
Instructions for customizing the output path are incorrect

### Motivation:

`displayHelpMessage` was incorrect - it claimed that the output path was
customizable via a `--output-directory` flag, but the code actually
looks for `--output-path`

### Modifications:

Changing the help message here, instead of the code, in case existing
projects already depend on `--output-path`

### Result:

`displayHelpMessage` will show the correct instructions
2025-02-26 23:42:27 +01:00
Sébastien Stormacq 71d49b049e [plugin] support for resources packaging on ubuntu (#467)
When including resources in the package and packaging on Ubuntu,
`FileManager` throws a FilePermission error. The docker daemon runs as
root and files to be copied are owned by `root` while the archiver runs
as the current user (`ubuntu` on EC2 Ubuntu). The `FileManager` manages
to copy the files but throws an error after the copy. We suspect the
`FileManager` to perform some kind of operation after the copy and it
fails because of the `root` permission of the files.

See
https://github.com/swift-server/swift-aws-lambda-runtime/issues/449#issuecomment-2595978246
for a description of the problem.

This PR contains code to reproduce the problem, a very simple
workaround, and an integration test.
The workaround consists of 
- trapping all errors
- verify if the error is the permission error (Code = 513)
- verify if the files have been copied or not 
- if the two above conditions are met, ignore the error, otherwise
re-throw it

I would rather prefer a solution that solves the root cause rather than
just ignoring the error.
We're still investigating the root cause (see [this
thread](https://forums.swift.org/t/filemanager-copyitem-on-linux-fails-after-copying-the-files/77282)
on the Swift Forum and this issue on Swift Foundation
https://github.com/swiftlang/swift-foundation/issues/1125
2025-01-21 08:06:51 +01:00
Sébastien StormacqandTim Condon c22f5271a0 add HelloJSON example + README (#424)
* add HelloJSON example + README

* multiple corrections of typos and grammatical errors

Co-authored-by: Tim Condon <0xTim@users.noreply.github.com>
2024-11-13 13:53:19 +01:00
Sébastien Stormacq 4992ba5bd8 change flag name from --allow-network-access to --allow-network-connections as documented by SPM (#407) 2024-10-18 14:51:23 +02:00
Sébastien Stormacq fc65c3cc42 Fix https://github.com/swift-server/swift-aws-lambda-runtime/issues/409
Direct use of executable URL
2024-10-12 00:24:55 +02:00
Sébastien Stormacq e5b120db67 change logging of process URL 2024-10-11 23:51:38 +02:00
Sébastien Stormacq 4ef50757a1 Increase verbosity when asked (#408)
Add verbose logging on docker pull action when --verbose flag is on
2024-10-11 23:35:32 +02:00
Sébastien StormacqandFabian Fett bb9ddfb555 do not force unwrap stdout (#398)
* do not force unwrap

Revert a change from #d2bd7f1aae1fc9455b208567ba5d85e42463c82c that caused the plugin to crash

* test stdout for nil

---------

Co-authored-by: Fabian Fett <fabianfett@apple.com>
2024-10-10 11:31:14 +02:00
Fabian Fett d2bd7f1aae Fix docs CI (#392) 2024-10-08 17:46:53 +02:00
Sébastien Stormacq f7584d1257 add docker fine grained permission to the plugin (#391)
* add docker fine grained permission to the plugin

* swift-format
2024-10-08 14:10:53 +02:00
Sébastien Stormacq 6660c99abf fix local deps in plugin (#389)
* fix local deps in plugin

* swift format
2024-10-08 12:19:23 +02:00
Jack RosenandSébastien Stormacq 426e658414 Add Support For Copying All Resources Into Final Executable (#386)
* Add Support For Copying All Resources Into Final Executable

* Run formatter

---------

Co-authored-by: Sébastien Stormacq <sebastien.stormacq@gmail.com>
2024-10-08 10:43:17 +02:00
Sébastien Stormacq 8131a83bf2 apply swift-format (#380)
* apply swift-format

* use swift-format script from swift-nio project
2024-09-30 22:28:27 +02:00
Fabian Fett 06936fefa4 Name executable bootstrap, don't create symlink (#383) 2024-09-30 17:27:21 +02:00
Sébastien Stormacq 62274444b5 add help option on archiver plugin (#368) 2024-09-30 14:31:46 +02:00
Sébastien Stormacq 0af509b243 Fix deprecation warning for Plugin's Path (#363) 2024-09-06 14:54:42 +02:00
aryan-25 f32987422c Require Swift 6 (#341)
* Require Swift 6
* Apply formatter
* Disable 5.8, 5.9, and 5.10 checks
* Remove -warnings-as-errors for now
* Ensure plugin compiles in Swift 6 language mode
2024-08-28 11:10:15 +02:00
ab8166a39d [CI] Add GHA CI and release flow (#340)
Co-authored-by: Fabian Fett <fabianfett@apple.com>
Co-authored-by: Sébastien Stormacq <sebastien.stormacq@gmail.com>
Co-authored-by: Mahdi Bahrami <github@mahdibm.com>
2024-08-26 16:36:07 +02:00
Camden FullmerandSébastien Stormacq 35e0919ed2 Add support for resources when packaging using the SwiftPM plugin (#333)
* Add support for resources when packaging using the SwiftPM plugin.

* Copy the resources directory to the working directory instead of recreating the directroy structure.

* Add resource packaging example.

* Use the bundle's url function to locate the file url.

* Fix year for soundness check.

---------

Co-authored-by: Sébastien Stormacq <sebastien.stormacq@gmail.com>
2024-08-05 17:51:21 +02:00
Sébastien Stormacq 872183bbe9 allow compilation with the static linux sdk (musl) (#331) 2024-06-26 10:09:25 +02:00
Sven A. Schmidt 0d4716d30c Fix compile error on Windows (#328) 2024-06-19 18:29:40 +02:00
Sébastien Stormacq 294d06bfd4 Use LAMBDA_USE_LOCAL_DEPS env var in local builds with docker (#325) 2024-05-22 14:55:42 +02:00
Florent Morin 2c3b2451db Add --disable-docker-image-update plugin flag (#311)
motivation: sometimes, you need to use a customized local docker image and `docker pull` don’t have to be called

changes:
* add `--disable-docker-image-update` plugin flag to disable `docker pull` call
2023-12-01 11:27:41 -08:00
81f8d27365 packaging plugin (#254)
motivation: add an easy wasy for lambda users to package their lambda and upload it to AWS

changes:
* add SwiftPM plugin to package the lambda as zipfile, with the verb "archive"
* use docker to build and package the lambda(s) on macOS and non-amazonlinux
* build directly on when on amazonlinux, zip correctly

Co-authored-by: Yim Lee <yim_lee@apple.com>
Co-authored-by: Fabian Fett <fabianfett@apple.com>
2022-06-01 09:41:05 -07:00