diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ce0080e6..e0f10f34 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,9 +39,6 @@ jobs: - name: Test & Code Coverage run: dotnet test --no-restore --filter "Category!=E2E" --collect:"XPlat Code Coverage" --results-directory ./codecov --verbosity normal - - name: Test Examples - run: dotnet test ../examples/ --verbosity normal - - name: Codecov uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # 5.4.0 with: diff --git a/.github/workflows/examples-tests.yml b/.github/workflows/examples-tests.yml new file mode 100644 index 00000000..c837733c --- /dev/null +++ b/.github/workflows/examples-tests.yml @@ -0,0 +1,40 @@ +name: Examples Tests + +on: + push: + paths: + - "examples/**" + branches: [develop] + pull_request: + paths: + - "examples/**" + branches: [develop] + +defaults: + run: + working-directory: ./examples + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup .NET SDK + uses: actions/setup-dotnet@3951f0dfe7a07e2313ec93c75700083e2005cbab # 4.3.0 + with: + dotnet-version: | + 6.0.x + 8.0.x + + - name: Install dependencies + run: dotnet restore + + - name: Build + run: dotnet build --configuration Release --no-restore /tl + + - name: Test Examples + run: dotnet test --no-restore --verbosity normal diff --git a/.github/workflows/publish-artifacts-examples-tests.yml b/.github/workflows/publish-artifacts-examples-tests.yml new file mode 100644 index 00000000..bd2f53de --- /dev/null +++ b/.github/workflows/publish-artifacts-examples-tests.yml @@ -0,0 +1,125 @@ +# PROCESS +# +# 1. Build and pack all libraries in the solution +# 2. Set up examples to use these local packages +# 3. Run tests on examples to verify they work with the latest code +# 4. Publish packages to GitHub Packages (on develop branch only) + +# USAGE +# +# This workflow is triggered on push to the develop branch or manually via workflow_dispatch. + +name: Publish Packages and Examples Tests + +on: + workflow_dispatch: + push: + paths: + - "libraries/**" + branches: + - develop + +permissions: + contents: read + +jobs: + pack-libraries: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup .NET + uses: actions/setup-dotnet@3951f0dfe7a07e2313ec93c75700083e2005cbab # 4.3.0 + with: + dotnet-version: '8.x' + + - name: Build libraries + run: dotnet build ./libraries/ --configuration Release + + - name: Pack libraries + run: | + mkdir -p ./packages + VERSION_SUFFIX=${{ github.run_id }} + dotnet pack ./libraries/ --configuration Release --no-build --output ./packages --version-suffix $VERSION_SUFFIX + + - name: Upload packages + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 #4.6.1 + with: + name: nuget-packages + path: ./packages/ + + run-tests: + permissions: + id-token: write + runs-on: ubuntu-latest + needs: pack-libraries + steps: + - name: Checkout code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Set up .NET + uses: actions/setup-dotnet@3951f0dfe7a07e2313ec93c75700083e2005cbab # 4.3.0 + with: + dotnet-version: '8.x' + + - name: Download packages + uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # 4.1.9 + with: + name: nuget-packages + path: ./packages/ + + - name: Configure local NuGet source + run: | + dotnet nuget add source ${{ github.workspace }}/packages --name local + + - name: Update examples to use local packages + run: | + find ./examples -name "*.csproj" | while read project; do + echo "Updating $project to use local packages" + for package in ./packages/*.nupkg; do + # Extract package name and version + packageName=$(basename $package .nupkg | sed -E 's/(.*)\.([0-9]+\.[0-9]+\.[0-9]+.*)$/\1/') + packageVersion=$(basename $package .nupkg | sed -E 's/(.*)\.([0-9]+\.[0-9]+\.[0-9]+.*)$/\2/') + + # Use xmlstarlet to check and update package references + if grep -q " - + diff --git a/examples/AOT/AOT_Metrics/src/AOT_Metrics/AOT_Metrics.csproj b/examples/AOT/AOT_Metrics/src/AOT_Metrics/AOT_Metrics.csproj index ec08ac52..c6463f13 100644 --- a/examples/AOT/AOT_Metrics/src/AOT_Metrics/AOT_Metrics.csproj +++ b/examples/AOT/AOT_Metrics/src/AOT_Metrics/AOT_Metrics.csproj @@ -20,6 +20,6 @@ - + \ No newline at end of file diff --git a/examples/AOT/AOT_Tracing/src/AOT_Tracing/AOT_Tracing.csproj b/examples/AOT/AOT_Tracing/src/AOT_Tracing/AOT_Tracing.csproj index 20100166..558effc2 100644 --- a/examples/AOT/AOT_Tracing/src/AOT_Tracing/AOT_Tracing.csproj +++ b/examples/AOT/AOT_Tracing/src/AOT_Tracing/AOT_Tracing.csproj @@ -20,6 +20,6 @@ - + \ No newline at end of file diff --git a/examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj b/examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj index d34e3e63..01b0ecf9 100644 --- a/examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj +++ b/examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj @@ -8,7 +8,7 @@ - + diff --git a/examples/Idempotency/src/HelloWorld/HelloWorld.csproj b/examples/Idempotency/src/HelloWorld/HelloWorld.csproj index 86f103f9..edf4ee5f 100644 --- a/examples/Idempotency/src/HelloWorld/HelloWorld.csproj +++ b/examples/Idempotency/src/HelloWorld/HelloWorld.csproj @@ -8,7 +8,7 @@ - - + + diff --git a/examples/Logging/src/HelloWorld/HelloWorld.csproj b/examples/Logging/src/HelloWorld/HelloWorld.csproj index 2fa0c42d..21b606a6 100644 --- a/examples/Logging/src/HelloWorld/HelloWorld.csproj +++ b/examples/Logging/src/HelloWorld/HelloWorld.csproj @@ -8,7 +8,7 @@ - + diff --git a/examples/Metrics/src/HelloWorld/Function.cs b/examples/Metrics/src/HelloWorld/Function.cs index f99cf395..9c797f6e 100644 --- a/examples/Metrics/src/HelloWorld/Function.cs +++ b/examples/Metrics/src/HelloWorld/Function.cs @@ -82,11 +82,11 @@ public async Task FunctionHandler(APIGatewayProxyReques // Add Metric to capture the amount of time Metrics.PushSingleMetric( - metricName: "CallingIP", + name: "CallingIP", value: 1, unit: MetricUnit.Count, service: "lambda-powertools-metrics-example", - defaultDimensions: new Dictionary + dimensions: new Dictionary { { "Metric Type", "Single" } }); @@ -104,11 +104,11 @@ public async Task FunctionHandler(APIGatewayProxyReques try { Metrics.PushSingleMetric( - metricName: "RecordsSaved", + name: "RecordsSaved", value: 1, unit: MetricUnit.Count, service: "lambda-powertools-metrics-example", - defaultDimensions: new Dictionary + dimensions: new Dictionary { { "Metric Type", "Single" } }); diff --git a/examples/Metrics/src/HelloWorld/HelloWorld.csproj b/examples/Metrics/src/HelloWorld/HelloWorld.csproj index 14d90df2..b914377b 100644 --- a/examples/Metrics/src/HelloWorld/HelloWorld.csproj +++ b/examples/Metrics/src/HelloWorld/HelloWorld.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/examples/ServerlessApi/src/LambdaPowertoolsAPI/LambdaPowertoolsAPI.csproj b/examples/ServerlessApi/src/LambdaPowertoolsAPI/LambdaPowertoolsAPI.csproj index f529937d..fd91c9de 100644 --- a/examples/ServerlessApi/src/LambdaPowertoolsAPI/LambdaPowertoolsAPI.csproj +++ b/examples/ServerlessApi/src/LambdaPowertoolsAPI/LambdaPowertoolsAPI.csproj @@ -13,8 +13,8 @@ - - - + + + diff --git a/examples/Tracing/src/HelloWorld/HelloWorld.csproj b/examples/Tracing/src/HelloWorld/HelloWorld.csproj index 0f61b8f4..af0b2435 100644 --- a/examples/Tracing/src/HelloWorld/HelloWorld.csproj +++ b/examples/Tracing/src/HelloWorld/HelloWorld.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/libraries/src/Directory.Build.props b/libraries/src/Directory.Build.props index ab02fae1..7d1e38a6 100644 --- a/libraries/src/Directory.Build.props +++ b/libraries/src/Directory.Build.props @@ -3,7 +3,7 @@ net6.0;net8.0 default - 0.0.1 + $(Version) Amazon Web Services Amazon.com, Inc Powertools for AWS Lambda (.NET) @@ -16,6 +16,7 @@ AWSLogo128x128.png true true + $(VersionSuffix)