Skip to content

Commit c97a65c

Browse files
Test packages with OATS (#183)
* Run OATS tests using NuGet packages Refactor the OATS tests to consume the built NuGet packages, rather than compiling the distribution from source. * Fix warning Avoid warning when installing OATS by disabling the Go cache. * Bump Swashbuckle.AspNetCore Bump Swashbuckle.AspNetCore to the latest release. * Avoid ArgumentException Cherry-pick change from #145 to avoid `ArgumentException` when using v4 of the AWS SDK.
1 parent 255f30a commit c97a65c

File tree

9 files changed

+71
-5
lines changed

9 files changed

+71
-5
lines changed

.github/workflows/oats.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,36 @@ on:
1414
permissions: {}
1515

1616
jobs:
17+
18+
package:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
23+
- name: Checkout code
24+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
25+
with:
26+
fetch-depth: 0
27+
filter: 'tree:0'
28+
persist-credentials: false
29+
show-progress: false
30+
31+
- name: Setup .NET SDK
32+
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
33+
34+
- name: Build NuGet packages
35+
run: dotnet build --configuration Release
36+
37+
- name: Publish NuGet packages
38+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
39+
with:
40+
name: oats-packages
41+
path: ./artifacts/package/release
42+
if-no-files-found: error
43+
1744
acceptance-tests:
1845
runs-on: ubuntu-latest
46+
needs: package
1947
timeout-minutes: 20
2048

2149
steps:
@@ -27,9 +55,16 @@ jobs:
2755
persist-credentials: false
2856
show-progress: false
2957

58+
- name: Download packages
59+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
60+
with:
61+
name: oats-packages
62+
path: ./.packages
63+
3064
- name: Set up Go
3165
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
3266
with:
67+
cache: false
3368
go-version: '1.24'
3469

3570
- name: Install OATS
@@ -39,6 +74,8 @@ jobs:
3974
run: go install "github.com/grafana/oats@${OATS_VERSION}"
4075

4176
- name: Run acceptance tests
77+
env:
78+
BUILD_DISTRO_FROM_SOURCE: false
4279
run: oats --timeout=5m ./docker/docker-compose-aspnetcore
4380

4481
- name: Upload log file

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,3 +472,6 @@ $RECYCLE.BIN/
472472

473473
# Windows shortcuts
474474
*.lnk
475+
476+
# Local NuGet package source
477+
!.packages/*.s?nupkg

NuGet.config

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<clear />
5+
<add key="local" value=".packages" />
6+
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
7+
</packageSources>
8+
<packageSourceMapping>
9+
<packageSource key="local">
10+
<package pattern="Grafana.OpenTelemetry" />
11+
<package pattern="Grafana.OpenTelemetry.Base" />
12+
</packageSource>
13+
<packageSource key="NuGet">
14+
<package pattern="*" />
15+
</packageSource>
16+
</packageSourceMapping>
17+
</configuration>

docker/docker-compose-aspnetcore/.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@
2222
**/secrets.dev.yaml
2323
**/values.dev.yaml
2424
LICENSE
25-
README.md
25+
README.md
26+
!.packages/

docker/docker-compose-aspnetcore/docker-compose.oats.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ services:
44
build:
55
context: ../..
66
dockerfile: examples/net8.0/aspnetcore/Dockerfile
7+
args:
8+
DOTNET_PUBLISH_ARGS: "/p:BuildDistroFromSource=${BUILD_DISTRO_FROM_SOURCE:-true}"
79
environment:
810
- AWS_ACCESS_KEY_ID=localstack
911
- AWS_SECRET_ACCESS_KEY=localstack

docker/docker-compose-aspnetcore/docker-compose.self-contained.oats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services:
55
context: ../..
66
dockerfile: examples/net8.0/aspnetcore/Dockerfile
77
args:
8-
DOTNET_PUBLISH_ARGS: "--self-contained true /p:PublishSingleFile=true"
8+
DOTNET_PUBLISH_ARGS: "--self-contained true /p:PublishSingleFile=true /p:BuildDistroFromSource=${BUILD_DISTRO_FROM_SOURCE:-true}"
99
entrypoint: ./aspnetcore
1010
environment:
1111
- AWS_ACCESS_KEY_ID=localstack

docker/docker-compose-aspnetcore/docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ services:
44
build:
55
context: ../..
66
dockerfile: examples/net8.0/aspnetcore/Dockerfile
7+
args:
8+
DOTNET_PUBLISH_ARGS: "/p:BuildDistroFromSource=${BUILD_DISTRO_FROM_SOURCE:-true}"
79
depends_on:
810
- redis
911
- mssql

examples/net8.0/aspnetcore/Controllers/AwsController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public async Task<ActionResult<string[]>> ListBuckets()
1717
{
1818
var response = await client.ListBucketsAsync();
1919

20-
var buckets = response.Buckets.Select(o => o.BucketName).ToArray();
20+
var buckets = response.Buckets?.Select(o => o.BucketName).ToArray() ?? [];
2121

2222
logger.LogInformation("Found {Count} buckets.", buckets.Length);
2323

examples/net8.0/aspnetcore/aspnetcore.csproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@
1616
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
1717
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.12.0" />
1818
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.12.0" />
19-
<PackageReference Include="Swashbuckle.AspNetCore" Version="8.1.4" />
19+
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.3" />
2020
</ItemGroup>
2121

22-
<ItemGroup>
22+
<ItemGroup Condition=" '$(BuildDistroFromSource)' != 'false' ">
2323
<ProjectReference Include="..\..\..\src\Grafana.OpenTelemetry\Grafana.OpenTelemetry.csproj" />
2424
</ItemGroup>
2525

26+
<ItemGroup Condition=" '$(BuildDistroFromSource)' == 'false' ">
27+
<PackageReference Include="Grafana.OpenTelemetry" Version="*-*" />
28+
</ItemGroup>
29+
2630
</Project>

0 commit comments

Comments
 (0)