Skip to content

Commit

Permalink
Merge pull request #315 from LiamMorrow/renovate/major-dotnet-monorepo
Browse files Browse the repository at this point in the history
chore(deps): update dotnet monorepo to v9 (major)
  • Loading branch information
LiamMorrow authored Nov 27, 2024
2 parents 0e8e5fb + b0743de commit 385573e
Show file tree
Hide file tree
Showing 27 changed files with 187 additions and 54 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/android-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Setup MAUI android
run: dotnet workload install android
# When running on a self hosted mac runner, the ios workload needs to be installed due to csproj configuration
Expand All @@ -26,7 +26,7 @@ jobs:
- name: Setup MAUI
run: dotnet workload restore
- name: Restore dependencies
run: dotnet restore -p:TargetFramework=net8.0-android
run: dotnet restore -p:TargetFramework=net9.0-android
- name: Setup JDK
uses: actions/setup-java@v4
with:
Expand All @@ -38,5 +38,5 @@ jobs:
run: npm i && npm run build
working-directory: ./LiftLog.Ui
- name: Build
run: dotnet build -p:TargetFramework=net8.0-android -f net8.0-android -p:BuildFor=android
run: dotnet build -p:TargetFramework=net9.0-android -f net9.0-android -p:BuildFor=android
working-directory: ./LiftLog.Maui
8 changes: 4 additions & 4 deletions .github/workflows/android-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Setup MAUI android
run: dotnet workload install android
# When running on a self hosted mac runner, the ios workload needs to be installed due to csproj configuration
Expand All @@ -26,7 +26,7 @@ jobs:
- name: Setup MAUI
run: dotnet workload restore
- name: Restore dependencies
run: dotnet restore -p:TargetFramework=net8.0-android
run: dotnet restore -p:TargetFramework=net9.0-android
- name: Put keystore
env:
ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
Expand All @@ -52,7 +52,7 @@ jobs:
run: dotnet build -c Release
working-directory: ./LiftLog.Ui
- name: Build
run: dotnet publish -p:TargetFramework=net8.0-android -f net8.0-android -c Release -p:BuildFor=android -p:AndroidKeyStore=true -p:AndroidSigningKeyStore=liftlog.keystore -p:AndroidSigningKeyAlias=liftlog -p:AndroidSigningKeyPass=env:KEYSTORE_PASS -p:AndroidSigningStorePass=env:KEYSTORE_PASS -p:UseSentryCLI=true -p:ApplicationDisplayVersion=${{ github.event.release.name }} -p:ApplicationVersion=${{ steps.buildNumber.outputs.build-number }}
run: dotnet publish -p:TargetFramework=net9.0-android -f net9.0-android -c Release -p:BuildFor=android -p:AndroidKeyStore=true -p:AndroidSigningKeyStore=liftlog.keystore -p:AndroidSigningKeyAlias=liftlog -p:AndroidSigningKeyPass=env:KEYSTORE_PASS -p:AndroidSigningStorePass=env:KEYSTORE_PASS -p:UseSentryCLI=true -p:ApplicationDisplayVersion=${{ github.event.release.name }} -p:ApplicationVersion=${{ steps.buildNumber.outputs.build-number }}
working-directory: ./LiftLog.Maui
env:
KEYSTORE_PASS: ${{ secrets.ANDROID_KEYSTORE_PASS }}
Expand All @@ -61,7 +61,7 @@ jobs:
uses: r0adkll/[email protected]
with:
packageName: com.limajuice.liftlog
releaseFiles: LiftLog.Maui/bin/Release/net8.0-android/publish/com.limajuice.liftlog-Signed.aab
releaseFiles: LiftLog.Maui/bin/Release/net9.0-android/publish/com.limajuice.liftlog-Signed.aab
track: internal
status: completed
serviceAccountJsonPlainText: ${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/api-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Build
run: dotnet build
working-directory: ./LiftLog.Api
2 changes: 1 addition & 1 deletion .github/workflows/api-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/api-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Restore dependencies
run: dotnet restore
working-directory: ./tests/LiftLog.Tests.Api
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/backupserver-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Build
run: dotnet build
working-directory: ./examples/remote-backup/reference-server-implementation/LiftLog.BackupServer
2 changes: 1 addition & 1 deletion .github/workflows/backupserver-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Install csharpier
run: dotnet tool restore
- name: Format with csharpier
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ios-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
Expand Down Expand Up @@ -47,7 +47,7 @@ jobs:
run: npm i && npm run build
working-directory: ./LiftLog.Ui
- name: Build
run: 'dotnet publish -c Release -f:net8.0-ios -p:ArchiveOnBuild=true -p:RuntimeIdentifier=ios-arm64 -p:CodesignKey="${{ secrets.APPLE_CODESIGN_KEY_NAME }}" -p:CodesignProvision="LiftLog"'
run: 'dotnet publish -c Release -f:net9.0-ios -p:ArchiveOnBuild=true -p:RuntimeIdentifier=ios-arm64 -p:CodesignKey="${{ secrets.APPLE_CODESIGN_KEY_NAME }}" -p:CodesignProvision="LiftLog"'
working-directory: ./LiftLog.Maui
- name: Delete keychain
if: always() # Always run this step to ensure the keychain is properly disposed of for self hosted runners
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ios-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
Expand Down Expand Up @@ -56,12 +56,12 @@ jobs:
run: dotnet build -c Release
working-directory: ./LiftLog.Ui
- name: Build
run: 'dotnet publish -c Release -f:net8.0-ios -p:ArchiveOnBuild=true -p:RuntimeIdentifier=ios-arm64 -p:CodesignKey="${{ secrets.APPLE_CODESIGN_KEY_NAME }}" -p:CodesignProvision="LiftLog" -p:UseSentryCLI=true -p:ApplicationDisplayVersion=${{ github.event.release.name }} -p:ApplicationVersion=${{ steps.buildNumber.outputs.build-number }}'
run: 'dotnet publish -c Release -f:net9.0-ios -p:ArchiveOnBuild=true -p:RuntimeIdentifier=ios-arm64 -p:CodesignKey="${{ secrets.APPLE_CODESIGN_KEY_NAME }}" -p:CodesignProvision="LiftLog" -p:UseSentryCLI=true -p:ApplicationDisplayVersion=${{ github.event.release.name }} -p:ApplicationVersion=${{ steps.buildNumber.outputs.build-number }}'
working-directory: ./LiftLog.Maui
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
- name: Upload with altool
run: xcrun altool --upload-app -f LiftLog.Maui/bin/Release/net8.0-ios/ios-arm64/publish/LiftLog.Maui.ipa -t ios -p '${{secrets.APPLE_UPLOAD_PASS}}' -u ${{secrets.APPLE_UPLOAD_USER}}
run: xcrun altool --upload-app -f LiftLog.Maui/bin/Release/net9.0-ios/ios-arm64/publish/LiftLog.Maui.ipa -t ios -p '${{secrets.APPLE_UPLOAD_PASS}}' -u ${{secrets.APPLE_UPLOAD_USER}}
- name: Delete keychain
if: always() # Always run this step to ensure the keychain is properly disposed of for self hosted runners
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ui-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Restore dependencies
run: dotnet restore
working-directory: ./LiftLog.Web
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ui-unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Restore dependencies
run: dotnet restore
working-directory: ./tests/LiftLog.Tests.App
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/web-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
- name: Build Tailwind
run: npm i && npm run build
working-directory: ./LiftLog.Ui
Expand All @@ -38,13 +38,13 @@ jobs:
run: dotnet publish -c Release
working-directory: ./LiftLog.Web
- name: Copy 404 page
run: cp ./404.html ./LiftLog.Web/bin/Release/net8.0/publish/wwwroot
run: cp ./404.html ./LiftLog.Web/bin/Release/net9.0/publish/wwwroot
- name: List files recusively
run: ls -R ./LiftLog.Web/bin/Release/net8.0/publish/wwwroot
run: ls -R ./LiftLog.Web/bin/Release/net9.0/publish/wwwroot
- name: Upload pages
uses: actions/upload-pages-artifact@v3
with:
path: ./LiftLog.Web/bin/Release/net8.0/publish/wwwroot
path: ./LiftLog.Web/bin/Release/net9.0/publish/wwwroot
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
134 changes: 134 additions & 0 deletions LiftLog.Api/Db/ConversionExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
namespace LiftLog.Api.Db;

using System.Globalization;
using System.Text;
using Microsoft.EntityFrameworkCore;

public static class ConversionExtensions
{
private static CultureInfo _culture = CultureInfo.InvariantCulture;

public static void ToSnakeCaseNames(this ModelBuilder modelBuilder)
{
_culture = CultureInfo.InvariantCulture;

SetNames(modelBuilder, NamingConvention.SnakeCase);
}

public static void ToLowerCaseNames(this ModelBuilder modelBuilder)
{
_culture = CultureInfo.InvariantCulture;

SetNames(modelBuilder, NamingConvention.LowerCase);
}

private static string? NameRewriter(this string name, NamingConvention naming)
{
if (string.IsNullOrEmpty(name))
return name;

return naming == NamingConvention.SnakeCase
? SnakeCaseNameRewriter(name)
: LowerCaseNameRewriter(name);
}

private enum NamingConvention
{
SnakeCase,
LowerCase,
}

private static void SetNames(ModelBuilder modelBuilder, NamingConvention naming)
{
_culture = CultureInfo.InvariantCulture;

foreach (var entity in modelBuilder.Model.GetEntityTypes())
{
entity.SetViewName(entity.GetViewName()?.NameRewriter(naming));
entity.SetSchema(entity.GetSchema()?.NameRewriter(naming));
entity.SetTableName(entity.GetTableName()?.NameRewriter(naming));

foreach (var property in entity!.GetProperties())
{
property.SetColumnName(property.GetColumnName()?.NameRewriter(naming));
}

foreach (var key in entity.GetKeys())
{
key.SetName(key.GetName()?.NameRewriter(naming));
}

foreach (var key in entity.GetForeignKeys())
{
key.SetConstraintName(key.GetConstraintName()?.NameRewriter(naming));
}

foreach (var index in entity.GetIndexes())
{
index.SetDatabaseName(index.GetDatabaseName()?.NameRewriter(naming));
}
}
}

private static string? LowerCaseNameRewriter(string name) => name.ToLower(_culture);

// https://github.com/efcore/EFCore.NamingConventions/blob/main/EFCore.NamingConventions/Internal/SnakeCaseNameRewriter.cs
private static string SnakeCaseNameRewriter(string name)
{
var builder = new StringBuilder(name.Length + Math.Min(2, name.Length / 5));
var previousCategory = default(UnicodeCategory?);

for (var currentIndex = 0; currentIndex < name.Length; currentIndex++)
{
var currentChar = name[currentIndex];
if (currentChar == '_')
{
builder.Append('_');
previousCategory = null;
continue;
}

var currentCategory = char.GetUnicodeCategory(currentChar);
switch (currentCategory)
{
case UnicodeCategory.UppercaseLetter:
case UnicodeCategory.TitlecaseLetter:
if (
previousCategory == UnicodeCategory.SpaceSeparator
|| previousCategory == UnicodeCategory.LowercaseLetter
|| previousCategory != UnicodeCategory.DecimalDigitNumber
&& previousCategory != null
&& currentIndex > 0
&& currentIndex + 1 < name.Length
&& char.IsLower(name[currentIndex + 1])
)
{
builder.Append('_');
}

currentChar = char.ToLower(currentChar, _culture);
break;

case UnicodeCategory.LowercaseLetter:
case UnicodeCategory.DecimalDigitNumber:
if (previousCategory == UnicodeCategory.SpaceSeparator)
{
builder.Append('_');
}
break;

default:
if (previousCategory != null)
{
previousCategory = UnicodeCategory.SpaceSeparator;
}
continue;
}

builder.Append(currentChar);
previousCategory = currentCategory;
}

return builder.ToString().ToLower(_culture);
}
}
1 change: 1 addition & 0 deletions LiftLog.Api/Db/RateLimitContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ public class RateLimitContext(DbContextOptions<RateLimitContext> options) : DbCo
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<RateLimitConsumption>().HasKey(x => x.Key);
modelBuilder.ToSnakeCaseNames();
}
}
1 change: 1 addition & 0 deletions LiftLog.Api/Db/UserDataContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
modelBuilder.Entity<UserEvent>().HasIndex(x => x.Expiry);

