Skip to content

Commit 2c605eb

Browse files
authored
feat: add dotnet10 runtime (#811)
* feat: add dotnet10 runtime * update dotnet-integration name in github action
1 parent c91b4c0 commit 2c605eb

File tree

10 files changed

+150
-26
lines changed

10 files changed

+150
-26
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ jobs:
302302
- run: pytest -vv tests/integration/workflows/ruby_bundler
303303

304304
dotnet-integration:
305-
name: ${{ matrix.os }} / ${{ matrix.python }} / dotnet
305+
name: ${{ matrix.os }} / ${{ matrix.python }} / dotnet ${{ matrix.dotnet }}
306306
if: github.repository_owner == 'aws'
307307
runs-on: ${{ matrix.os }}
308308
strategy:
@@ -313,11 +313,18 @@ jobs:
313313
- windows-latest
314314
python:
315315
- "3.13"
316+
dotnet:
317+
- "6.0.x"
318+
- "8.0.x"
319+
- "10.0.x"
316320
steps:
317321
- uses: actions/checkout@v6
318322
- uses: actions/setup-python@v6
319323
with:
320324
python-version: ${{ matrix.python }}
325+
- uses: actions/setup-dotnet@v5
326+
with:
327+
dotnet-version: ${{ matrix.dotnet }}
321328
- run: make init
322329
- run: pytest -vv tests/integration/workflows/dotnet_clipackage
323330

aws_lambda_builders/supported_runtimes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
DOTNET_RUNTIMES = [
5353
"dotnet6",
5454
"dotnet8",
55+
"dotnet10",
5556
]
5657

5758
# Custom runtimes

tests/integration/workflows/dotnet_clipackage/test_dotnet.py

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,34 @@
1313

1414
from aws_lambda_builders.builder import LambdaBuilder
1515
from aws_lambda_builders.architecture import ARM64, X86_64
16+
from aws_lambda_builders.supported_runtimes import DOTNET_RUNTIMES
17+
18+
19+
def get_dotnet_test_params():
20+
"""Generate test parameters from DOTNET_RUNTIMES for standard Lambda functions."""
21+
params = []
22+
for runtime in DOTNET_RUNTIMES:
23+
version_num = runtime.replace("dotnet", "")
24+
version = f"{version_num}.0"
25+
test_project = f"WithDefaultsFile{version_num}"
26+
params.append((runtime, version, test_project))
27+
return params
28+
29+
30+
def get_custom_runtime_test_params():
31+
"""Generate test parameters from DOTNET_RUNTIMES for custom runtime builds.
32+
33+
Note: dotnet6 is excluded as it doesn't support custom runtime in the same way.
34+
"""
35+
params = []
36+
for runtime in DOTNET_RUNTIMES:
37+
if runtime == "dotnet6":
38+
continue
39+
version_num = runtime.replace("dotnet", "")
40+
version = f"{version_num}.0"
41+
test_project = f"CustomRuntime{version_num}"
42+
params.append((runtime, version, test_project))
43+
return params
1644

1745

1846
class TestDotnetBase(TestCase):
@@ -57,12 +85,7 @@ class TestDotnet(TestDotnetBase):
5785
def setUp(self):
5886
super(TestDotnet, self).setUp()
5987

60-
@parameterized.expand(
61-
[
62-
("dotnet6", "6.0", "WithDefaultsFile6"),
63-
("dotnet8", "8.0", "WithDefaultsFile8"),
64-
]
65-
)
88+
@parameterized.expand(get_dotnet_test_params())
6689
def test_with_defaults_file(self, runtime, version, test_project):
6790
source_dir = os.path.join(self.TEST_DATA_FOLDER, test_project)
6891

@@ -83,12 +106,7 @@ def test_with_defaults_file(self, runtime, version, test_project):
83106
self.assertEqual(expected_files, output_files)
84107
self.verify_architecture("WithDefaultsFile.deps.json", "linux-x64", version)
85108

86-
@parameterized.expand(
87-
[
88-
("dotnet6", "6.0", "WithDefaultsFile6"),
89-
("dotnet8", "8.0", "WithDefaultsFile8"),
90-
]
91-
)
109+
@parameterized.expand(get_dotnet_test_params())
92110
def test_with_defaults_file_x86(self, runtime, version, test_project):
93111
source_dir = os.path.join(self.TEST_DATA_FOLDER, test_project)
94112

@@ -109,12 +127,7 @@ def test_with_defaults_file_x86(self, runtime, version, test_project):
109127
self.assertEqual(expected_files, output_files)
110128
self.verify_architecture("WithDefaultsFile.deps.json", "linux-x64", version)
111129

112-
@parameterized.expand(
113-
[
114-
("dotnet6", "6.0", "WithDefaultsFile6"),
115-
("dotnet8", "8.0", "WithDefaultsFile8"),
116-
]
117-
)
130+
@parameterized.expand(get_dotnet_test_params())
118131
def test_with_defaults_file_arm64(self, runtime, version, test_project):
119132
source_dir = os.path.join(self.TEST_DATA_FOLDER, test_project)
120133

@@ -135,12 +148,7 @@ def test_with_defaults_file_arm64(self, runtime, version, test_project):
135148
self.assertEqual(expected_files, output_files)
136149
self.verify_architecture("WithDefaultsFile.deps.json", "linux-arm64", version)
137150

138-
@parameterized.expand(
139-
[
140-
# ("dotnet6", "6.0", "CustomRuntime6"),
141-
("dotnet8", "8.0", "CustomRuntime8"),
142-
]
143-
)
151+
@parameterized.expand(get_custom_runtime_test_params())
144152
def test_with_custom_runtime(self, runtime, version, test_project):
145153
source_dir = os.path.join(self.TEST_DATA_FOLDER, test_project)
146154

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<TargetFramework>net10.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
<AWSProjectType>Lambda</AWSProjectType>
8+
<AssemblyName>bootstrap</AssemblyName>
9+
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
10+
<PublishReadyToRun>true</PublishReadyToRun>
11+
</PropertyGroup>
12+
<ItemGroup>
13+
<PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="1.8.2" />
14+
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
15+
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.0" />
16+
</ItemGroup>
17+
</Project>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Amazon.Lambda.Core;
2+
using Amazon.Lambda.RuntimeSupport;
3+
using Amazon.Lambda.Serialization.SystemTextJson;
4+
5+
namespace CustomRuntime10;
6+
7+
public class Function
8+
{
9+
private static async Task Main(string[] args)
10+
{
11+
Func<string, ILambdaContext, string> handler = FunctionHandler;
12+
await LambdaBootstrapBuilder.Create(handler, new DefaultLambdaJsonSerializer())
13+
.Build()
14+
.RunAsync();
15+
}
16+
17+
public static string FunctionHandler(string input, ILambdaContext context)
18+
{
19+
return input.ToUpper();
20+
}
21+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"Information": [
3+
"This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.",
4+
"To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.",
5+
"dotnet lambda help",
6+
"All the command line options for the Lambda command can be specified in this file."
7+
],
8+
"profile": "",
9+
"region": "",
10+
"configuration": "Release",
11+
"function-runtime": "provided.al2023",
12+
"function-memory-size": 256,
13+
"function-timeout": 30,
14+
"function-handler": "bootstrap",
15+
"msbuild-parameters": "--self-contained true"
16+
}

tests/integration/workflows/dotnet_clipackage/testdata/CustomRuntime8/Function.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using Amazon.Lambda.RuntimeSupport;
33
using Amazon.Lambda.Serialization.SystemTextJson;
44

5-
namespace CustomRuntime6;
5+
namespace CustomRuntime8;
66

77
public class Function
88
{
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
6+
using Amazon.Lambda.Core;
7+
8+
// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class.
9+
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))]
10+
11+
namespace WithDefaultsFile
12+
{
13+
public class Function
14+
{
15+
16+
/// <summary>
17+
/// A simple function that takes a string and does a ToUpper
18+
/// </summary>
19+
/// <param name="input"></param>
20+
/// <param name="context"></param>
21+
/// <returns></returns>
22+
public string FunctionHandler(string input, ILambdaContext context)
23+
{
24+
return input?.ToUpper();
25+
}
26+
}
27+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net10.0</TargetFramework>
4+
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
5+
<AWSProjectType>Lambda</AWSProjectType>
6+
</PropertyGroup>
7+
<ItemGroup>
8+
<PackageReference Include="Amazon.Lambda.Core" Version="1.1.0" />
9+
<PackageReference Include="Amazon.Lambda.Serialization.Json" Version="1.4.0" />
10+
</ItemGroup>
11+
</Project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"Information": [
3+
"This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.",
4+
"To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.",
5+
"dotnet lambda help",
6+
"All the command line options for the Lambda command can be specified in this file."
7+
],
8+
"profile": "",
9+
"region": "",
10+
"configuration": "Release",
11+
"framework": "net10.0",
12+
"function-runtime": "dotnet10",
13+
"function-memory-size": 256,
14+
"function-timeout": 30,
15+
"function-handler": "WithDefaultsFile::WithDefaultsFile.Function::FunctionHandler"
16+
}

0 commit comments

Comments
 (0)