Skip to content

Commit 18eabfc

Browse files
authored
Merge branch 'main' into ff-platform-dance
2 parents 9ea009a + 59dd68a commit 18eabfc

27 files changed

+700
-229
lines changed

.github/ISSUE_TEMPLATE/issue-report.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ body:
1717
attributes:
1818
label: Actual behavior
1919
description: What actually happened
20-
placeholder: Describe
20+
placeholder: Describe
2121
validations:
2222
required: true
2323
- type: textarea
@@ -55,7 +55,7 @@ body:
5555
attributes:
5656
label: Swift version
5757
description: Swift environment version.
58-
placeholder: |
58+
placeholder: |
5959
Open a Terminal and execute the following command
6060
6161
swift --version && uname -a

.github/workflows/examples_matrix.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: ExamplesMatrix
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
name:
7+
type: string
8+
description: "The name of the workflow used for the concurrency group."
9+
required: true
10+
# examples:
11+
# type: sequence
12+
# description: "The examples to run."
13+
# required: true
14+
matrix_linux_command:
15+
type: string
16+
description: "The command of the current Swift version linux matrix job to execute."
17+
required: true
18+
matrix_linux_swift_container_image:
19+
type: string
20+
description: "Container image for the matrix job. Defaults to matching latest Swift Ubuntu image."
21+
default: "swift:amazonlinux2"
22+
23+
## We are cancelling previously triggered workflow runs
24+
concurrency:
25+
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.name }}
26+
cancel-in-progress: true
27+
28+
jobs:
29+
linux:
30+
name: Example/${{ matrix.examples }} on Linux ${{ matrix.swift.swift_version }}
31+
runs-on: ubuntu-latest
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
# This should be passed as an argument in input. Can we pass arrays as argument ?
36+
examples: ["HelloWorld", "APIGateway", "S3_AWSSDK", "S3_Soto"]
37+
# examples: ${{ inputs.examples }}
38+
39+
# We are using only one Swift version
40+
swift:
41+
- image: ${{ inputs.matrix_linux_swift_container_image }}
42+
swift_version: "6.0.1-amazonlinux2"
43+
container:
44+
image: ${{ matrix.swift.image }}
45+
steps:
46+
# GitHub checkout action has a dep on NodeJS 20 which is not running on Amazonlinux2
47+
# workaround is to manually checkout the repository
48+
# https://github.com/actions/checkout/issues/1487
49+
- name: Manually Clone repository and checkout PR
50+
env:
51+
PR_NUMBER: ${{ github.event.pull_request.number }}
52+
run: |
53+
# Clone the repository
54+
git clone https://github.com/${{ github.repository }}
55+
cd ${{ github.event.repository.name }}
56+
57+
# Fetch the pull request
58+
git fetch origin +refs/pull/$PR_NUMBER/merge:
59+
60+
# Checkout the pull request
61+
git checkout -qf FETCH_HEAD
62+
63+
# - name: Checkout repository
64+
# uses: actions/checkout@v4
65+
# with:
66+
# persist-credentials: false
67+
68+
- name: Mark the workspace as safe
69+
working-directory: ${{ github.event.repository.name }} # until we can use action/checkout@v4
70+
# https://github.com/actions/checkout/issues/766
71+
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
72+
73+
- name: Run matrix job
74+
working-directory: ${{ github.event.repository.name }} # until we can use action/checkout@v4
75+
env:
76+
SWIFT_VERSION: ${{ matrix.swift.swift_version }}
77+
COMMAND: ${{ inputs.matrix_linux_command }}
78+
EXAMPLE: ${{ matrix.examples }}
79+
run: |
80+
./scripts/integration_tests.sh

.github/workflows/pull_request.yml

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,39 @@
11
name: PR
22

33
on:
4-
pull_request:
5-
types: [opened, reopened, synchronize]
4+
pull_request:
5+
types: [opened, reopened, synchronize]
66

77
jobs:
8-
soundness:
9-
name: Soundness
10-
uses: apple/swift-nio/.github/workflows/soundness.yml@main
11-
with:
12-
license_header_check_project_name: "SwiftAWSLambdaRuntime"
13-
shell_check_enabled: false
14-
api_breakage_check_container_image: "swift:6.0-noble"
15-
docs_check_container_image: "swift:6.0-noble"
8+
soundness:
9+
name: Soundness
10+
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
11+
with:
12+
license_header_check_project_name: "SwiftAWSLambdaRuntime"
13+
shell_check_enabled: false
14+
api_breakage_check_container_image: "swift:6.0-noble"
15+
docs_check_container_image: "swift:6.0-noble"
16+
format_check_container_image: "swiftlang/swift:nightly-6.0-jammy"
1617

