Skip to content

Commit b27a98a

Browse files
authored
Merge branch 'main' into ff-platform-dance
2 parents 3c5d217 + 23da9bf commit b27a98a

26 files changed

+115
-33
lines changed

.devcontainer/devcontainer.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "Swift",
3+
"image": "swift:6.0",
4+
"features": {
5+
"ghcr.io/devcontainers/features/common-utils:2": {
6+
"installZsh": "false",
7+
"username": "vscode",
8+
"upgradePackages": "false"
9+
},
10+
"ghcr.io/devcontainers/features/git:1": {
11+
"version": "os-provided",
12+
"ppa": "false"
13+
}
14+
},
15+
"runArgs": [
16+
"--cap-add=SYS_PTRACE",
17+
"--security-opt",
18+
"seccomp=unconfined"
19+
],
20+
// Configure tool-specific properties.
21+
"customizations": {
22+
// Configure properties specific to VS Code.
23+
"vscode": {
24+
// Set *default* container specific settings.json values on container create.
25+
"settings": {
26+
"lldb.library": "/usr/lib/liblldb.so"
27+
},
28+
// Add the IDs of extensions you want installed when the container is created.
29+
"extensions": [
30+
"sswg.swift-lang"
31+
]
32+
}
33+
},
34+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
35+
// "forwardPorts": [],
36+
37+
// Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
38+
"remoteUser": "vscode"
39+
}

.github/release.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ changelog:
55
- ⚠️ semver/major
66
- title: SemVer Minor
77
labels:
8-
- semver/minor
8+
- 🆕 semver/minor
99
- title: SemVer Patch
1010
labels:
11-
- semver/patch
11+
- 🔨 semver/patch
1212
- title: Other Changes
1313
labels:
1414
- semver/none
15-
- "*"

.github/workflows/pull_request.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ jobs:
1010
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
1111
with:
1212
license_header_check_project_name: "SwiftAWSLambdaRuntime"
13-
shell_check_enabled: false
14-
python_lint_check_enabled: false
13+
shell_check_enabled: true
14+
python_lint_check_enabled: true
1515
api_breakage_check_container_image: "swift:6.0-noble"
1616
docs_check_container_image: "swift:6.0-noble"
1717
format_check_container_image: "swiftlang/swift:nightly-6.0-jammy"
18+
yamllint_check_enabled: true
1819

1920
unit-tests:
2021
name: Unit tests
@@ -43,6 +44,18 @@ jobs:
4344
name: Swift 6 Language Mode
4445
uses: apple/swift-nio/.github/workflows/swift_6_language_mode.yml@main
4546

47+
semver-label-check:
48+
name: Semantic Version label check
49+
runs-on: ubuntu-latest
50+
timeout-minutes: 1
51+
steps:
52+
- name: Checkout repository
53+
uses: actions/checkout@v4
54+
with:
55+
persist-credentials: false
56+
- name: Check for Semantic Version label
57+
uses: apple/swift-nio/.github/actions/pull_request_semver_label_checker@main
58+
4659
# until there is a support for musl in swiftlang/github-workflows
4760
# https://github.com/swiftlang/github-workflows/issues/34
4861
musl:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
# shellcheck disable=all
12
# Create a project directory
23
mkdir SquareNumber && cd SquareNumber

Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-01-02-package-init.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# shellcheck disable=all
12
# Create a project directory
23
mkdir SquareNumber && cd SquareNumber
34
# create a skeleton project

Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-01-03-package-init.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# shellcheck disable=all
12
# Create a project directory
23
mkdir SquareNumber && cd SquareNumber
34
# create a skeleton project

Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-01-04-package-init.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# shellcheck disable=all
12
# Create a project directory
23
mkdir SquareNumber && cd SquareNumber
34
# create a skeleton project

Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-04-03-console-output.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# shellcheck disable=all
2+
13
2023-04-14T11:42:21+0200 info LocalLambdaServer : [AWSLambdaRuntimeCore] LocalLambdaServer started and listening on 127.0.0.1:7000, receiving events on /invoke
24
2023-04-14T11:42:21+0200 info Lambda : [AWSLambdaRuntimeCore] lambda runtime starting with LambdaConfiguration
35
General(logLevel: info))

Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-04-04-curl.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# shellcheck disable=all
2+
13
curl --header "Content-Type: application/json" \
24
--request POST \
35
--data '{"number": 3}' \

Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-04-05-curl.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# shellcheck disable=all
2+
13
curl --header "Content-Type: application/json" \
24
--request POST \
35
--data '{"number": 3}' \
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
export LOCAL_LAMBDA_SERVER_ENABLED=true
1+
# shellcheck disable=all
22

