Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ jobs:
- run: pytest -vv tests/integration/workflows/ruby_bundler

dotnet-integration:
name: ${{ matrix.os }} / ${{ matrix.python }} / dotnet
name: ${{ matrix.os }} / ${{ matrix.python }} / dotnet ${{ matrix.dotnet }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious: what dotnet version did we test before this?

if: github.repository_owner == 'aws'
runs-on: ${{ matrix.os }}
strategy:
Expand All @@ -313,11 +313,18 @@ jobs:
- windows-latest
python:
- "3.13"
dotnet:
- "6.0.x"
- "8.0.x"
- "10.0.x"
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}
- uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ matrix.dotnet }}
- run: make init
- run: pytest -vv tests/integration/workflows/dotnet_clipackage

Expand Down
1 change: 1 addition & 0 deletions aws_lambda_builders/supported_runtimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
DOTNET_RUNTIMES = [
"dotnet6",
"dotnet8",
"dotnet10",
]

# Custom runtimes
Expand Down
56 changes: 32 additions & 24 deletions tests/integration/workflows/dotnet_clipackage/test_dotnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,34 @@

from aws_lambda_builders.builder import LambdaBuilder
from aws_lambda_builders.architecture import ARM64, X86_64
from aws_lambda_builders.supported_runtimes import DOTNET_RUNTIMES


def get_dotnet_test_params():
"""Generate test parameters from DOTNET_RUNTIMES for standard Lambda functions."""
params = []
for runtime in DOTNET_RUNTIMES:
version_num = runtime.replace("dotnet", "")
version = f"{version_num}.0"
test_project = f"WithDefaultsFile{version_num}"
params.append((runtime, version, test_project))
return params


def get_custom_runtime_test_params():
"""Generate test parameters from DOTNET_RUNTIMES for custom runtime builds.

Note: dotnet6 is excluded as it doesn't support custom runtime in the same way.
"""
params = []
for runtime in DOTNET_RUNTIMES:
if runtime == "dotnet6":
continue
version_num = runtime.replace("dotnet", "")
version = f"{version_num}.0"
test_project = f"CustomRuntime{version_num}"
params.append((runtime, version, test_project))
return params


class TestDotnetBase(TestCase):
Expand Down Expand Up @@ -57,12 +85,7 @@ class TestDotnet(TestDotnetBase):
def setUp(self):
super(TestDotnet, self).setUp()

@parameterized.expand(
[
("dotnet6", "6.0", "WithDefaultsFile6"),
("dotnet8", "8.0", "WithDefaultsFile8"),
]
)
@parameterized.expand(get_dotnet_test_params())
def test_with_defaults_file(self, runtime, version, test_project):
source_dir = os.path.join(self.TEST_DATA_FOLDER, test_project)

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

@parameterized.expand(
[
("dotnet6", "6.0", "WithDefaultsFile6"),
("dotnet8", "8.0", "WithDefaultsFile8"),
]
)
@parameterized.expand(get_dotnet_test_params())
def test_with_defaults_file_x86(self, runtime, version, test_project):
source_dir = os.path.join(self.TEST_DATA_FOLDER, test_project)

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

@parameterized.expand(
[
("dotnet6", "6.0", "WithDefaultsFile6"),
("dotnet8", "8.0", "WithDefaultsFile8"),
]
)
@parameterized.expand(get_dotnet_test_params())
def test_with_defaults_file_arm64(self, runtime, version, test_project):
source_dir = os.path.join(self.TEST_DATA_FOLDER, test_project)

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

@parameterized.expand(
[
# ("dotnet6", "6.0", "CustomRuntime6"),
("dotnet8", "8.0", "CustomRuntime8"),
]
)
@parameterized.expand(get_custom_runtime_test_params())
def test_with_custom_runtime(self, runtime, version, test_project):
source_dir = os.path.join(self.TEST_DATA_FOLDER, test_project)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AWSProjectType>Lambda</AWSProjectType>
<AssemblyName>bootstrap</AssemblyName>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="1.8.2" />
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Amazon.Lambda.Core;
using Amazon.Lambda.RuntimeSupport;
using Amazon.Lambda.Serialization.SystemTextJson;

namespace CustomRuntime10;

public class Function
{
private static async Task Main(string[] args)
{
Func<string, ILambdaContext, string> handler = FunctionHandler;
await LambdaBootstrapBuilder.Create(handler, new DefaultLambdaJsonSerializer())
.Build()
.RunAsync();
}

public static string FunctionHandler(string input, ILambdaContext context)
{
return input.ToUpper();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"Information": [
"This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.",
"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.",
"dotnet lambda help",
"All the command line options for the Lambda command can be specified in this file."
],
"profile": "",
"region": "",
"configuration": "Release",
"function-runtime": "provided.al2023",
"function-memory-size": 256,
"function-timeout": 30,
"function-handler": "bootstrap",
"msbuild-parameters": "--self-contained true"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Amazon.Lambda.RuntimeSupport;
using Amazon.Lambda.Serialization.SystemTextJson;

namespace CustomRuntime6;
namespace CustomRuntime8;

public class Function
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

using Amazon.Lambda.Core;

// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class.
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))]

namespace WithDefaultsFile
{
public class Function
{

/// <summary>
/// A simple function that takes a string and does a ToUpper
/// </summary>
/// <param name="input"></param>
/// <param name="context"></param>
/// <returns></returns>
public string FunctionHandler(string input, ILambdaContext context)
{
return input?.ToUpper();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AWSProjectType>Lambda</AWSProjectType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Amazon.Lambda.Core" Version="1.1.0" />
<PackageReference Include="Amazon.Lambda.Serialization.Json" Version="1.4.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"Information": [
"This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.",
"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.",
"dotnet lambda help",
"All the command line options for the Lambda command can be specified in this file."
],
"profile": "",
"region": "",
"configuration": "Release",
"framework": "net10.0",
"function-runtime": "dotnet10",
"function-memory-size": 256,
"function-timeout": 30,
"function-handler": "WithDefaultsFile::WithDefaultsFile.Function::FunctionHandler"
}
Loading