17-
unit-tests:
18-
name: Unit tests
19-
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
20-
with:
21-
linux_5_8_enabled: false
22-
linux_5_9_enabled: false
23-
linux_5_10_enabled: false
24-
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
25-
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
18+
unit-tests:
19+
name: Unit tests
20+
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
21+
with:
22+
linux_5_8_enabled: false
23+
linux_5_9_enabled: false
24+
linux_5_10_enabled: false
25+
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
26+
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
2627

27-
swift-6-language-mode:
28-
name: Swift 6 Language Mode
29-
uses: apple/swift-nio/.github/workflows/swift_6_language_mode.yml@main
28+
integration-tests:
29+
name: Integration Tests
30+
uses: ./.github/workflows/examples_matrix.yml
31+
with:
32+
# We should pass the list of examples here, but we can't pass an array as argument
33+
# examples: [ "HelloWorld", "APIGateway" ]
34+
name: "Integration tests"
35+
matrix_linux_command: "LAMBDA_USE_LOCAL_DEPS=../.. swift build"
36+
37+
swift-6-language-mode:
38+
name: Swift 6 Language Mode
39+
uses: apple/swift-nio/.github/workflows/swift_6_language_mode.yml@main

Examples/APIGateway/Package.swift

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import PackageDescription
44

55
// needed for CI to test the local version of the library
6-
import class Foundation.ProcessInfo
76
import struct Foundation.URL
87