3+
export LOCAL_LAMBDA_SERVER_ENABLED=true
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
# shellcheck disable=all
2+
13
export LOCAL_LAMBDA_SERVER_ENABLED=true
24
swift run

Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-04-08-terminal.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# shellcheck disable=all
2+
13
export LOCAL_LAMBDA_SERVER_ENABLED=true
24
swift run
35

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
# shellcheck disable=all
2+
13
swift package archive --allow-network-connections docker
24

Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-01-03-plugin-archive.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# shellcheck disable=all
2+
13
swift package archive --allow-network-connections docker
24

35
-------------------------------------------------------------------------

Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-01-04-plugin-archive.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# shellcheck disable=all
2+
13
swift package archive --allow-network-connections docker
24

35
-------------------------------------------------------------------------
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
# shellcheck disable=all
2+
13
aws --version

Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-03-02-lambda-invoke-hidden.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# shellcheck disable=all
2+
13
#
24
# --region the AWS Region to send the command
35
# --function-name the name of your function

Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-03-02-lambda-invoke.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# shellcheck disable=all
2+
13
#
24
# --region the AWS Region to send the command
35
# --function-name the name of your function

Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-03-03-lambda-invoke.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# shellcheck disable=all
2+
13
#
24
# --region the AWS Region to send the command
35
# --function-name the name of your function

Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-03-04-lambda-invoke.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# shellcheck disable=all
2+
13
#
24
# --region the AWS Region to send the command
35
# --function-name the name of your function

Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-03-05-lambda-invoke.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# shellcheck disable=all
2+
13
#
24
# --region the AWS Region to send the command
35
# --function-name the name of your function

Sources/AWSLambdaRuntimeCore/LambdaRuntime.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ public final class LambdaRuntime<Handler>: @unchecked Sendable where Handler: St
3939
// this approach is less flexible but more performant than reading the value of the environment variable at each invocation
4040
var log = logger
4141
log.logLevel = Lambda.env("LOG_LEVEL").flatMap(Logger.Level.init) ?? .info
42-
self.logger = logger
42+
self.logger = log
43+
self.logger.debug("LambdaRuntime initialized")
4344
}
4445

