-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add buildcmd integ test for cargo workspace (#7052)
* add buildcmd integ test for cargo workspace * fix test
- Loading branch information
Showing
7 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
tests/integration/testdata/buildcmd/Rust/cargo_workspace/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[workspace] | ||
resolver = "2" | ||
|
||
members = ["function_a", "function_b"] |
14 changes: 14 additions & 0 deletions
14
tests/integration/testdata/buildcmd/Rust/cargo_workspace/function_a/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "function_a" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
|
||
lambda_runtime = "0.6.0" | ||
serde = "1.0.136" | ||
tokio = { version = "1", features = ["macros"] } | ||
tracing = { version = "0.1", features = ["log"] } | ||
tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt"] } |
49 changes: 49 additions & 0 deletions
49
tests/integration/testdata/buildcmd/Rust/cargo_workspace/function_a/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use lambda_runtime::{run, service_fn, Error, LambdaEvent}; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
/// This is a made-up example. Requests come into the runtime as unicode | ||
/// strings in json format, which can map to any structure that implements `serde::Deserialize` | ||
/// The runtime pays no attention to the contents of the request payload. | ||
#[derive(Deserialize)] | ||
struct Request { | ||
} | ||
|
||
/// This is a made-up example of what a response structure may look like. | ||
/// There is no restriction on what it can be. The runtime requires responses | ||
/// to be serialized into json. The runtime pays no attention | ||
/// to the contents of the response payload. | ||
#[derive(Serialize)] | ||
struct Response { | ||
req_id: String, | ||
msg: String, | ||
} | ||
|
||
/// This is the main body for the function. | ||
/// Write your code inside it. | ||
/// There are some code example in the following URLs: | ||
/// - https://github.com/awslabs/aws-lambda-rust-runtime/tree/main/examples | ||
/// - https://github.com/aws-samples/serverless-rust-demo/ | ||
async fn function_handler(event: LambdaEvent<Request>) -> Result<Response, Error> { | ||
// Prepare the response | ||
let resp = Response { | ||
req_id: "34".to_string(), | ||
msg: "Hello World A".to_string(), | ||
}; | ||
|
||
// Return `Response` (it will be serialized to JSON automatically by the runtime) | ||
Ok(resp) | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Error> { | ||
tracing_subscriber::fmt() | ||
.with_max_level(tracing::Level::INFO) | ||
// disable printing the name of the module in every log line. | ||
.with_target(false) | ||
// disabling time is handy because CloudWatch will add the ingestion time. | ||
.without_time() | ||
.init(); | ||
|
||
run(service_fn(function_handler)).await | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/integration/testdata/buildcmd/Rust/cargo_workspace/function_b/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "function_b" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
|
||
lambda_runtime = "0.6.0" | ||
serde = "1.0.136" | ||
tokio = { version = "1", features = ["macros"] } | ||
tracing = { version = "0.1", features = ["log"] } | ||
tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt"] } |
49 changes: 49 additions & 0 deletions
49
tests/integration/testdata/buildcmd/Rust/cargo_workspace/function_b/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use lambda_runtime::{run, service_fn, Error, LambdaEvent}; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
/// This is a made-up example. Requests come into the runtime as unicode | ||
/// strings in json format, which can map to any structure that implements `serde::Deserialize` | ||
/// The runtime pays no attention to the contents of the request payload. | ||
#[derive(Deserialize)] | ||
struct Request { | ||
} | ||
|
||
/// This is a made-up example of what a response structure may look like. | ||
/// There is no restriction on what it can be. The runtime requires responses | ||
/// to be serialized into json. The runtime pays no attention | ||
/// to the contents of the response payload. | ||
#[derive(Serialize)] | ||
struct Response { | ||
req_id: String, | ||
msg: String, | ||
} | ||
|
||
/// This is the main body for the function. | ||
/// Write your code inside it. | ||
/// There are some code example in the following URLs: | ||
/// - https://github.com/awslabs/aws-lambda-rust-runtime/tree/main/examples | ||
/// - https://github.com/aws-samples/serverless-rust-demo/ | ||
async fn function_handler(event: LambdaEvent<Request>) -> Result<Response, Error> { | ||
// Prepare the response | ||
let resp = Response { | ||
req_id: "281".to_string(), | ||
msg: "Hello World B".to_string(), | ||
}; | ||
|
||
// Return `Response` (it will be serialized to JSON automatically by the runtime) | ||
Ok(resp) | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Error> { | ||
tracing_subscriber::fmt() | ||
.with_max_level(tracing::Level::INFO) | ||
// disable printing the name of the module in every log line. | ||
.with_target(false) | ||
// disabling time is handy because CloudWatch will add the ingestion time. | ||
.without_time() | ||
.init(); | ||
|
||
run(service_fn(function_handler)).await | ||
} |
26 changes: 26 additions & 0 deletions
26
tests/integration/testdata/buildcmd/template_build_method_rust_cargo_workspace.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
AWSTemplateFormatVersion : '2010-09-09' | ||
Transform: AWS::Serverless-2016-10-31 | ||
|
||
Parameters: | ||
Runtime: | ||
Type: String | ||
CodeUri: | ||
Type: String | ||
Handler: | ||
Type: String | ||
Architectures: | ||
Type: String | ||
|
||
Resources: | ||
|
||
Function: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
Handler: !Ref Handler | ||
Runtime: !Ref Runtime | ||
CodeUri: !Ref CodeUri | ||
Timeout: 600 | ||
Architectures: | ||
- !Ref Architectures | ||
Metadata: | ||
BuildMethod: rust-cargolambda |