Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
dotnet-version: 10.0.x
- name: download JSON submodule
run: git submodule update --init ./src/Helldivers-2-Models/json
- name: Restore dependencies
Expand All @@ -36,3 +36,22 @@
retention-days: 5
name: openapi-schemas
path: docs/openapi/

docker-build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./src/Helldivers-2-API/Dockerfile
push: false
tags: helldivers-api:test
cache-from: type=gha
cache-to: type=gha,mode=max
2 changes: 1 addition & 1 deletion .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
dotnet-version: 10.0.x
- name: Generate OpenAPI JSON files
run: dotnet build -c Debug
- name: Copy README
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
dotnet-version: '10.0.x'

- name: Download JSON submodule
run: git submodule update --init ./src/Helldivers-2-Models/json
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

Expand Down
6 changes: 4 additions & 2 deletions src/Helldivers-2-API/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM mcr.microsoft.com/dotnet/runtime-deps:9.0-alpine-extra AS base
FROM alpine:latest AS base
USER $APP_UID
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build
FROM mcr.microsoft.com/dotnet/sdk:10.0-alpine-aot AS build
RUN apk add --upgrade --no-cache build-base clang zlib-dev
ARG BUILD_CONFIGURATION=Release
ARG BUILD_RUNTIME=linux-musl-x64
Expand Down Expand Up @@ -35,6 +35,8 @@ RUN dotnet build "Helldivers-2-API.csproj" --no-restore -r $BUILD_RUNTIME -c $BU

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
ARG BUILD_RUNTIME=linux-musl-x64
ARG VERSION=0.0.0
RUN dotnet publish "Helldivers-2-API.csproj" /p:Version="$VERSION" --no-restore --self-contained -r $BUILD_RUNTIME -c $BUILD_CONFIGURATION -o /app/publish

FROM base AS final
Expand Down
13 changes: 7 additions & 6 deletions src/Helldivers-2-API/Helldivers-2-API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<PublishAot>true</PublishAot>
<RootNamespace>Helldivers.API</RootNamespace>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<IncludeOpenAPIAnalyzers>true</IncludeOpenAPIAnalyzers>
<EnableConfigurationBindingGenerator>true</EnableConfigurationBindingGenerator>
<PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>

<!-- Only generate OpenAPI docs for DEBUG builds -->
Expand All @@ -23,8 +23,9 @@

<!-- Dependencies for all build configurations -->
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="10.0.0" />
<PackageReference Include="NetEscapades.AspNetCore.SecurityHeaders" Version="1.2.0" />
<PackageReference Include="prometheus-net.AspNetCore" Version="8.2.1" />
<ProjectReference Include="..\Helldivers-2-Models\Helldivers-2-Models.csproj" />
<ProjectReference Include="..\Helldivers-2-Core\Helldivers-2-Core.csproj" />
Expand All @@ -36,12 +37,12 @@

<!-- Only include swagger dependencies in DEBUG builds -->
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.6" />
<PackageReference Include="Microsoft.Extensions.ApiDescription.Server" Version="9.0.6">
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.ApiDescription.Server" Version="10.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NSwag.AspNetCore" Version="14.4.0" />
<PackageReference Include="NSwag.AspNetCore" Version="14.6.2" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NJsonSchema;
#if DEBUG
using NJsonSchema;
using NJsonSchema.Generation.TypeMappers;
using System.Collections.ObjectModel;

Expand Down Expand Up @@ -34,3 +35,4 @@ public void GenerateSchema(JsonSchema schema, TypeMapperContext context)
schema.ExtensionData ??= new Dictionary<string, object>()!;
}
}
#endif
7 changes: 5 additions & 2 deletions src/Helldivers-2-API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@
options.ForwardLimit = 999;
options.OriginalForHeaderName = "Fly-Client-IP";
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor;
options.KnownNetworks.Add(new IPNetwork(IPAddress.Any, 0));
options.KnownNetworks.Add(new IPNetwork(IPAddress.IPv6Any, 0));
options.KnownIPNetworks.Add(new System.Net.IPNetwork(IPAddress.Any, 0));
options.KnownIPNetworks.Add(new System.Net.IPNetwork(IPAddress.IPv6Any, 0));
});