4546
public func run() async throws {

scripts/integration_tests.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,10 @@ fatal() { error "$@"; exit 1; }
2222
test -n "${SWIFT_VERSION:-}" || fatal "SWIFT_VERSION unset"
2323
test -n "${COMMAND:-}" || fatal "COMMAND unset"
2424
test -n "${EXAMPLE:-}" || fatal "EXAMPLE unset"
25-
swift_version="$SWIFT_VERSION"
26-
command="$COMMAND"
27-
example="$EXAMPLE"
2825

29-
pushd Examples/"$example" > /dev/null
26+
pushd Examples/"$EXAMPLE" > /dev/null
3027

3128
log "Running command with Swift $SWIFT_VERSION"
32-
eval "$command"
29+
eval "$COMMAND"
3330

3431
popd

scripts/linux_performance_setup.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ apt-get install -y vim htop strace linux-tools-common linux-tools-generic libc6-
2020

2121
echo 0 > /proc/sys/kernel/kptr_restrict
2222

23-
cd /usr/bin
23+
pushd /usr/bin || exit 1
2424
rm -rf perf
2525
ln -s /usr/lib/linux-tools/*/perf perf
26-
cd -
26+
popd || exit 1
2727

28-
cd /opt
28+
pushd /opt || exit 1
2929
git clone https://github.com/brendangregg/FlameGraph.git
30-
cd -
30+
popd || exit 1
3131

3232
# build the code in relase mode with debug symbols
3333
# swift build -c release -Xswiftc -g

scripts/performance_test.sh

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ if [[ $(uname -s) == "Linux" ]]; then
2727
fi
2828

2929
swift build -c release -Xswiftc -g
30-
swift build --package-path Examples/Echo -c release -Xswiftc -g
31-
swift build --package-path Examples/JSON -c release -Xswiftc -g
30+
LAMBDA_USE_LOCAL_DEPS=../.. swift build --package-path Examples/HelloWorld -c release -Xswiftc -g
31+
LAMBDA_USE_LOCAL_DEPS=../.. swift build --package-path Examples/HelloJSON -c release -Xswiftc -g
3232

3333
cleanup() {
3434
kill -9 $server_pid # ignore-unacceptable-language
@@ -58,24 +58,24 @@ kill -0 $server_pid # check server is alive # ignore-unacceptable-language
5858
echo "running $MODE mode cold test"
5959
cold=()
6060
export MAX_REQUESTS=1
61-
for (( i=0; i<$cold_iterations; i++ )); do
61+
for (( i=0; i<cold_iterations; i++ )); do
6262
start=$(gdate +%s%N)
63-
./Examples/Echo/.build/release/MyLambda
63+
./Examples/HelloWorld/.build/release/MyLambda
6464
end=$(gdate +%s%N)
65-
cold+=( $(($end-$start)) )
65+
cold+=( $((end-start)) )
6666
done
6767
sum_cold=$(IFS=+; echo "$((${cold[*]}))")
68-
avg_cold=$(($sum_cold/$cold_iterations))
68+
avg_cold=$((sum_cold/cold_iterations))
6969
results+=( "$MODE, cold: $avg_cold (ns)" )
7070

7171
# normal calls
7272
echo "running $MODE mode warm test"
7373
export MAX_REQUESTS=$warm_iterations
7474
start=$(gdate +%s%N)
75-
./Examples/Echo/.build/release/MyLambda
75+
./Examples/HelloWorld/.build/release/MyLambda
7676
end=$(gdate +%s%N)
77-
sum_warm=$(($end-$start-$avg_cold)) # substract by avg cold since the first call is cold
78-
avg_warm=$(($sum_warm/($warm_iterations-1))) # substract since the first call is cold
77+
sum_warm=$((end-start-avg_cold)) # substract by avg cold since the first call is cold
78+
avg_warm=$((sum_warm/(warm_iterations-1))) # substract since the first call is cold
7979
results+=( "$MODE, warm: $avg_warm (ns)" )
8080

8181
#------------------
@@ -96,32 +96,32 @@ kill -0 $server_pid # check server is alive # ignore-unacceptable-language
9696
echo "running $MODE mode cold test"
9797
cold=()
9898
export MAX_REQUESTS=1
99-
for (( i=0; i<$cold_iterations; i++ )); do
99+
for (( i=0; i<cold_iterations; i++ )); do
100100
start=$(gdate +%s%N)
101-
./Examples/JSON/.build/release/MyLambda
101+
./Examples/HelloJSON/.build/release/MyLambda
102102
end=$(gdate +%s%N)
103-
cold+=( $(($end-$start)) )
103+
cold+=( $((end-start)) )
104104
done
105105
sum_cold=$(IFS=+; echo "$((${cold[*]}))")
106-
avg_cold=$(($sum_cold/$cold_iterations))
106+
avg_cold=$((sum_cold/cold_iterations))
107107
results+=( "$MODE, cold: $avg_cold (ns)" )
108108

109109
# normal calls
110110
echo "running $MODE mode warm test"
111111
export MAX_REQUESTS=$warm_iterations
112112
start=$(gdate +%s%N)
113-
./Examples/JSON/.build/release/MyLambda
113+
./Examples/HelloJSON/.build/release/MyLambda
114114
end=$(gdate +%s%N)
115-
sum_warm=$(($end-$start-$avg_cold)) # substract by avg cold since the first call is cold
116-
avg_warm=$(($sum_warm/($warm_iterations-1))) # substract since the first call is cold
115+
sum_warm=$((end-start-avg_cold)) # substract by avg cold since the first call is cold
116+
avg_warm=$((sum_warm/(warm_iterations-1))) # substract since the first call is cold
117117
results+=( "$MODE, warm: $avg_warm (ns)" )
118118

119119
# print results
120120
echo "-----------------------------"
121121
echo "results"
122122
echo "-----------------------------"
123123
for i in "${results[@]}"; do
124-
echo $i
124+
echo "$i"
125125
done
126126
echo "-----------------------------"
127127

0 commit comments

Comments
 (0)