Skip to content

Commit c99378b

Browse files
authored
Merge changes for v1.19 release
- Update to Go 1.22 - Allow user-defined client context - Refactor test cases - Add workflow for automated releases
2 parents 25a2eac + d37e08c commit c99378b

File tree

8 files changed

+298
-157
lines changed

8 files changed

+298
-157
lines changed

.github/workflows/integ-tests.yml

+33-5
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,44 @@ on:
66
- develop
77

88
jobs:
9-
integ-tests:
9+
go-tests:
1010
runs-on: ubuntu-latest
1111
environment:
12-
name: prod
12+
name: integ-tests
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: run go tests
16+
run: make tests-with-docker
17+
integ-tests-x86:
18+
runs-on: ubuntu-latest
19+
environment:
20+
name: integ-tests
21+
steps:
22+
- uses: actions/checkout@v4
23+
- uses: actions/setup-python@v5
24+
with:
25+
python-version: '3.11'
26+
- name: run integration tests
27+
run: make integ-tests-with-docker-x86-64
28+
integ-tests-arm64:
29+
runs-on: ubuntu-latest
30+
environment:
31+
name: integ-tests
32+
steps:
33+
- uses: actions/checkout@v4
34+
- uses: actions/setup-python@v5
35+
with:
36+
python-version: '3.11'
37+
- name: run integration tests
38+
run: make integ-tests-with-docker-arm64
39+
integ-tests-old:
40+
runs-on: ubuntu-latest
41+
environment:
42+
name: integ-tests
1343
steps:
1444
- uses: actions/checkout@v4
1545
- uses: actions/setup-python@v5
1646
with:
1747
python-version: '3.11'
18-
- name: allows us to build arm64 images
19-
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
2048
- name: run integration tests
21-
run: make integ-tests-with-docker
49+
run: make integ-tests-with-docker-old

.github/workflows/release.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
releaseVersion:
7+
description: "Version to use for the release."
8+
required: true
9+
default: "X.Y"
10+
releaseBody:
11+
description: "Information about the release"
12+
required: true
13+
default: "New release"
14+
jobs:
15+
Release:
16+
environment: Release
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
ref: main
22+
- name: Set up python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: '3.11'
26+
- name: Build
27+
run: make compile-with-docker-all
28+
- name: Run Integ Tests
29+
run: |
30+
make tests-with-docker
31+
make integ-tests
32+
- name: Release
33+
uses: softprops/action-gh-release@v2
34+
with:
35+
name: Release ${{ github.event.inputs.releaseVersion }}
36+
tag_name: v${{ github.event.inputs.releaseVersion }}
37+
body: ${{ github.event.inputs.releaseBody }}
38+
files: |
39+
bin/aws-lambda-rie
40+
bin/aws-lambda-rie-arm64
41+
bin/aws-lambda-rie-x86_64

Makefile

+36-7
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,64 @@ DESTINATION_old:= bin/${BINARY_NAME}
1010
DESTINATION_x86_64 := bin/${BINARY_NAME}-x86_64
1111
DESTINATION_arm64 := bin/${BINARY_NAME}-arm64
1212

13+
run_in_docker = docker run --env GOPROXY=direct -v $(shell pwd):/LambdaRuntimeLocal -w /LambdaRuntimeLocal golang:1.22 $(1)
14+
1315
compile-with-docker-all:
14-
make ARCH=x86_64 compile-with-docker
15-
make ARCH=arm64 compile-with-docker
16-
make ARCH=old compile-with-docker
16+
$(call run_in_docker, make compile-lambda-linux-all)
1717

1818
compile-lambda-linux-all:
1919
make ARCH=x86_64 compile-lambda-linux
2020
make ARCH=arm64 compile-lambda-linux
2121
make ARCH=old compile-lambda-linux
2222

