Skip to content

Commit 1a8c29c

Browse files
authored
Merge pull request #813 from hjgraca/chore/update-examples-130
chore: Update examples for release 1.30 and add workflows
2 parents d922246 + 15238b8 commit 1a8c29c

File tree

14 files changed

+185
-22
lines changed

14 files changed

+185
-22
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ jobs:
3939
- name: Test & Code Coverage
4040
run: dotnet test --no-restore --filter "Category!=E2E" --collect:"XPlat Code Coverage" --results-directory ./codecov --verbosity normal
4141

42-
- name: Test Examples
43-
run: dotnet test ../examples/ --verbosity normal
44-
4542
- name: Codecov
4643
uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # 5.4.0
4744
with:

.github/workflows/examples-tests.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Examples Tests
2+
3+
on:
4+
push:
5+
paths:
6+
- "examples/**"
7+
branches: [develop]
8+
pull_request:
9+
paths:
10+
- "examples/**"
11+
branches: [develop]
12+
13+
defaults:
14+
run:
15+
working-directory: ./examples
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
build:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
25+
26+
- name: Setup .NET SDK
27+
uses: actions/setup-dotnet@3951f0dfe7a07e2313ec93c75700083e2005cbab # 4.3.0
28+
with:
29+
dotnet-version: |
30+
6.0.x
31+
8.0.x
32+
33+
- name: Install dependencies
34+
run: dotnet restore
35+
36+
- name: Build
37+
run: dotnet build --configuration Release --no-restore /tl
38+
39+
- name: Test Examples
40+
run: dotnet test --no-restore --verbosity normal
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# PROCESS
2+
#
3+
# 1. Build and pack all libraries in the solution
4+
# 2. Set up examples to use these local packages
5+
# 3. Run tests on examples to verify they work with the latest code
6+
# 4. Publish packages to GitHub Packages (on develop branch only)
7+
8+
# USAGE
9+
#
10+
# This workflow is triggered on push to the develop branch or manually via workflow_dispatch.
11+
12+
name: Publish Packages and Examples Tests
13+
14+
on:
15+
workflow_dispatch:
16+
push:
17+
paths:
18+
- "libraries/**"
19+
branches:
20+
- develop
21+
22+
permissions:
23+
contents: read
24+
25+
jobs:
26+
pack-libraries:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
31+
32+
- name: Setup .NET
33+
uses: actions/setup-dotnet@3951f0dfe7a07e2313ec93c75700083e2005cbab # 4.3.0
34+
with:
35+
dotnet-version: '8.x'
36+
37+
- name: Build libraries
38+
run: dotnet build ./libraries/ --configuration Release
39+
40+
- name: Pack libraries
41+
run: |
42+
mkdir -p ./packages
43+
VERSION_SUFFIX=${{ github.run_id }}
44+
dotnet pack ./libraries/ --configuration Release --no-build --output ./packages --version-suffix $VERSION_SUFFIX
45+
46+
- name: Upload packages
47+
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 #4.6.1
48+
with:
49+
name: nuget-packages
50+
path: ./packages/
51+
52+
run-tests:
53+
permissions:
54+
id-token: write
55+
runs-on: ubuntu-latest
56+
needs: pack-libraries
57+
steps:
58+
- name: Checkout code
59+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
60+
61+
- name: Set up .NET
62+
uses: actions/setup-dotnet@3951f0dfe7a07e2313ec93c75700083e2005cbab # 4.3.0
63+
with:
64+
dotnet-version: '8.x'
65+
66+
- name: Download packages
67+
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # 4.1.9
68+
with:
69+
name: nuget-packages
70+
path: ./packages/
71+
72+
- name: Configure local NuGet source
73+
run: |
74+
dotnet nuget add source ${{ github.workspace }}/packages --name local
75+
76+
- name: Update examples to use local packages
77+
run: |
78+
find ./examples -name "*.csproj" | while read project; do
79+
echo "Updating $project to use local packages"
80+
for package in ./packages/*.nupkg; do
81+
# Extract package name and version
82+
packageName=$(basename $package .nupkg | sed -E 's/(.*)\.([0-9]+\.[0-9]+\.[0-9]+.*)$/\1/')
83+
packageVersion=$(basename $package .nupkg | sed -E 's/(.*)\.([0-9]+\.[0-9]+\.[0-9]+.*)$/\2/')
84+
85+
# Use xmlstarlet to check and update package references
86+
if grep -q "<PackageReference.*Include=\"$packageName\"" "$project"; then
87+
echo " - Updating $packageName to version $packageVersion"
88+
dotnet add "$project" package "$packageName" --version "$packageVersion" --source ${{ github.workspace }}/packages
89+
fi
90+
done
91+
done
92+
93+
- name: Test Examples
94+
run: dotnet test ./examples/ --configuration Release --verbosity normal
95+
96+
publish-packages:
97+
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
98+
needs: run-tests
99+
runs-on: ubuntu-latest
100+
permissions:
101+
packages: write
102+
steps:
103+
- name: Download packages
104+
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # 4.1.9
105+
with:
106+
name: nuget-packages
107+
path: ./packages/
108+
109+
- name: Setup .NET
110+
uses: actions/setup-dotnet@3951f0dfe7a07e2313ec93c75700083e2005cbab # 4.3.0
111+
with:
112+
dotnet-version: '8.x'
113+
114+
- name: Setup GitHub Packages source
115+
run: |
116+
dotnet nuget add source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json \
117+
--name github \
118+
--username ${{ github.actor }} \
119+
--password ${{ secrets.GITHUB_TOKEN }}
120+
121+
- name: Publish packages to GitHub Packages
122+
run: |
123+
for package in ./packages/*.nupkg; do
124+
dotnet nuget push $package --source github --api-key ${{ secrets.GITHUB_TOKEN }}
125+
done

examples/AOT/AOT_Logging/src/AOT_Logging/AOT_Logging.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
<PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="1.10.0"/>
2121
<PackageReference Include="Amazon.Lambda.Core" Version="2.2.0"/>
2222
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.3"/>
23-
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.6.3" />
23+
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.6.5" />
2424
</ItemGroup>
2525
</Project>

examples/AOT/AOT_Metrics/src/AOT_Metrics/AOT_Metrics.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
<PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="1.10.0"/>
2121
<PackageReference Include="Amazon.Lambda.Core" Version="2.2.0"/>
2222
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.3"/>
23-
<PackageReference Include="AWS.Lambda.Powertools.Metrics" Version="1.7.1" />
23+
<PackageReference Include="AWS.Lambda.Powertools.Metrics" Version="2.0.0" />
2424
</ItemGroup>
2525
</Project>

examples/AOT/AOT_Tracing/src/AOT_Tracing/AOT_Tracing.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
<PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="1.10.0"/>
2121
<PackageReference Include="Amazon.Lambda.Core" Version="2.2.0"/>
2222
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.3"/>
23-
<PackageReference Include="AWS.Lambda.Powertools.Tracing" Version="1.6.0" />
23+
<PackageReference Include="AWS.Lambda.Powertools.Tracing" Version="1.6.1" />
2424
</ItemGroup>
2525
</Project>

examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<PackageReference Include="Amazon.Lambda.Core" Version="2.2.0" />
99
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.3" />
1010
<PackageReference Include="AWS.Lambda.Powertools.BatchProcessing" Version="1.1.2" />
11-
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.6.3" />
11+
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.6.5" />
1212
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
1313
</ItemGroup>
1414
</Project>

examples/Idempotency/src/HelloWorld/HelloWorld.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<PackageReference Include="Amazon.Lambda.Core" Version="2.2.0" />
99
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.7.0" />
1010
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.3" />
11-
<PackageReference Include="AWS.Lambda.Powertools.Idempotency" Version="1.2.2" />
12-
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.6.3" />
11+
<PackageReference Include="AWS.Lambda.Powertools.Idempotency" Version="1.3.0" />
12+
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.6.5" />
1313
</ItemGroup>
1414
</Project>

examples/Logging/src/HelloWorld/HelloWorld.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<PackageReference Include="Amazon.Lambda.Core" Version="2.2.0" />
99
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.7.0" />
1010
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.3" />
11-
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.6.3" />
11+
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.6.5" />
1212
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.301.18" />
1313
</ItemGroup>
1414
</Project>

examples/Metrics/src/HelloWorld/Function.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ public async Task<APIGatewayProxyResponse> FunctionHandler(APIGatewayProxyReques
8282

8383
// Add Metric to capture the amount of time
8484
Metrics.PushSingleMetric(
85-
metricName: "CallingIP",
85+
name: "CallingIP",
8686
value: 1,
8787
unit: MetricUnit.Count,
8888
service: "lambda-powertools-metrics-example",
89-
defaultDimensions: new Dictionary<string, string>
89+
dimensions: new Dictionary<string, string>
9090
{
9191
{ "Metric Type", "Single" }
9292
});
@@ -104,11 +104,11 @@ public async Task<APIGatewayProxyResponse> FunctionHandler(APIGatewayProxyReques
104104
try
105105
{
106106
Metrics.PushSingleMetric(
107-
metricName: "RecordsSaved",
107+
name: "RecordsSaved",
108108
value: 1,
109109
unit: MetricUnit.Count,
110110
service: "lambda-powertools-metrics-example",
111-
defaultDimensions: new Dictionary<string, string>
111+
dimensions: new Dictionary<string, string>
112112
{
113113
{ "Metric Type", "Single" }
114114
});

examples/Metrics/src/HelloWorld/HelloWorld.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<PackageReference Include="Amazon.Lambda.Core" Version="2.2.0" />
99
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.7.0" />
1010
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.3" />
11-
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.6.3" />
12-
<PackageReference Include="AWS.Lambda.Powertools.Metrics" Version="1.7.1" />
11+
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.6.5" />
12+
<PackageReference Include="AWS.Lambda.Powertools.Metrics" Version="2.0.0" />
1313
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.301.18" />
1414
</ItemGroup>
1515
</Project>

examples/ServerlessApi/src/LambdaPowertoolsAPI/LambdaPowertoolsAPI.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
</PropertyGroup>
1414
<ItemGroup>
1515
<PackageReference Include="Amazon.Lambda.AspNetCoreServer" Version="9.0.0" />
16-
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.6.3" />
17-
<PackageReference Include="AWS.Lambda.Powertools.Metrics" Version="1.7.1" />
18-
<PackageReference Include="AWS.Lambda.Powertools.Tracing" Version="1.6.0" />
16+
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.6.5" />
17+
<PackageReference Include="AWS.Lambda.Powertools.Metrics" Version="2.0.0" />
18+
<PackageReference Include="AWS.Lambda.Powertools.Tracing" Version="1.6.1" />
1919
</ItemGroup>
2020
</Project>

examples/Tracing/src/HelloWorld/HelloWorld.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<PackageReference Include="Amazon.Lambda.Core" Version="2.2.0" />
99
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.7.0" />
1010
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.3" />
11-
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.6.3" />
12-
<PackageReference Include="AWS.Lambda.Powertools.Tracing" Version="1.6.0" />
11+
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.6.5" />
12+
<PackageReference Include="AWS.Lambda.Powertools.Tracing" Version="1.6.1" />
1313
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.301.18" />
1414
</ItemGroup>
1515
</Project>

libraries/src/Directory.Build.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
44
<LangVersion>default</LangVersion>
55
<!-- Version is generated when packaging the individual csproj -->
6-
<Version>0.0.1</Version>
6+
<Version>$(Version)</Version>
77
<Authors>Amazon Web Services</Authors>
88
<Company>Amazon.com, Inc</Company>
99
<Title>Powertools for AWS Lambda (.NET)</Title>
@@ -16,6 +16,7 @@
1616
<PackageIcon>AWSLogo128x128.png</PackageIcon>
1717
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1818
<GenerateDocumentationFile>true</GenerateDocumentationFile>
19+
<VersionSuffix>$(VersionSuffix)</VersionSuffix>
1920

2021
</PropertyGroup>
2122

0 commit comments

Comments
 (0)