Skip to content

Commit

Permalink
feat: disable AOT (#294)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanJosipovic authored Sep 30, 2024
1 parent 06a409b commit 7e262c1
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 16 deletions.
35 changes: 32 additions & 3 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ on:
types: [opened, reopened, synchronize]
merge_group:

permissions:
# deployments permission to deploy GitHub pages website
deployments: write
# contents permission to update benchmark contents in gh-pages branch
contents: write

jobs:
build-test:
name: Build & Test
Expand Down Expand Up @@ -55,9 +61,32 @@ jobs:
file: coverage.cobertura.xml
fail_ci_if_error: true

- name: Benchmark
- name: Publish Benchmark
working-directory: benchmarks/oidc-guard-benchmarks
run: dotnet run -c Release
run: dotnet publish -c Release -o bin/publish

- name: Chmod Benchmark
working-directory: benchmarks/oidc-guard-benchmarks/bin/publish
run: chmod +x oidc-guard-benchmarks

- name: Run Benchmark
working-directory: benchmarks/oidc-guard-benchmarks/bin/publish
run: ./oidc-guard-benchmarks

- name: Store benchmark result
if: github.ref == 'refs/heads/main'
uses: benchmark-action/github-action-benchmark@v1
with:
name: Benchmark.Net Benchmark
tool: 'benchmarkdotnet'
output-file-path: benchmarks/oidc-guard-benchmarks/bin/publish/BenchmarkDotNet.Artifacts/results/Sample.Benchmarks-report-full-compressed.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
# Show alert with commit comment on detecting possible performance regression
alert-threshold: '120%'
comment-on-alert: true
fail-on-alert: false
alert-comment-cc-users: '@IvanJosipovic'

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
Expand All @@ -73,7 +102,7 @@ jobs:
if: ${{ github.event_name != 'pull_request' }}
name: Create Release
runs-on: ubuntu-latest
needs: build-test
needs: [build-test]
steps:
- uses: actions/checkout@v4

Expand Down
7 changes: 7 additions & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="bdn-nightly" value="https://www.myget.org/F/benchmarkdotnet/api/v3/index.json" />
</packageSources>
</configuration>
4 changes: 4 additions & 0 deletions benchmarks/oidc-guard-benchmarks/BenchmarkCookie.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using FluentAssertions;
using Microsoft.Extensions.Logging;
using oidc_guard_tests.Infra;
using System.Net;

namespace oidc_guard_benchmarks;

[JsonExporterAttribute.FullCompressed]
[MemoryDiagnoser]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[SimpleJob(RuntimeMoniker.NativeAot90)]
public class BenchmarkCookie
{
private HttpClient client = default!;
Expand Down
4 changes: 4 additions & 0 deletions benchmarks/oidc-guard-benchmarks/BenchmarkJWT.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using Microsoft.Extensions.Logging;
using Microsoft.Net.Http.Headers;
using oidc_guard_tests.Infra;
using System.Security.Claims;

namespace oidc_guard_benchmarks;

[JsonExporterAttribute.FullCompressed]
[MemoryDiagnoser]
[SimpleJob(RuntimeMoniker.Net90, baseline: true)]
[SimpleJob(RuntimeMoniker.NativeAot90)]
public class BenchmarkJWT
{
private HttpClient client = default!;
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/oidc-guard-benchmarks/oidc-guard-benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<RootNamespace>oidc_guard_benchmarks</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
<PackageReference Include="BenchmarkDotNet" Version="0.14.1-nightly.20240925.188" />
</ItemGroup>

<ItemGroup>
Expand Down
18 changes: 10 additions & 8 deletions src/oidc-guard/oidc-guard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<EnableConfigurationBindingGenerator>true</EnableConfigurationBindingGenerator>
<EnableRequestDelegateGenerator>true</EnableRequestDelegateGenerator>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
<RootNamespace>oidc_guard</RootNamespace>
<UserSecretsId>a70c2d04-572e-41af-8710-66bacf303453</UserSecretsId>
<PublishReadyToRun>true</PublishReadyToRun>
<EnableRequestDelegateGenerator>true</EnableRequestDelegateGenerator>
<EnableConfigurationBindingGenerator>true</EnableConfigurationBindingGenerator>
<IsAotCompatible>true</IsAotCompatible>
<PublishAot>true</PublishAot>
<JsonSerializerIsReflectionEnabledByDefault>false</JsonSerializerIsReflectionEnabledByDefault>
<Nullable>enable</Nullable>
<OptimizationPreference>Speed</OptimizationPreference>
<PublishAot>false</PublishAot>
<PublishIISAssets>false</PublishIISAssets>
<PublishReadyToRun>true</PublishReadyToRun>
<RootNamespace>oidc_guard</RootNamespace>
<SelfContained>true</SelfContained>
<SuppressTrimAnalysisWarnings>false</SuppressTrimAnalysisWarnings>
<TrimmerSingleWarn>false</TrimmerSingleWarn>
<OptimizationPreference>Speed</OptimizationPreference>
<UserSecretsId>a70c2d04-572e-41af-8710-66bacf303453</UserSecretsId>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
Expand Down
2 changes: 1 addition & 1 deletion tests/oidc-guard-tests/EndToEndTraefik.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public async Task TokenInQuery()
}

//[Fact]
public async Task OIDC()
private async Task OIDC()
{
using var playwright = await Playwright.CreateAsync();

Expand Down
15 changes: 13 additions & 2 deletions tests/oidc-guard-tests/Infra/MyWebApplicationFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using oidc_guard;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace oidc_guard_tests.Infra;

Expand All @@ -20,10 +21,20 @@ protected override IHost CreateHost(IHostBuilder builder)
{
builder.ConfigureHostConfiguration(config =>
{
var data = new { Settings = settings };
var data = new SettingsObject { Settings = settings };

config.AddJsonStream(new MemoryStream(Encoding.UTF8.GetBytes(JsonSerializer.Serialize(data))));
config.AddJsonStream(new MemoryStream(Encoding.UTF8.GetBytes(JsonSerializer.Serialize(data, typeof(SettingsObject), FactoryJsonSerializerContext.Default))));
});
return base.CreateHost(builder);
}
}

public class SettingsObject
{
public Settings Settings { get; set; }

Check warning on line 34 in tests/oidc-guard-tests/Infra/MyWebApplicationFactory.cs

View workflow job for this annotation

GitHub Actions / Build & Test

Non-nullable property 'Settings' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
}

[JsonSerializable(typeof(SettingsObject))]
internal partial class FactoryJsonSerializerContext : JsonSerializerContext
{
}

0 comments on commit 7e262c1

Please sign in to comment.