2323
compile-with-docker:
24-
docker run --env GOPROXY=direct -v $(shell pwd):/LambdaRuntimeLocal -w /LambdaRuntimeLocal golang:1.21 make ARCH=${ARCH} compile-lambda-linux
24+
$(call run_in_docker, make ARCH=${ARCH} compile-lambda-linux)
2525

2626
compile-lambda-linux:
2727
CGO_ENABLED=0 GOOS=linux GOARCH=${GO_ARCH_${ARCH}} go build -buildvcs=false -ldflags "${RELEASE_BUILD_LINKER_FLAGS}" -o ${DESTINATION_${ARCH}} ./cmd/aws-lambda-rie
2828

29+
tests-with-docker:
30+
$(call run_in_docker, make tests)
31+
2932
tests:
3033
go test ./...
3134

3235
integ-tests-and-compile: tests
3336
make compile-lambda-linux-all
3437
make integ-tests
3538

36-
integ-tests-with-docker: tests
39+
integ-tests-with-docker: tests-with-docker
3740
make compile-with-docker-all
3841
make integ-tests
39-
40-
integ-tests:
42+
43+
prep-python:
4144
python3 -m venv .venv
4245
.venv/bin/pip install --upgrade pip
4346
.venv/bin/pip install requests parameterized
47+
48+
exec-python-e2e-test:
4449
.venv/bin/python3 test/integration/local_lambda/test_end_to_end.py
50+
51+
integ-tests:
52+
make prep-python
53+
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
54+
make TEST_ARCH=x86_64 TEST_PORT=8002 exec-python-e2e-test
55+
make TEST_ARCH=arm64 TEST_PORT=9002 exec-python-e2e-test
56+
make TEST_ARCH="" TEST_PORT=9052 exec-python-e2e-test
57+
58+
integ-tests-with-docker-x86-64:
59+
make ARCH=x86_64 compile-with-docker
60+
make prep-python
61+
make TEST_ARCH=x86_64 TEST_PORT=8002 exec-python-e2e-test
62+
63+
integ-tests-with-docker-arm64:
64+
make ARCH=arm64 compile-with-docker
65+
make prep-python
66+
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
67+
make TEST_ARCH=arm64 TEST_PORT=9002 exec-python-e2e-test
68+
69+
integ-tests-with-docker-old:
70+
make ARCH=old compile-with-docker
71+
make prep-python
72+
make TEST_ARCH="" TEST_PORT=9052 exec-python-e2e-test
73+

cmd/aws-lambda-rie/handlers.go

+9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package main
55

66
import (
77
"bytes"
8+
"encoding/base64"
89
"fmt"
910
"io/ioutil"
1011
"math"
@@ -81,6 +82,13 @@ func InvokeHandler(w http.ResponseWriter, r *http.Request, sandbox Sandbox, bs i
8182
return
8283
}
8384

85+
rawClientContext, err := base64.StdEncoding.DecodeString(r.Header.Get("X-Amz-Client-Context"))
86+
if err != nil {
87+
log.Errorf("Failed to decode X-Amz-Client-Context: %s", err)
88+
w.WriteHeader(500)
89+
return
90+
}
91+
8492
initDuration := ""
8593
inv := GetenvWithDefault("AWS_LAMBDA_FUNCTION_TIMEOUT", "300")
8694
timeoutDuration, _ := time.ParseDuration(inv + "s")
@@ -114,6 +122,7 @@ func InvokeHandler(w http.ResponseWriter, r *http.Request, sandbox Sandbox, bs i
114122
TraceID: r.Header.Get("X-Amzn-Trace-Id"),
115123
LambdaSegmentID: r.Header.Get("X-Amzn-Segment-Id"),
116124
Payload: bytes.NewReader(bodyBytes),
125+
ClientContext: string(rawClientContext),
117126
}
118127
fmt.Println("START RequestId: " + invokePayload.ID + " Version: " + functionVersion)
119128

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module go.amzn.com
22

3-
go 1.21
3+
go 1.22
44

55
require (
66
github.com/aws/aws-lambda-go v1.46.0

0 commit comments

Comments
 (0)