-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
251 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
tests/integration/workflows/dotnet_clipackage/testdata/CustomRuntime6/CustomRuntime6.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<AWSProjectType>Lambda</AWSProjectType> | ||
<AssemblyName>bootstrap</AssemblyName> | ||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> | ||
<PublishReadyToRun>true</PublishReadyToRun> | ||
</PropertyGroup> | ||
<!-- | ||
When publishing Lambda functions for ARM64 to the provided.al2 runtime a newer version of libicu needs to be included | ||
in the deployment bundle because .NET requires a newer version of libicu then is preinstalled with Amazon Linux 2. | ||
--> | ||
<ItemGroup Condition="'$(RuntimeIdentifier)' == 'linux-arm64'"> | ||
<RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2.0.9" /> | ||
<PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.9" /> | ||
</ItemGroup> | ||
<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> |
21 changes: 21 additions & 0 deletions
21
tests/integration/workflows/dotnet_clipackage/testdata/CustomRuntime6/Function.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 CustomRuntime6; | ||
|
||
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(); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...ration/workflows/dotnet_clipackage/testdata/CustomRuntime6/aws-lambda-tools-defaults.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.al2", | ||
"function-memory-size": 256, | ||
"function-timeout": 30, | ||
"function-handler": "bootstrap", | ||
"msbuild-parameters": "--self-contained true" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import os | ||
import stat | ||
import tempfile | ||
from unittest import TestCase | ||
from zipfile import ZipFile | ||
|
||
from aws_lambda_builders.workflows.dotnet_clipackage.utils import OSUtils | ||
|
||
|
||
class TestDotnetCliPackageWorkflow(TestCase): | ||
def test_unzip_keeps_execute_permission_on_linux(self): | ||
with tempfile.TemporaryDirectory() as temp_dir: | ||
with tempfile.TemporaryDirectory(dir=temp_dir) as output_dir: | ||
test_file_name = "myFileToZip" | ||
path_to_file_to_zip = os.path.join(temp_dir, test_file_name) | ||
path_to_zip_file = os.path.join(temp_dir, "myZip.zip") | ||
expected_output_file = os.path.join(output_dir, test_file_name) | ||
with open(path_to_file_to_zip, "a") as the_file: | ||
the_file.write("Hello World!") | ||
|
||
# Set execute permissions on the file before zipping (won't do anything on Windows) | ||
st = os.stat(path_to_file_to_zip) | ||
os.chmod(path_to_file_to_zip, st.st_mode | stat.S_IEXEC | stat.S_IXOTH | stat.S_IXGRP) | ||
|
||
# Zip the file | ||
with ZipFile(path_to_zip_file, "w") as myzip: | ||
myzip.write(path_to_file_to_zip, test_file_name) | ||
|
||
# Unzip the file | ||
OSUtils().unzip(path_to_zip_file, output_dir) | ||
self.assertTrue(os.path.exists(expected_output_file)) | ||
|
||
# Assert that execute permissions are still applied | ||
self.assertTrue(os.access(expected_output_file, os.X_OK)) |