From 4a800c636f98afcc79965fefecd9885544bff9e3 Mon Sep 17 00:00:00 2001 From: Henrique Graca <999396+hjgraca@users.noreply.github.com> Date: Fri, 5 Jan 2024 11:24:08 +0000 Subject: [PATCH 01/20] Handle Exceptions and Prevent application from crashing when using Logger --- .../LoggerExtensions.cs | 52 ++++++++++++------- ...AWS.Lambda.Powertools.Logging.Tests.csproj | 2 + .../Handlers/ExceptionFunctionHandler.cs | 32 ++++++++++++ .../Handlers/ExceptionFunctionHandlerTests.cs | 16 ++++++ 4 files changed, 83 insertions(+), 19 deletions(-) diff --git a/libraries/src/AWS.Lambda.Powertools.Logging/LoggerExtensions.cs b/libraries/src/AWS.Lambda.Powertools.Logging/LoggerExtensions.cs index 8c8dd3110..200cf46ed 100644 --- a/libraries/src/AWS.Lambda.Powertools.Logging/LoggerExtensions.cs +++ b/libraries/src/AWS.Lambda.Powertools.Logging/LoggerExtensions.cs @@ -1,12 +1,12 @@ /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - * + * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at - * + * * http://aws.amazon.com/apache2.0 - * + * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing @@ -187,7 +187,7 @@ public static void Log(this ILogger logger, LogLevel logLevel, Exception excepti #region ExtraKeys Logger Extentions #region Debug - + /// /// Formats and writes a debug log message. /// @@ -242,15 +242,16 @@ public static void LogDebug(this ILogger logger, T extraKeys, Exception excep /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogDebug(extraKeys, "Processing request from {Address}", address) - public static void LogDebug(this ILogger logger, T extraKeys, string message, params object[] args) where T : class + public static void LogDebug(this ILogger logger, T extraKeys, string message, params object[] args) + where T : class { Log(logger, LogLevel.Debug, extraKeys, message, args); } - + #endregion #region Trace - + /// /// Formats and writes a trace log message. /// @@ -305,7 +306,8 @@ public static void LogTrace(this ILogger logger, T extraKeys, Exception excep /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogTrace(extraKeys, "Processing request from {Address}", address) - public static void LogTrace(this ILogger logger, T extraKeys, string message, params object[] args) where T : class + public static void LogTrace(this ILogger logger, T extraKeys, string message, params object[] args) + where T : class { Log(logger, LogLevel.Trace, extraKeys, message, args); } @@ -313,7 +315,7 @@ public static void LogTrace(this ILogger logger, T extraKeys, string message, #endregion #region Information - + /// /// Formats and writes an informational log message. /// @@ -368,11 +370,12 @@ public static void LogInformation(this ILogger logger, T extraKeys, Exception /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogInformation(extraKeys, "Processing request from {Address}", address) - public static void LogInformation(this ILogger logger, T extraKeys, string message, params object[] args) where T : class + public static void LogInformation(this ILogger logger, T extraKeys, string message, params object[] args) + where T : class { Log(logger, LogLevel.Information, extraKeys, message, args); } - + #endregion #region Warning @@ -431,11 +434,12 @@ public static void LogWarning(this ILogger logger, T extraKeys, Exception exc /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogWarning(extraKeys, "Processing request from {Address}", address) - public static void LogWarning(this ILogger logger, T extraKeys, string message, params object[] args) where T : class + public static void LogWarning(this ILogger logger, T extraKeys, string message, params object[] args) + where T : class { Log(logger, LogLevel.Warning, extraKeys, message, args); } - + #endregion #region Error @@ -494,7 +498,8 @@ public static void LogError(this ILogger logger, T extraKeys, Exception excep /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogError(extraKeys, "Processing request from {Address}", address) - public static void LogError(this ILogger logger, T extraKeys, string message, params object[] args) where T : class + public static void LogError(this ILogger logger, T extraKeys, string message, params object[] args) + where T : class { Log(logger, LogLevel.Error, extraKeys, message, args); } @@ -557,7 +562,8 @@ public static void LogCritical(this ILogger logger, T extraKeys, Exception ex /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogCritical(extraKeys, "Processing request from {Address}", address) - public static void LogCritical(this ILogger logger, T extraKeys, string message, params object[] args) where T : class + public static void LogCritical(this ILogger logger, T extraKeys, string message, params object[] args) + where T : class { Log(logger, LogLevel.Critical, extraKeys, message, args); } @@ -565,7 +571,7 @@ public static void LogCritical(this ILogger logger, T extraKeys, string messa #endregion #region Log - + /// /// Formats and writes a log message at the specified log level. /// @@ -630,11 +636,19 @@ public static void Log(this ILogger logger, LogLevel logLevel, T extraKeys, E /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.Log(LogLevel.Information, extraKeys, "Processing request from {Address}", address) - public static void Log(this ILogger logger, LogLevel logLevel, T extraKeys, string message, params object[] args) where T : class + public static void Log(this ILogger logger, LogLevel logLevel, T extraKeys, string message, params object[] args) + where T : class { - Log(logger, logLevel, extraKeys, 0, null, message, args); + try + { + Log(logger, logLevel, extraKeys, 0, null, message, args); + } + catch (Exception e) + { + logger.Log(LogLevel.Error, 0, e, "Powertools internal error"); + } } - + #endregion #endregion diff --git a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/AWS.Lambda.Powertools.Logging.Tests.csproj b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/AWS.Lambda.Powertools.Logging.Tests.csproj index 197fec51d..5567ec66f 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/AWS.Lambda.Powertools.Logging.Tests.csproj +++ b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/AWS.Lambda.Powertools.Logging.Tests.csproj @@ -12,6 +12,8 @@ + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Handlers/ExceptionFunctionHandler.cs b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Handlers/ExceptionFunctionHandler.cs index a2928252d..230053886 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Handlers/ExceptionFunctionHandler.cs +++ b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Handlers/ExceptionFunctionHandler.cs @@ -1,6 +1,8 @@ using System; +using System.Collections.Generic; using System.Globalization; using System.Threading.Tasks; +using Amazon.Lambda.Core; namespace AWS.Lambda.Powertools.Logging.Tests.Handlers; @@ -20,4 +22,34 @@ private void ThisThrows() { throw new NullReferenceException(); } + + [Logging(CorrelationIdPath = "/1//", LogEvent = true, Service = null, SamplingRate = 10000d)] + public string HandlerLoggerForExceptions(string input, ILambdaContext context) + { + // Edge cases and bad code to force exceptions + + Logger.LogInformation("Hello {input}", input); + Logger.LogError("Hello {input}", input); + Logger.LogCritical("Hello {input}", input); + Logger.LogDebug("Hello {input}", input); + Logger.LogTrace("Hello {input}", input); + + Logger.LogInformation("Testing with parameter Log Information Method {company}", new[] { "AWS" }); + + var customKeys = new Dictionary + { + {"test1", "value1"}, + {"test2", "value2"} + }; + Logger.LogInformation(customKeys, "Retrieved data for city {cityName} with count {company}", "AWS"); + + Logger.AppendKey("aws",1); + Logger.AppendKey("aws",3); + + Logger.RemoveKeys("test"); + + Logger.AppendKeys(new[]{ new KeyValuePair("aws",1), new KeyValuePair("aws",2)}); + + return "OK"; + } } \ No newline at end of file diff --git a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Handlers/ExceptionFunctionHandlerTests.cs b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Handlers/ExceptionFunctionHandlerTests.cs index f2bbe798e..dd7a12db8 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Handlers/ExceptionFunctionHandlerTests.cs +++ b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Handlers/ExceptionFunctionHandlerTests.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using Amazon.Lambda.TestUtilities; using Xunit; namespace AWS.Lambda.Powertools.Logging.Tests.Handlers; @@ -20,4 +21,19 @@ public async Task Stack_Trace_Included_When_Decorator_Present() Assert.StartsWith("at AWS.Lambda.Powertools.Logging.Tests.Handlers.ExceptionFunctionHandler.ThisThrows()", tracedException.StackTrace?.TrimStart()); } + + [Fact] + public void Utility_Should_Not_Throw_Exceptions_To_Client() + { + // Arrange + var lambdaContext = new TestLambdaContext(); + + var handler = new ExceptionFunctionHandler(); + + // Act + var res = handler.HandlerLoggerForExceptions("aws",lambdaContext); + + // Assert + Assert.Equal("OK", res); + } } \ No newline at end of file From 5159cd84b6fb2730a4d45f010fb5b32ea0100411 Mon Sep 17 00:00:00 2001 From: Henrique Graca <999396+hjgraca@users.noreply.github.com> Date: Fri, 5 Jan 2024 12:02:30 +0000 Subject: [PATCH 02/20] fix test because of order of execution might fail --- .../LogFormatterTest.cs | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/LogFormatterTest.cs b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/LogFormatterTest.cs index 82c93e34a..158d8fe8e 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/LogFormatterTest.cs +++ b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/LogFormatterTest.cs @@ -138,16 +138,17 @@ public void Log_WhenCustomFormatter_LogsCustomFormat() x.Level == logLevel && x.Message.ToString() == message && x.Exception == null && - x.ExtraKeys != null && - x.ExtraKeys.Count == globalExtraKeys.Count + scopeExtraKeys.Count && - x.ExtraKeys.ContainsKey(globalExtraKeys.First().Key) && - x.ExtraKeys[globalExtraKeys.First().Key] == globalExtraKeys.First().Value && - x.ExtraKeys.ContainsKey(globalExtraKeys.Last().Key) && - x.ExtraKeys[globalExtraKeys.Last().Key] == globalExtraKeys.Last().Value && - x.ExtraKeys.ContainsKey(scopeExtraKeys.First().Key) && - x.ExtraKeys[scopeExtraKeys.First().Key] == scopeExtraKeys.First().Value && - x.ExtraKeys.ContainsKey(scopeExtraKeys.Last().Key) && - x.ExtraKeys[scopeExtraKeys.Last().Key] == scopeExtraKeys.Last().Value && + x.ExtraKeys != null && ( + x.ExtraKeys.Count != globalExtraKeys.Count + scopeExtraKeys.Count || ( + x.ExtraKeys.Count == globalExtraKeys.Count + scopeExtraKeys.Count && + x.ExtraKeys.ContainsKey(globalExtraKeys.First().Key) && + x.ExtraKeys[globalExtraKeys.First().Key] == globalExtraKeys.First().Value && + x.ExtraKeys.ContainsKey(globalExtraKeys.Last().Key) && + x.ExtraKeys[globalExtraKeys.Last().Key] == globalExtraKeys.Last().Value && + x.ExtraKeys.ContainsKey(scopeExtraKeys.First().Key) && + x.ExtraKeys[scopeExtraKeys.First().Key] == scopeExtraKeys.First().Value && + x.ExtraKeys.ContainsKey(scopeExtraKeys.Last().Key) && + x.ExtraKeys[scopeExtraKeys.Last().Key] == scopeExtraKeys.Last().Value ) ) && x.LambdaContext != null && x.LambdaContext.FunctionName == lambdaContext.FunctionName && x.LambdaContext.FunctionVersion == lambdaContext.FunctionVersion && From 597a3fb39ad1f1daad56e62903a2c05aece036ed Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Jan 2024 16:54:58 +0000 Subject: [PATCH 03/20] chore(deps): bump gitpython from 3.1.37 to 3.1.41 Bumps [gitpython](https://github.com/gitpython-developers/GitPython) from 3.1.37 to 3.1.41. - [Release notes](https://github.com/gitpython-developers/GitPython/releases) - [Changelog](https://github.com/gitpython-developers/GitPython/blob/main/CHANGES) - [Commits](https://github.com/gitpython-developers/GitPython/compare/3.1.37...3.1.41) --- updated-dependencies: - dependency-name: gitpython dependency-type: indirect ... Signed-off-by: dependabot[bot] --- poetry.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/poetry.lock b/poetry.lock index 40b30317f..e9a118f19 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. [[package]] name = "click" @@ -58,20 +58,20 @@ smmap = ">=3.0.1,<6" [[package]] name = "gitpython" -version = "3.1.37" +version = "3.1.41" description = "GitPython is a Python library used to interact with Git repositories" optional = false python-versions = ">=3.7" files = [ - {file = "GitPython-3.1.37-py3-none-any.whl", hash = "sha256:5f4c4187de49616d710a77e98ddf17b4782060a1788df441846bddefbb89ab33"}, - {file = "GitPython-3.1.37.tar.gz", hash = "sha256:f9b9ddc0761c125d5780eab2d64be4873fc6817c2899cbcb34b02344bdc7bc54"}, + {file = "GitPython-3.1.41-py3-none-any.whl", hash = "sha256:c36b6634d069b3f719610175020a9aed919421c87552185b085e04fbbdb10b7c"}, + {file = "GitPython-3.1.41.tar.gz", hash = "sha256:ed66e624884f76df22c8e16066d567aaa5a37d5b5fa19db2c6df6f7156db9048"}, ] [package.dependencies] gitdb = ">=4.0.1,<5" [package.extras] -test = ["black", "coverage[toml]", "ddt (>=1.1.1,!=1.4.3)", "mypy", "pre-commit", "pytest", "pytest-cov", "pytest-sugar"] +test = ["black", "coverage[toml]", "ddt (>=1.1.1,!=1.4.3)", "mock", "mypy", "pre-commit", "pytest (>=7.3.1)", "pytest-cov", "pytest-instafail", "pytest-mock", "pytest-sugar", "sumtypes"] [[package]] name = "importlib-metadata" From 3e561d846bd2284da07d1a1359a9c05f05d240a6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Jan 2024 20:25:12 +0000 Subject: [PATCH 04/20] chore(deps): bump jinja2 from 3.1.2 to 3.1.3 Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.2 to 3.1.3. - [Release notes](https://github.com/pallets/jinja/releases) - [Changelog](https://github.com/pallets/jinja/blob/main/CHANGES.rst) - [Commits](https://github.com/pallets/jinja/compare/3.1.2...3.1.3) --- updated-dependencies: - dependency-name: jinja2 dependency-type: indirect ... Signed-off-by: dependabot[bot] --- poetry.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/poetry.lock b/poetry.lock index 40b30317f..c65f61f63 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. [[package]] name = "click" @@ -94,13 +94,13 @@ testing = ["flake8 (<5)", "flufl.flake8", "importlib-resources (>=1.3)", "packag [[package]] name = "jinja2" -version = "3.1.2" +version = "3.1.3" description = "A very fast and expressive template engine." optional = false python-versions = ">=3.7" files = [ - {file = "Jinja2-3.1.2-py3-none-any.whl", hash = "sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61"}, - {file = "Jinja2-3.1.2.tar.gz", hash = "sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852"}, + {file = "Jinja2-3.1.3-py3-none-any.whl", hash = "sha256:7d6d50dd97d52cbc355597bd845fabfbac3f551e1f99619e39a35ce8c370b5fa"}, + {file = "Jinja2-3.1.3.tar.gz", hash = "sha256:ac8bd6544d4bb2c9792bf3a159e80bba8fda7f07e81bc3aed565432d5925ba90"}, ] [package.dependencies] From 19884babf078bced1ed392168a4aed1309d9673c Mon Sep 17 00:00:00 2001 From: Henrique Graca <999396+hjgraca@users.noreply.github.com> Date: Wed, 17 Jan 2024 14:58:31 +0000 Subject: [PATCH 05/20] Update build.yml matrix dotnet8 Signed-off-by: Henrique Graca <999396+hjgraca@users.noreply.github.com> --- .github/workflows/build.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bc25ad50a..d6c6c72a6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,13 +13,17 @@ defaults: jobs: build: runs-on: ubuntu-latest - + strategy: + matrix: + dotnet: [ '6.0.405', '8.0.101' ] steps: - uses: actions/checkout@v3 - - name: Setup .NET 6.0 + - name: Setup .NET ${{ matrix.dotnet }} uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a with: - dotnet-version: 6.0.405 + dotnet-version: ${{ matrix.dotnet }} + - name: Create temporary global.json + run: echo '{"sdk":{"version": "${{ steps.stepid.outputs.dotnet-version }}"}}' > ./global.json - name: Install solution dependencies run: dotnet restore - name: Build From 7f380d281f4cd0138e30b09851fe07692191804d Mon Sep 17 00:00:00 2001 From: Henrique Graca <999396+hjgraca@users.noreply.github.com> Date: Wed, 17 Jan 2024 15:23:18 +0000 Subject: [PATCH 06/20] oh yaml formatting Signed-off-by: Henrique Graca <999396+hjgraca@users.noreply.github.com> --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d6c6c72a6..01434b209 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,7 @@ jobs: with: dotnet-version: ${{ matrix.dotnet }} - name: Create temporary global.json - run: echo '{"sdk":{"version": "${{ steps.stepid.outputs.dotnet-version }}"}}' > ./global.json + run: echo '{"sdk":{"version":"${{ steps.stepid.outputs.dotnet-version }}"}}' > ./global.json - name: Install solution dependencies run: dotnet restore - name: Build From bfe7aaa7fcca4e3eb193ad473ee4a61043922ab1 Mon Sep 17 00:00:00 2001 From: Henrique Graca <999396+hjgraca@users.noreply.github.com> Date: Wed, 17 Jan 2024 15:33:05 +0000 Subject: [PATCH 07/20] add stepid Signed-off-by: Henrique Graca <999396+hjgraca@users.noreply.github.com> --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 01434b209..2487217af 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,10 +20,11 @@ jobs: - uses: actions/checkout@v3 - name: Setup .NET ${{ matrix.dotnet }} uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a + id: setup with: dotnet-version: ${{ matrix.dotnet }} - name: Create temporary global.json - run: echo '{"sdk":{"version":"${{ steps.stepid.outputs.dotnet-version }}"}}' > ./global.json + run: echo '{"sdk":{"version":"${{ steps.setup.outputs.dotnet-version }}"}}' > ./global.json - name: Install solution dependencies run: dotnet restore - name: Build From 5d3c0b342a9fd82580192f9ccda2fb9ebf0ed010 Mon Sep 17 00:00:00 2001 From: Henrique Graca <999396+hjgraca@users.noreply.github.com> Date: Wed, 17 Jan 2024 15:39:44 +0000 Subject: [PATCH 08/20] Update Directory.Build.props - remove target framework Signed-off-by: Henrique Graca <999396+hjgraca@users.noreply.github.com> --- libraries/src/Directory.Build.props | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/src/Directory.Build.props b/libraries/src/Directory.Build.props index 4d4afc36c..4ed23fdd4 100644 --- a/libraries/src/Directory.Build.props +++ b/libraries/src/Directory.Build.props @@ -1,7 +1,6 @@ - net6.0 default 0.0.1 @@ -26,4 +25,4 @@ - \ No newline at end of file + From 0df927168f4d8fbbd0c111647f4dcec58ef8f28f Mon Sep 17 00:00:00 2001 From: Henrique Graca <999396+hjgraca@users.noreply.github.com> Date: Wed, 17 Jan 2024 16:14:49 +0000 Subject: [PATCH 09/20] update target frameworks. delete global.json --- global.json | 5 ----- libraries/src/Directory.Build.props | 4 ++-- .../AWS.Lambda.Powertools.BatchProcessing.Tests.csproj | 1 - .../AWS.Lambda.Powertools.Common.Tests.csproj | 1 - .../AWS.Lambda.Powertools.Idempotency.Tests.csproj | 1 - .../AWS.Lambda.Powertools.Logging.Tests.csproj | 1 - .../AWS.Lambda.Powertools.Metrics.Tests.csproj | 5 ----- .../AWS.Lambda.Powertools.Parameters.Tests.csproj | 1 - .../AWS.Lambda.Powertools.Tracing.Tests.csproj | 1 - libraries/tests/Directory.Build.props | 3 +++ 10 files changed, 5 insertions(+), 18 deletions(-) delete mode 100644 global.json diff --git a/global.json b/global.json deleted file mode 100644 index 5f5ece165..000000000 --- a/global.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "sdk": { - "version": "6.0.405" - } -} diff --git a/libraries/src/Directory.Build.props b/libraries/src/Directory.Build.props index 4ed23fdd4..0260344d5 100644 --- a/libraries/src/Directory.Build.props +++ b/libraries/src/Directory.Build.props @@ -1,6 +1,6 @@ - + net6.0;net8.0 default 0.0.1 @@ -25,4 +25,4 @@ - + \ No newline at end of file diff --git a/libraries/tests/AWS.Lambda.Powertools.BatchProcessing.Tests/AWS.Lambda.Powertools.BatchProcessing.Tests.csproj b/libraries/tests/AWS.Lambda.Powertools.BatchProcessing.Tests/AWS.Lambda.Powertools.BatchProcessing.Tests.csproj index 0824576d0..d71afc788 100644 --- a/libraries/tests/AWS.Lambda.Powertools.BatchProcessing.Tests/AWS.Lambda.Powertools.BatchProcessing.Tests.csproj +++ b/libraries/tests/AWS.Lambda.Powertools.BatchProcessing.Tests/AWS.Lambda.Powertools.BatchProcessing.Tests.csproj @@ -1,7 +1,6 @@ - net6.0 default AWS.Lambda.Powertools.BatchProcessing.Tests AWS.Lambda.Powertools.BatchProcessing.Tests diff --git a/libraries/tests/AWS.Lambda.Powertools.Common.Tests/AWS.Lambda.Powertools.Common.Tests.csproj b/libraries/tests/AWS.Lambda.Powertools.Common.Tests/AWS.Lambda.Powertools.Common.Tests.csproj index 8c5541406..243fbf9d3 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Common.Tests/AWS.Lambda.Powertools.Common.Tests.csproj +++ b/libraries/tests/AWS.Lambda.Powertools.Common.Tests/AWS.Lambda.Powertools.Common.Tests.csproj @@ -1,7 +1,6 @@ - net6.0 AWS.Lambda.Powertools.Common.Tests AWS.Lambda.Powertools.Common.Tests diff --git a/libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/AWS.Lambda.Powertools.Idempotency.Tests.csproj b/libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/AWS.Lambda.Powertools.Idempotency.Tests.csproj index 4dab4f4f1..1ea81cc32 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/AWS.Lambda.Powertools.Idempotency.Tests.csproj +++ b/libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/AWS.Lambda.Powertools.Idempotency.Tests.csproj @@ -1,7 +1,6 @@ - net6.0 default AWS.Lambda.Powertools.Idempotency.Tests AWS.Lambda.Powertools.Idempotency.Tests diff --git a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/AWS.Lambda.Powertools.Logging.Tests.csproj b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/AWS.Lambda.Powertools.Logging.Tests.csproj index 197fec51d..c9baf07b9 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/AWS.Lambda.Powertools.Logging.Tests.csproj +++ b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/AWS.Lambda.Powertools.Logging.Tests.csproj @@ -1,7 +1,6 @@ - net6.0 default AWS.Lambda.Powertools.Logging.Tests AWS.Lambda.Powertools.Logging.Tests diff --git a/libraries/tests/AWS.Lambda.Powertools.Metrics.Tests/AWS.Lambda.Powertools.Metrics.Tests.csproj b/libraries/tests/AWS.Lambda.Powertools.Metrics.Tests/AWS.Lambda.Powertools.Metrics.Tests.csproj index a209a34c0..f6fd9f8d8 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Metrics.Tests/AWS.Lambda.Powertools.Metrics.Tests.csproj +++ b/libraries/tests/AWS.Lambda.Powertools.Metrics.Tests/AWS.Lambda.Powertools.Metrics.Tests.csproj @@ -1,14 +1,9 @@ - net6.0 - false - default - AWS.Lambda.Powertools.Metrics.Tests - AWS.Lambda.Powertools.Metrics.Tests diff --git a/libraries/tests/AWS.Lambda.Powertools.Parameters.Tests/AWS.Lambda.Powertools.Parameters.Tests.csproj b/libraries/tests/AWS.Lambda.Powertools.Parameters.Tests/AWS.Lambda.Powertools.Parameters.Tests.csproj index 199185679..bae7120f3 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Parameters.Tests/AWS.Lambda.Powertools.Parameters.Tests.csproj +++ b/libraries/tests/AWS.Lambda.Powertools.Parameters.Tests/AWS.Lambda.Powertools.Parameters.Tests.csproj @@ -1,7 +1,6 @@ - net6.0 enable enable AWS.Lambda.Powertools.Parameters.Tests diff --git a/libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/AWS.Lambda.Powertools.Tracing.Tests.csproj b/libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/AWS.Lambda.Powertools.Tracing.Tests.csproj index 57314fc65..ce7a88ba5 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/AWS.Lambda.Powertools.Tracing.Tests.csproj +++ b/libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/AWS.Lambda.Powertools.Tracing.Tests.csproj @@ -1,7 +1,6 @@ - net6.0 default AWS.Lambda.Powertools.Tracing.Tests AWS.Lambda.Powertools.Tracing.Tests diff --git a/libraries/tests/Directory.Build.props b/libraries/tests/Directory.Build.props index b320c91fd..e714cb16b 100644 --- a/libraries/tests/Directory.Build.props +++ b/libraries/tests/Directory.Build.props @@ -1,4 +1,7 @@ + + net6.0;net8.0 + From f5266b1949cd9c2a97221d95dd9084dc7ed97418 Mon Sep 17 00:00:00 2001 From: Henrique Graca <999396+hjgraca@users.noreply.github.com> Date: Wed, 17 Jan 2024 19:52:32 +0000 Subject: [PATCH 10/20] revert matrix and add both sdks --- .github/workflows/build.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2487217af..97310853c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,18 +13,15 @@ defaults: jobs: build: runs-on: ubuntu-latest - strategy: - matrix: - dotnet: [ '6.0.405', '8.0.101' ] + steps: - uses: actions/checkout@v3 - - name: Setup .NET ${{ matrix.dotnet }} + - name: Setup .NET 6.0 uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a - id: setup with: - dotnet-version: ${{ matrix.dotnet }} - - name: Create temporary global.json - run: echo '{"sdk":{"version":"${{ steps.setup.outputs.dotnet-version }}"}}' > ./global.json + dotnet-version: | + 6.0.405 + 8.0.101 - name: Install solution dependencies run: dotnet restore - name: Build From 675d6eeaee4e4665fa59c03bba99cd75e435a5e5 Mon Sep 17 00:00:00 2001 From: Henrique Graca <999396+hjgraca@users.noreply.github.com> Date: Wed, 17 Jan 2024 20:09:11 +0000 Subject: [PATCH 11/20] update setup title. update examples for multi target framework --- .github/workflows/build.yml | 2 +- examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj | 2 +- .../test/HelloWorld.Test/HelloWorld.Tests.csproj | 2 +- examples/Idempotency/src/HelloWorld/HelloWorld.csproj | 2 +- .../Idempotency/test/HelloWorld.Test/HelloWorld.Tests.csproj | 2 +- examples/Logging/src/HelloWorld/HelloWorld.csproj | 2 +- examples/Logging/test/HelloWorld.Test/HelloWorld.Tests.csproj | 2 +- examples/Metrics/src/HelloWorld/HelloWorld.csproj | 2 +- examples/Metrics/test/HelloWorld.Test/HelloWorld.Tests.csproj | 2 +- examples/Parameters/cfn/HelloWorld.Cfn/HelloWorld.Cfn.csproj | 2 +- examples/Parameters/src/HelloWorld/HelloWorld.csproj | 2 +- .../Parameters/test/HelloWorld.Test/HelloWorld.Tests.csproj | 2 +- .../src/LambdaPowertoolsAPI/LambdaPowertoolsAPI.csproj | 2 +- .../LambdaPowertoolsAPI.Tests/LambdaPowertoolsAPI.Tests.csproj | 2 +- examples/Tracing/src/HelloWorld/HelloWorld.csproj | 2 +- examples/Tracing/test/HelloWorld.Test/HelloWorld.Tests.csproj | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 97310853c..68efa4354 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Setup .NET 6.0 + - name: Setup .NET 6.0 & 8.0 uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a with: dotnet-version: | diff --git a/examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj b/examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj index 4b4abe012..0589010c1 100644 --- a/examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj +++ b/examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj @@ -1,6 +1,6 @@  - net6.0 + net6.0;net8.0 true enable diff --git a/examples/BatchProcessing/test/HelloWorld.Test/HelloWorld.Tests.csproj b/examples/BatchProcessing/test/HelloWorld.Test/HelloWorld.Tests.csproj index 6403301ae..fe9b08e07 100644 --- a/examples/BatchProcessing/test/HelloWorld.Test/HelloWorld.Tests.csproj +++ b/examples/BatchProcessing/test/HelloWorld.Test/HelloWorld.Tests.csproj @@ -1,6 +1,6 @@ - net6.0 + net6.0;net8.0 diff --git a/examples/Idempotency/src/HelloWorld/HelloWorld.csproj b/examples/Idempotency/src/HelloWorld/HelloWorld.csproj index 8be19c09c..1b62c992d 100644 --- a/examples/Idempotency/src/HelloWorld/HelloWorld.csproj +++ b/examples/Idempotency/src/HelloWorld/HelloWorld.csproj @@ -1,6 +1,6 @@ - net6.0 + net6.0;net8.0 true enable diff --git a/examples/Idempotency/test/HelloWorld.Test/HelloWorld.Tests.csproj b/examples/Idempotency/test/HelloWorld.Test/HelloWorld.Tests.csproj index c38d76bdd..6afa095c4 100644 --- a/examples/Idempotency/test/HelloWorld.Test/HelloWorld.Tests.csproj +++ b/examples/Idempotency/test/HelloWorld.Test/HelloWorld.Tests.csproj @@ -1,6 +1,6 @@ - net6.0 + net6.0;net8.0 diff --git a/examples/Logging/src/HelloWorld/HelloWorld.csproj b/examples/Logging/src/HelloWorld/HelloWorld.csproj index c99ee06d4..53323ac8d 100644 --- a/examples/Logging/src/HelloWorld/HelloWorld.csproj +++ b/examples/Logging/src/HelloWorld/HelloWorld.csproj @@ -1,6 +1,6 @@ - net6.0 + net6.0;net8.0 true enable diff --git a/examples/Logging/test/HelloWorld.Test/HelloWorld.Tests.csproj b/examples/Logging/test/HelloWorld.Test/HelloWorld.Tests.csproj index 31e123cf3..7a5090108 100644 --- a/examples/Logging/test/HelloWorld.Test/HelloWorld.Tests.csproj +++ b/examples/Logging/test/HelloWorld.Test/HelloWorld.Tests.csproj @@ -1,6 +1,6 @@ - net6.0 + net6.0;net8.0 diff --git a/examples/Metrics/src/HelloWorld/HelloWorld.csproj b/examples/Metrics/src/HelloWorld/HelloWorld.csproj index 8ccb558a7..b3262af29 100644 --- a/examples/Metrics/src/HelloWorld/HelloWorld.csproj +++ b/examples/Metrics/src/HelloWorld/HelloWorld.csproj @@ -1,6 +1,6 @@ - net6.0 + net6.0;net8.0 true enable diff --git a/examples/Metrics/test/HelloWorld.Test/HelloWorld.Tests.csproj b/examples/Metrics/test/HelloWorld.Test/HelloWorld.Tests.csproj index 31e123cf3..7a5090108 100644 --- a/examples/Metrics/test/HelloWorld.Test/HelloWorld.Tests.csproj +++ b/examples/Metrics/test/HelloWorld.Test/HelloWorld.Tests.csproj @@ -1,6 +1,6 @@ - net6.0 + net6.0;net8.0 diff --git a/examples/Parameters/cfn/HelloWorld.Cfn/HelloWorld.Cfn.csproj b/examples/Parameters/cfn/HelloWorld.Cfn/HelloWorld.Cfn.csproj index a46da41e4..cf56c3616 100644 --- a/examples/Parameters/cfn/HelloWorld.Cfn/HelloWorld.Cfn.csproj +++ b/examples/Parameters/cfn/HelloWorld.Cfn/HelloWorld.Cfn.csproj @@ -1,6 +1,6 @@ - net6.0 + net6.0;net8.0 true enable HelloWorld.Cfn diff --git a/examples/Parameters/src/HelloWorld/HelloWorld.csproj b/examples/Parameters/src/HelloWorld/HelloWorld.csproj index d4fcefec5..d9709c681 100644 --- a/examples/Parameters/src/HelloWorld/HelloWorld.csproj +++ b/examples/Parameters/src/HelloWorld/HelloWorld.csproj @@ -1,6 +1,6 @@ - net6.0 + net6.0;net8.0 true enable diff --git a/examples/Parameters/test/HelloWorld.Test/HelloWorld.Tests.csproj b/examples/Parameters/test/HelloWorld.Test/HelloWorld.Tests.csproj index 8ed6558af..0c7418eb5 100644 --- a/examples/Parameters/test/HelloWorld.Test/HelloWorld.Tests.csproj +++ b/examples/Parameters/test/HelloWorld.Test/HelloWorld.Tests.csproj @@ -1,6 +1,6 @@ - net6.0 + net6.0;net8.0 diff --git a/examples/ServerlessApi/src/LambdaPowertoolsAPI/LambdaPowertoolsAPI.csproj b/examples/ServerlessApi/src/LambdaPowertoolsAPI/LambdaPowertoolsAPI.csproj index 489c9a7b6..3609e4422 100644 --- a/examples/ServerlessApi/src/LambdaPowertoolsAPI/LambdaPowertoolsAPI.csproj +++ b/examples/ServerlessApi/src/LambdaPowertoolsAPI/LambdaPowertoolsAPI.csproj @@ -1,7 +1,7 @@ Exe - net6.0 + net6.0;net8.0 enable enable true diff --git a/examples/ServerlessApi/test/LambdaPowertoolsAPI.Tests/LambdaPowertoolsAPI.Tests.csproj b/examples/ServerlessApi/test/LambdaPowertoolsAPI.Tests/LambdaPowertoolsAPI.Tests.csproj index 070787b5f..de239d45c 100644 --- a/examples/ServerlessApi/test/LambdaPowertoolsAPI.Tests/LambdaPowertoolsAPI.Tests.csproj +++ b/examples/ServerlessApi/test/LambdaPowertoolsAPI.Tests/LambdaPowertoolsAPI.Tests.csproj @@ -1,6 +1,6 @@ - net6.0 + net6.0;net8.0 enable enable False diff --git a/examples/Tracing/src/HelloWorld/HelloWorld.csproj b/examples/Tracing/src/HelloWorld/HelloWorld.csproj index 81a344457..32beb88bb 100644 --- a/examples/Tracing/src/HelloWorld/HelloWorld.csproj +++ b/examples/Tracing/src/HelloWorld/HelloWorld.csproj @@ -1,6 +1,6 @@ - net6.0 + net6.0;net8.0 true enable diff --git a/examples/Tracing/test/HelloWorld.Test/HelloWorld.Tests.csproj b/examples/Tracing/test/HelloWorld.Test/HelloWorld.Tests.csproj index 31e123cf3..7a5090108 100644 --- a/examples/Tracing/test/HelloWorld.Test/HelloWorld.Tests.csproj +++ b/examples/Tracing/test/HelloWorld.Test/HelloWorld.Tests.csproj @@ -1,6 +1,6 @@ - net6.0 + net6.0;net8.0 From 1a490e93687dd93ac89bd2d54dfa97179422b7fb Mon Sep 17 00:00:00 2001 From: Henrique Graca <999396+hjgraca@users.noreply.github.com> Date: Wed, 17 Jan 2024 20:26:40 +0000 Subject: [PATCH 12/20] with restore in test --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 68efa4354..15d8cff7d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,7 +29,7 @@ jobs: - name: Test Examples run: dotnet test ../examples/ - name: Test & Code Coverage - run: dotnet test --collect:"XPlat Code Coverage" -r ./codecov --no-restore --verbosity normal + run: dotnet test --collect:"XPlat Code Coverage" -r ./codecov --verbosity normal - name: Codecov uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # 3.1.0 with: From a72a6121fc0095ff5001ff104ef775f12416dbf7 Mon Sep 17 00:00:00 2001 From: Henrique Graca <999396+hjgraca@users.noreply.github.com> Date: Thu, 18 Jan 2024 11:55:03 +0000 Subject: [PATCH 13/20] remove restore. codecov in framework path --- .github/workflows/build.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 15d8cff7d..7ac189a68 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,14 +22,12 @@ jobs: dotnet-version: | 6.0.405 8.0.101 - - name: Install solution dependencies - run: dotnet restore - name: Build - run: dotnet build --configuration Release --no-restore + run: dotnet build --configuration Release - name: Test Examples run: dotnet test ../examples/ - name: Test & Code Coverage - run: dotnet test --collect:"XPlat Code Coverage" -r ./codecov --verbosity normal + run: dotnet test --collect:"XPlat Code Coverage" -r codecov --verbosity normal - name: Codecov uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # 3.1.0 with: From 3b20c091969b826e9e58b2edfabd5e9b4ef3bd1e Mon Sep 17 00:00:00 2001 From: Henrique Graca <999396+hjgraca@users.noreply.github.com> Date: Thu, 18 Jan 2024 12:56:43 +0000 Subject: [PATCH 14/20] trying to bring back --no-restore. Fixing test path --- .github/workflows/build.yml | 6 ++++-- .../Core/PowertoolsEnvironmentTest.cs | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7ac189a68..279aa1270 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,12 +22,14 @@ jobs: dotnet-version: | 6.0.405 8.0.101 + - name: Install solution dependencies + run: dotnet restore - name: Build - run: dotnet build --configuration Release + run: dotnet build --configuration Release --no-restore - name: Test Examples run: dotnet test ../examples/ - name: Test & Code Coverage - run: dotnet test --collect:"XPlat Code Coverage" -r codecov --verbosity normal + run: dotnet test --collect:"XPlat Code Coverage" -r codecov --no-restore --verbosity normal - name: Codecov uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # 3.1.0 with: diff --git a/libraries/tests/AWS.Lambda.Powertools.Common.Tests/Core/PowertoolsEnvironmentTest.cs b/libraries/tests/AWS.Lambda.Powertools.Common.Tests/Core/PowertoolsEnvironmentTest.cs index df41e2538..571b936f0 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Common.Tests/Core/PowertoolsEnvironmentTest.cs +++ b/libraries/tests/AWS.Lambda.Powertools.Common.Tests/Core/PowertoolsEnvironmentTest.cs @@ -5,11 +5,19 @@ using System.Xml.Linq; using System.Xml.XPath; using Xunit; +using Xunit.Abstractions; namespace AWS.Lambda.Powertools.Common.Tests; public class PowertoolsEnvironmentTest : IDisposable { + private readonly ITestOutputHelper _testOutputHelper; + + public PowertoolsEnvironmentTest(ITestOutputHelper testOutputHelper) + { + _testOutputHelper = testOutputHelper; + } + [Fact] public void Set_Execution_Environment() { @@ -69,7 +77,14 @@ public void Should_Use_Aspect_Injector_281() { // This test must be present until Issue: https://github.com/pamidur/aspect-injector/issues/220 is fixed - var directory = Path.GetFullPath("../../../../../src/Directory.Packages.props"); + var path = "../../../../../src/Directory.Packages.props"; + // Test to see if running in CI/CD and add an extra ../ + if (Environment.CurrentDirectory.EndsWith("codecov")) + { + path = "../../../../../../src/Directory.Packages.props"; + } + + var directory = Path.GetFullPath(path); var doc = XDocument.Load(directory); var packageReference = doc.XPathSelectElements("//PackageVersion") From 4e6ca8ffdfcb8bfe4144c5fda7e8e7d04a95d85a Mon Sep 17 00:00:00 2001 From: Henrique Graca <999396+hjgraca@users.noreply.github.com> Date: Thu, 18 Jan 2024 13:00:04 +0000 Subject: [PATCH 15/20] restore again --- .github/workflows/build.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 279aa1270..7ac189a68 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,14 +22,12 @@ jobs: dotnet-version: | 6.0.405 8.0.101 - - name: Install solution dependencies - run: dotnet restore - name: Build - run: dotnet build --configuration Release --no-restore + run: dotnet build --configuration Release - name: Test Examples run: dotnet test ../examples/ - name: Test & Code Coverage - run: dotnet test --collect:"XPlat Code Coverage" -r codecov --no-restore --verbosity normal + run: dotnet test --collect:"XPlat Code Coverage" -r codecov --verbosity normal - name: Codecov uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # 3.1.0 with: From 98e0e92bb2ca2d168f2becc5c7b4bb2848bb8fce Mon Sep 17 00:00:00 2001 From: Henrique Graca <999396+hjgraca@users.noreply.github.com> Date: Thu, 18 Jan 2024 15:10:21 +0000 Subject: [PATCH 16/20] revert test. update -r to --results-directory ../../codecov. https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-test#options --- .github/workflows/build.yml | 2 +- .../Core/PowertoolsEnvironmentTest.cs | 17 +---------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7ac189a68..d69477fbc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,7 +27,7 @@ jobs: - name: Test Examples run: dotnet test ../examples/ - name: Test & Code Coverage - run: dotnet test --collect:"XPlat Code Coverage" -r codecov --verbosity normal + run: dotnet test --collect:"XPlat Code Coverage" --results-directory ../../codecov --verbosity normal - name: Codecov uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # 3.1.0 with: diff --git a/libraries/tests/AWS.Lambda.Powertools.Common.Tests/Core/PowertoolsEnvironmentTest.cs b/libraries/tests/AWS.Lambda.Powertools.Common.Tests/Core/PowertoolsEnvironmentTest.cs index 571b936f0..df41e2538 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Common.Tests/Core/PowertoolsEnvironmentTest.cs +++ b/libraries/tests/AWS.Lambda.Powertools.Common.Tests/Core/PowertoolsEnvironmentTest.cs @@ -5,19 +5,11 @@ using System.Xml.Linq; using System.Xml.XPath; using Xunit; -using Xunit.Abstractions; namespace AWS.Lambda.Powertools.Common.Tests; public class PowertoolsEnvironmentTest : IDisposable { - private readonly ITestOutputHelper _testOutputHelper; - - public PowertoolsEnvironmentTest(ITestOutputHelper testOutputHelper) - { - _testOutputHelper = testOutputHelper; - } - [Fact] public void Set_Execution_Environment() { @@ -77,14 +69,7 @@ public void Should_Use_Aspect_Injector_281() { // This test must be present until Issue: https://github.com/pamidur/aspect-injector/issues/220 is fixed - var path = "../../../../../src/Directory.Packages.props"; - // Test to see if running in CI/CD and add an extra ../ - if (Environment.CurrentDirectory.EndsWith("codecov")) - { - path = "../../../../../../src/Directory.Packages.props"; - } - - var directory = Path.GetFullPath(path); + var directory = Path.GetFullPath("../../../../../src/Directory.Packages.props"); var doc = XDocument.Load(directory); var packageReference = doc.XPathSelectElements("//PackageVersion") From 42e1582e7db105e63b5e27cce0025caf6db49f75 Mon Sep 17 00:00:00 2001 From: Henrique Graca <999396+hjgraca@users.noreply.github.com> Date: Thu, 18 Jan 2024 15:15:43 +0000 Subject: [PATCH 17/20] fix path codecov --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d69477fbc..e831d3669 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,7 +27,7 @@ jobs: - name: Test Examples run: dotnet test ../examples/ - name: Test & Code Coverage - run: dotnet test --collect:"XPlat Code Coverage" --results-directory ../../codecov --verbosity normal + run: dotnet test --collect:"XPlat Code Coverage" --results-directory ./codecov --verbosity normal - name: Codecov uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # 3.1.0 with: From 959db8e7d9f26af47d4df53d8a2510303963f569 Mon Sep 17 00:00:00 2001 From: Henrique Graca <999396+hjgraca@users.noreply.github.com> Date: Thu, 18 Jan 2024 15:40:59 +0000 Subject: [PATCH 18/20] Update tracing.md Auto-disable when not running in AWS Lambda environment Signed-off-by: Henrique Graca <999396+hjgraca@users.noreply.github.com> --- docs/core/tracing.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/core/tracing.md b/docs/core/tracing.md index 30a709cd4..9815b49a1 100644 --- a/docs/core/tracing.md +++ b/docs/core/tracing.md @@ -15,6 +15,7 @@ a provides functionality to reduce the overhead of performing common tracing tas * Capture function responses and full exceptions as metadata. * Better experience when developing with multiple threads. * Auto-patch supported modules by AWS X-Ray +* Auto-disable when not running in AWS Lambda environment ## Installation From 1be562f3f47881443a1b0f77dc3251f8a4599e1a Mon Sep 17 00:00:00 2001 From: Henrique Graca <999396+hjgraca@users.noreply.github.com> Date: Mon, 5 Feb 2024 16:20:39 +0000 Subject: [PATCH 19/20] Update batch-processing docs Signed-off-by: Henrique Graca <999396+hjgraca@users.noreply.github.com> --- docs/utilities/batch-processing.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/utilities/batch-processing.md b/docs/utilities/batch-processing.md index 2c3e460bc..eb18eb7c9 100644 --- a/docs/utilities/batch-processing.md +++ b/docs/utilities/batch-processing.md @@ -62,6 +62,20 @@ This behavior changes when you enable Report Batch Item Failures feature in your You can find more details on how Lambda works with either [SQS](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html){target="_blank"}, [Kinesis](https://docs.aws.amazon.com/lambda/latest/dg/with-kinesis.html){target="_blank"}, or [DynamoDB](https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html){target="_blank"} in the AWS Documentation. +## Installation + +You should install with NuGet: + +```powershell +Install-Package AWS.Lambda.Powertools.BatchProcessing +``` + +Or via the .NET Core command line interface: + +```bash +dotnet add package AWS.Lambda.Powertools.BatchProcessing +``` + ## Getting started For this feature to work, you need to **(1)** configure your Lambda function event source to use `ReportBatchItemFailures`, and **(2)** return [a specific response](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#services-sqs-batchfailurereporting){target="_blank" rel="nofollow"} to report which records failed to be processed. From a331cb31daf466b556dcc817fef4eb18d6975ce3 Mon Sep 17 00:00:00 2001 From: H1Gdev Date: Thu, 15 Feb 2024 19:31:49 +0900 Subject: [PATCH 20/20] fix upper snake case to camel case. --- docs/core/logging.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/logging.md b/docs/core/logging.md index d4e85f98b..1e6153620 100644 --- a/docs/core/logging.md +++ b/docs/core/logging.md @@ -223,7 +223,7 @@ for known event sources, where either a request ID or X-Ray Trace ID are present */ public class Function { - [Logging(CorrelationIdPath = CorrelationIdPaths.API_GATEWAY_REST)] + [Logging(CorrelationIdPath = CorrelationIdPaths.ApiGatewayRest)] public async Task FunctionHandler (APIGatewayProxyRequest apigProxyEvent, ILambdaContext context) {