98
#if os(macOS)
@@ -16,17 +15,16 @@ let package = Package(
1615
name: "swift-aws-lambda-runtime-example",
1716
platforms: platforms,
1817
products: [
19-
.executable(name: "APIGAtewayLambda", targets: ["APIGAtewayLambda"])
18+
.executable(name: "APIGatewayLambda", targets: ["APIGatewayLambda"])
2019
],
2120
dependencies: [
22-
// dependency on swift-aws-lambda-runtime is added dynamically below
23-
// .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", branch: "main")
24-
25-
.package(url: "https://github.com/swift-server/swift-aws-lambda-events.git", branch: "main")
21+
// during CI, the dependency on local version of swift-aws-lambda-runtime is added dynamically below
22+
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", branch: "main"),
23+
.package(url: "https://github.com/swift-server/swift-aws-lambda-events.git", branch: "main"),
2624
],
2725
targets: [
2826
.executableTarget(
29-
name: "APIGAtewayLambda",
27+
name: "APIGatewayLambda",
3028
dependencies: [
3129
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"),
3230
.product(name: "AWSLambdaEvents", package: "swift-aws-lambda-events"),
@@ -36,20 +34,29 @@ let package = Package(
3634
]
3735
)
3836

39-
if let localDepsPath = ProcessInfo.processInfo.environment["LAMBDA_USE_LOCAL_DEPS"],
37+
if let localDepsPath = Context.environment["LAMBDA_USE_LOCAL_DEPS"],
4038
localDepsPath != "",
4139
let v = try? URL(fileURLWithPath: localDepsPath).resourceValues(forKeys: [.isDirectoryKey]),
42-
let _ = v.isDirectory
40+
v.isDirectory == true
4341
{
42+
// when we use the local runtime as deps, let's remove the dependency added above
43+
let indexToRemove = package.dependencies.firstIndex { dependency in
44+
if case .sourceControl(
45+
name: _,
46+
location: "https://github.com/swift-server/swift-aws-lambda-runtime.git",
47+
requirement: _
48+
) = dependency.kind {
49+
return true
50+
}
51+
return false
52+
}
53+
if let indexToRemove {
54+
package.dependencies.remove(at: indexToRemove)
55+
}
56+
57+
// then we add the dependency on LAMBDA_USE_LOCAL_DEPS' path (typically ../..)
4458
print("[INFO] Compiling against swift-aws-lambda-runtime located at \(localDepsPath)")
4559
package.dependencies += [
4660
.package(name: "swift-aws-lambda-runtime", path: localDepsPath)
4761
]
48-
49-
} else {
50-
print("[INFO] LAMBDA_USE_LOCAL_DEPS is not pointing to your local swift-aws-lambda-runtime code")
51-
print("[INFO] This project will compile against the main branch of the Lambda Runtime on GitHub")
52-
package.dependencies += [
53-
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", branch: "main")
54-
]
5562
}

Examples/APIGateway/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ swift package archive --allow-network-access docker
2626
```
2727

2828
If there is no error, there is a ZIP file ready to deploy.
29-
The ZIP file is located at `.build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager/MyLambda/MyLambda.zip`
29+
The ZIP file is located at `.build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager/APIGatewayLambda/APIGatewayLambda.zip`
3030

3131
## Deploy
3232

@@ -40,9 +40,9 @@ To actually deploy your Lambda function and create the infrastructure, type the
4040

4141
```bash
4242
sam deploy \
43-
----resolve-s3 \
43+
--resolve-s3 \
4444
--template-file template.yaml \
45-
--stack-name MyLambda \
45+
--stack-name APIGatewayLambda \
4646
--capabilities CAPABILITY_IAM
4747
```
4848

@@ -53,8 +53,8 @@ The output is similar to this one.
5353
-----------------------------------------------------------------------------------------------------------------------------
5454
Outputs
5555
-----------------------------------------------------------------------------------------------------------------------------
56-
Key APIGAtewayEndpoint
57-
Description API Gateway endpoint UR"
56+
Key APIGatewayEndpoint
57+
Description API Gateway endpoint URL"
5858
Value https://a5q74es3k2.execute-api.us-east-1.amazonaws.com
5959
-----------------------------------------------------------------------------------------------------------------------------
6060
```

Examples/APIGateway/template.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ Description: SAM Template for QuoteService
44

55
Resources:
66
# Lambda function
7-
APIGAtewayLambda:
7+
APIGatewayLambda:
88
Type: AWS::Serverless::Function
99
Properties:
10-
CodeUri: .build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager/APIGAtewayLambda/APIGAtewayLambda.zip
10+
CodeUri: .build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager/APIGatewayLambda/APIGatewayLambda.zip
1111
Timeout: 60
12-
Handler: swift.bootstrap
12+
Handler: swift.bootstrap # ignored by the Swift runtime
1313
Runtime: provided.al2
1414
MemorySize: 512
1515
Architectures:
@@ -19,13 +19,13 @@ Resources:
1919
# by default, AWS Lambda runtime produces no log
2020
# use `LOG_LEVEL: debug` for for lifecycle and event handling information
2121
# use `LOG_LEVEL: trace` for detailed input event information
22-
LOG_LEVEL: trace
22+
LOG_LEVEL: debug
2323
Events:
2424
HttpApiEvent:
25-
Type: HttpApi
25+
Type: HttpApi
2626

2727
Outputs:
2828
# print API Gateway endpoint
29-
APIGAtewayEndpoint:
29+
APIGatewayEndpoint:
3030
Description: API Gateway endpoint UR"
3131
Value: !Sub "https://${ServerlessHttpApi}.execute-api.${AWS::Region}.amazonaws.com"

Examples/HelloWorld/Package.swift

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import PackageDescription
44

55
// needed for CI to test the local version of the library
6-
import class Foundation.ProcessInfo
76
import struct Foundation.URL
87

98
#if os(macOS)
@@ -19,8 +18,8 @@ let package = Package(
1918
.executable(name: "MyLambda", targets: ["MyLambda"])
2019
],
2120
dependencies: [
22-
// dependency on swift-aws-lambda-runtime is added dynamically below
23-
// .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", branch: "main")
21+
// during CI, the dependency on local version of swift-aws-lambda-runtime is added dynamically below
22+
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", branch: "main")
2423
],
2524
targets: [
2625
.executableTarget(
@@ -33,20 +32,29 @@ let package = Package(
3332
]
3433
)
3534

36-
if let localDepsPath = ProcessInfo.processInfo.environment["LAMBDA_USE_LOCAL_DEPS"],
35+
if let localDepsPath = Context.environment["LAMBDA_USE_LOCAL_DEPS"],
3736
localDepsPath != "",
3837
let v = try? URL(fileURLWithPath: localDepsPath).resourceValues(forKeys: [.isDirectoryKey]),
39-
let _ = v.isDirectory
38+
v.isDirectory == true
4039
{
40+
// when we use the local runtime as deps, let's remove the dependency added above
41+
let indexToRemove = package.dependencies.firstIndex { dependency in
42+
if case .sourceControl(
43+
name: _,
44+
location: "https://github.com/swift-server/swift-aws-lambda-runtime.git",
45+
requirement: _
46+
) = dependency.kind {
47+
return true
48+
}
49+
return false
50+
}
51+
if let indexToRemove {
52+
package.dependencies.remove(at: indexToRemove)
53+
}
54+
55+
// then we add the dependency on LAMBDA_USE_LOCAL_DEPS' path (typically ../..)
4156
print("[INFO] Compiling against swift-aws-lambda-runtime located at \(localDepsPath)")
4257
package.dependencies += [
4358
.package(name: "swift-aws-lambda-runtime", path: localDepsPath)
4459
]
45-
46-
} else {
47-
print("[INFO] LAMBDA_USE_LOCAL_DEPS is not pointing to your local swift-aws-lambda-runtime code")
48-
print("[INFO] This project will compile against the main branch of the Lambda Runtime on GitHub")
49-
package.dependencies += [
50-
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", branch: "main")
51-
]
5260
}

Examples/S3_AWSSDK/.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.DS_Store
2+
.aws-sam/
3+
.build
4+
samtemplate.toml
5+
*/build/*
6+
/.build
7+
/Packages
8+
xcuserdata/
9+
DerivedData/
10+
.swiftpm/configuration/registries.json
11+
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
12+
.netrc

0 commit comments

Comments
 (0)