Skip to content

How to test locally (macOS, Xcode or command line)? #413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jpenwith opened this issue Oct 18, 2024 · 9 comments
Closed

How to test locally (macOS, Xcode or command line)? #413

jpenwith opened this issue Oct 18, 2024 · 9 comments

Comments

@jpenwith
Copy link

Expected behavior

I can't see how to test locally on the README?

Some documentation suggests setting LOCAL_LAMBDA_SERVER_ENABLED in ENV, so I tried this

Actual behavior

The process exits with a missingLambdaRuntimeAPIEnvironmentVariable error

Steps to reproduce

  1. Follow the steps in https://github.com/swift-server/swift-aws-lambda-runtime/blob/main/readme.md
  2. Either open in Xcode and set LOCAL_LAMBDA_SERVER_ENABLED to true in the scheme editor, then run
  3. Or do LOCAL_LAMBDA_SERVER_ENABLED=true swift run

If possible, minimal yet complete reproducer code (or URL to code)

No response

What version of this project (swift-aws-lambda-runtime) are you using?

latest main

Swift version

swift-driver version: 1.115 Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)
Target: arm64-apple-macosx15.0
Darwin Firebolt 24.0.0 Darwin Kernel Version 24.0.0: Tue Sep 24 23:38:45 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T8122 arm64

Amazon Linux 2 docker image version

No response

@sebsto
Copy link
Contributor

sebsto commented Oct 22, 2024

Hello @jpenwith
When using the version from the main branch, you're using the runtime v2 and the local server is not implemented yet.

If you want to test locally, you can develop against the latest release / branch v1.0.0-alpha.3

We are in the process of updating the doc. The README you mentioned has no references to LOCAL_LAMBDA_SERVER_ENABLED

@jpenwith
Copy link
Author

Thanks for explaining. I wanted to use main because I couldn’t get swift package archive to work on earlier releases

@sebsto
Copy link
Contributor

sebsto commented Oct 22, 2024

mmmh swift package archive should work with 1.0.0-alpha.3 release. The flag to authorize network connections is a bit different though.

swift package archive --disable-sandbox

You can read the v1 version of the README on the v1 branch and the v1 doc on the Swift Package Index

I know this is confusing, bear with us while we update the doc in the coming weeks.

@sebsto
Copy link
Contributor

sebsto commented Oct 22, 2024

Note you can follow this issue to track progress
#369

The behaviour will be a bit different than in V1. When the runtime does not find the typical env variable setup by the Lambda microVM, the local web server will be started by default.

@jpenwith
Copy link
Author

Thanks very much, really appreciate you explaining 👍

@sebsto
Copy link
Contributor

sebsto commented Nov 7, 2024

I'm closing this, feel free to re-open if you feel your question is not addressed

@sebsto sebsto closed this as completed Nov 7, 2024
@sebsto
Copy link
Contributor

sebsto commented Nov 13, 2024

@jpenwith #426 is under review
Once approved and merged, you can simply use swift run on your project to start the local HTTP server

@sebsto
Copy link
Contributor

sebsto commented Nov 14, 2024

Hello @jpenwith
You can now try the local testing. No need to set an environment variable, just type swift run
https://github.com/swift-server/swift-aws-lambda-runtime?tab=readme-ov-file#testing-locally

@jpenwith
Copy link
Author

Thanks @sebsto, that's fantastic, really appreciate it 👍

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

No branches or pull requests

2 participants