// This configuration is bound here so that source generators kick in.
Expand Down Expand Up @@ -219,6 +219,9 @@
// Ensure web applications can access the API by setting CORS headers.
app.UseCors();

// Add various security-related headers.
app.UseSecurityHeaders();

// Make sure ASP.NET Core uses the correct addresses internally rather than Fly's proxy
app.UseForwardedHeaders();

Expand Down
4 changes: 2 additions & 2 deletions src/Helldivers-2-CI/Helldivers-2-CI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>Helldivers_2_CI</RootNamespace>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.5" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.0" />
<ProjectReference Include="..\Helldivers-2-Sync\Helldivers-2-Sync.csproj" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Helldivers-2-Core/Helldivers-2-Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.0"/>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.0"/>
<ProjectReference Include="..\Helldivers-2-Models\Helldivers-2-Models.csproj"/>
</ItemGroup>

Expand Down
8 changes: 4 additions & 4 deletions src/Helldivers-2-SourceGen/Helldivers-2-SourceGen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0"/>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" Version="9.0.0" PrivateAssets="all" LocalSourceGenerators="true" />
<PackageReference Include="System.Text.Encodings.Web" Version="9.0.0" PrivateAssets="all" LocalSourceGenerators="true" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.0" PrivateAssets="all" LocalSourceGenerators="true" />
<PackageReference Include="System.Text.Json" Version="10.0.0" PrivateAssets="all" LocalSourceGenerators="true" />
<PackageReference Include="System.Text.Encodings.Web" Version="10.0.0" PrivateAssets="all" LocalSourceGenerators="true" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="10.0.0" PrivateAssets="all" LocalSourceGenerators="true" />
</ItemGroup>

<!-- Include each nuget reference with property 'LocalSourceGenerators' into final-->
Expand Down
9 changes: 4 additions & 5 deletions src/Helldivers-2-Sync/Helldivers-2-Sync.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.0"/>
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.0"/>
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.0"/>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0"/>
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.0"/>
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="10.0.0"/>
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.0"/>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.0"/>
<ProjectReference Include="..\Helldivers-2-Core\Helldivers-2-Core.csproj" />
<ProjectReference Include="..\Helldivers-2-Models\Helldivers-2-Models.csproj"/>
</ItemGroup>
Expand Down
14 changes: 7 additions & 7 deletions src/Helldivers-2-Sync/Hosted/ArrowHeadSyncService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ private static partial void LogFailedToLoadTranslation(ILogger logger, Exception
/// <inheritdoc cref="BackgroundService.ExecuteAsync(CancellationToken)" />
protected override async Task ExecuteAsync(CancellationToken cancellationToken)
{

var delay = TimeSpan.FromSeconds(configuration.Value.IntervalSeconds);

LogRunAtInterval(logger, delay);
Expand Down Expand Up @@ -113,11 +112,12 @@ private async Task SynchronizeAsync(IServiceProvider services, CancellationToken
cancellationToken
);

var spaceStations = await configuration.Value.SpaceStations.ToAsyncEnumerable().ToDictionaryAwaitAsync(ValueTask.FromResult, async key =>
await DownloadTranslations<SpaceStation>(
async language => await api.LoadSpaceStations(season, key, language, cancellationToken),
cancellationToken
), cancellationToken: cancellationToken);
var spaceStations = await configuration.Value.SpaceStations.ToAsyncEnumerable().ToDictionaryAsync(
static (key, _) => ValueTask.FromResult(key), async (key, stoppingToken) =>
await DownloadTranslations<SpaceStation>(
async language => await api.LoadSpaceStations(season, key, language, stoppingToken),
stoppingToken
), cancellationToken: cancellationToken);

await storage.UpdateStores(
rawWarId,
Expand Down Expand Up @@ -152,7 +152,7 @@ private async Task<Dictionary<string, Memory<byte>>> DownloadTranslations<T>(Fun
return new KeyValuePair<string, Memory<byte>?>(language, null);
}
})
.SelectAwait(async task => await task)
.Select(async (task, stoppingToken) => await task.WaitAsync(stoppingToken))
.Where(pair => pair.Value is not null)
.ToDictionaryAsync(pair => pair.Key, pair => pair.Value.GetValueOrDefault(),
cancellationToken: cancellationToken);
Expand Down
Loading