Skip to content

Commit 489b235

Browse files
authored
CI/CD fixes (#994)
* chore(lambda_runtime): fix clippy by boxing large service future variant that models LambdaInvocation->LambdaEvent processing failures * fix(ci/cd): build but do not execute tests in `build integration tests` step
1 parent 00fef2c commit 489b235

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

.github/actions/rust-build/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ inputs:
77
toolchain:
88
required: true
99
description: "the Rust toolchain to use"
10+
run-tests:
11+
required: true
12+
default: true
13+
description: "whether to run tests in addition to building"
1014

1115
runs:
1216
using: "composite"
@@ -22,5 +26,6 @@ runs:
2226
run: cargo build --all-features --verbose --package ${{ inputs.package }}
2327

2428
- name: Run tests
29+
if: ${{ inputs.run-tests == 'true' }}
2530
shell: bash
2631
run: cargo test --all-features --verbose --package ${{ inputs.package }}

.github/workflows/build-integration-test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ jobs:
3535
with:
3636
package: lambda-integration-tests
3737
toolchain: ${{ matrix.toolchain}}
38+
# the tests will generally fail in ci since they make a network call to a real endpoint,
39+
# this step is just designed to make sure they build successfully
40+
run-tests: false

lambda-runtime/src/layers/api_response.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ where
8585
#[cfg(debug_assertions)]
8686
if req.parts.status.is_server_error() {
8787
error!("Lambda Runtime server returned an unexpected error");
88-
return RuntimeApiResponseFuture::Ready(Some(Err(req.parts.status.to_string().into())));
88+
return RuntimeApiResponseFuture::Ready(Box::new(Some(Err(req.parts.status.to_string().into()))));
8989
}
9090

9191
// Utility closure to propagate potential error from conditionally executed trace
@@ -98,22 +98,23 @@ where
9898
};
9999
if let Err(err) = trace_fn() {
100100
error!(error = ?err, "Failed to parse raw JSON event received from Lambda. The handler will not be called. Log at TRACE level to see the payload.");
101-
return RuntimeApiResponseFuture::Ready(Some(Err(err)));
101+
return RuntimeApiResponseFuture::Ready(Box::new(Some(Err(err))));
102102
};
103103

104104
let request_id = req.context.request_id.clone();
105105
let lambda_event = match deserializer::deserialize::<EventPayload>(&req.body, req.context) {
106106
Ok(lambda_event) => lambda_event,
107107
Err(err) => match build_event_error_request(&request_id, err) {
108-
Ok(request) => return RuntimeApiResponseFuture::Ready(Some(Ok(request))),
108+
Ok(request) => return RuntimeApiResponseFuture::Ready(Box::new(Some(Ok(request)))),
109109
Err(err) => {
110110
error!(error = ?err, "failed to build error response for Lambda Runtime API");
111-
return RuntimeApiResponseFuture::Ready(Some(Err(err)));
111+
return RuntimeApiResponseFuture::Ready(Box::new(Some(Err(err))));
112112
}
113113
},
114114
};
115115

116-
// Once the handler input has been generated successfully, the
116+
// Once the handler input has been generated successfully, pass it through to inner services
117+
// allowing processing both before reaching the handler function and after the handler completes.
117118
let fut = self.inner.call(lambda_event);
118119
RuntimeApiResponseFuture::Future(fut, request_id, PhantomData)
119120
}
@@ -141,7 +142,10 @@ pub enum RuntimeApiResponseFuture<F, Response, BufferedResponse, StreamingRespon
141142
StreamError,
142143
)>,
143144
),
144-
Ready(Option<Result<http::Request<Body>, BoxError>>),
145+
/// This variant is used in case the invocation fails to be processed into an event.
146+
/// We box it to avoid bloating the size of the more likely variant, which is
147+
/// the future that drives event processing.
148+
Ready(Box<Option<Result<http::Request<Body>, BoxError>>>),
145149
}
146150

147151
impl<F, Response, BufferedResponse, StreamingResponse, StreamItem, StreamError> Future

0 commit comments

Comments
 (0)