modelBuilder.Entity<UserEvent>().HasKey(x => new { x.UserId, x.Id });
modelBuilder.ToSnakeCaseNames();
}
}
7 changes: 3 additions & 4 deletions LiftLog.Api/LiftLog.Api.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
Expand All @@ -19,12 +19,11 @@
<PackageReference Include="cuid.net" Version="6.0.0" />
<PackageReference Include="FluentValidation" Version="11.11.0" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.11.0" />
<PackageReference Include="EFCore.NamingConventions" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.11">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.11" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.1" />
<PackageReference Include="OpenAI-DotNet" Version="8.4.1" />
<PackageReference Include="Google.Apis.AndroidPublisher.v3" Version="1.68.0.3576" />
</ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions LiftLog.Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
options
.UseNpgsql(builder.Configuration.GetConnectionString("UserDataContext"))
.ReplaceService<IHistoryRepository, CamelCaseHistoryContext>()
.UseSnakeCaseNamingConvention()
// .UseSnakeCaseNamingConvention()
);
builder.Services.AddDbContext<RateLimitContext>(options =>
options
.UseNpgsql(builder.Configuration.GetConnectionString("RateLimitContext"))
.ReplaceService<IHistoryRepository, CamelCaseHistoryContext>()
.UseSnakeCaseNamingConvention()
// .UseSnakeCaseNamingConvention()
);
builder.Services.AddCors(options =>
{
Expand Down Expand Up @@ -71,7 +71,7 @@
builder.Configuration.GetValue<string>("GooglePlayServiceAccountEmail")
?? throw new Exception("GooglePlayServiceAccountEmail configuration is not set.");
var certificateBytes = Convert.FromBase64String(certificateBase64);
var certificate = new X509Certificate2(
var certificate = X509CertificateLoader.LoadPkcs12(
certificateBytes,
"notasecret",
X509KeyStorageFlags.Exportable
Expand Down
Loading

0 comments on commit 385573e

Please sign in to comment.