Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
51 changes: 8 additions & 43 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Trion CI

on:
push:
branches: [ main, dev ]
Expand All @@ -11,81 +12,45 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]

steps:
- name: Checkout
uses: actions/checkout@v4

# Setup .NET 9 runtime
- name: Setup .NET 9
- name: Setup .NET 9
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x

# MAUI is Windows-only, skip on Linux to avoid workload installation errors
- name: Install MAUI workload (Windows)
if: matrix.os == 'windows-latest'
run: dotnet workload install maui

# wasm-tools needed for web projects on all platforms
- name: Install wasm-tools workload
run: dotnet workload install wasm-tools
- name: Install .NET workloads
run: dotnet workload install aspire wasm-tools

# RESTORE: Windows restores everything, Linux only restores Web project
# This prevents MAUI-tizen dependency errors on Linux runners
- name: Restore (Windows - all projects)
if: matrix.os == 'windows-latest'
- name: Restore
run: dotnet restore

- name: Restore (Linux - web only)
if: matrix.os == 'ubuntu-latest'
run: dotnet restore src/Trion.Web/Trion.Web.csproj

# BUILD: Split build steps by OS to avoid Desktop project compilation on Linux
# Windows builds Desktop (MAUI) + Web, Linux builds Web only
- name: Build (Windows - all projects)
if: matrix.os == 'windows-latest'
- name: Build
run: dotnet build -c Release --no-restore --warnaserror

- name: Build (Linux - web only)
if: matrix.os == 'ubuntu-latest'
run: dotnet build src/Trion.Web/Trion.Web.csproj -c Release --no-restore --warnaserror

# TEST: Run unit tests only on relevant projects per platform
- name: Test (Windows - all)
if: matrix.os == 'windows-latest'
- name: Test
run: dotnet test -c Release --no-build --logger trx --collect:"XPlat Code Coverage"

- name: Test (Linux - web only)
if: matrix.os == 'ubuntu-latest'
run: dotnet test src/Trion.Web/Trion.Web.csproj -c Release --no-build --logger trx --collect:"XPlat Code Coverage"

# PUBLISH DESKTOP: Windows only - creates self-contained single-file exe
- name: Publish desktop (Windows)
if: matrix.os == 'windows-latest'
run: dotnet publish src/Trion.Desktop/Trion.Desktop.csproj -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -o artifacts/desktop

# PUBLISH WEB: Both platforms - portable web app deployment
- name: Publish web (portable)
run: dotnet publish src/Trion.Web/Trion.Web.csproj -c Release -o artifacts/web

# ARTIFACT UPLOADS
# Upload test results from both platforms
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.os }}
path: '**/*.trx'

# Upload code coverage to codecov (Linux only to avoid duplicates)
- name: Upload coverage
if: matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: '**/coverage.cobertura.xml'

# Upload all build artifacts (desktop exe on Windows, web files on both)
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
Expand Down
16 changes: 0 additions & 16 deletions Trion.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Trion.Core", "src\Trion.Cor
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Trion.Web", "src\Trion.Web\Trion.Web.csproj", "{C99FA784-527A-433A-8892-71A951DF63CE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Trion.Desktop", "src\Trion.Desktop\Trion.Desktop.csproj", "{75DB2555-FFE9-459B-B0E6-092D892FBE85}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -89,19 +87,6 @@ Global
{C99FA784-527A-433A-8892-71A951DF63CE}.Release|x64.Build.0 = Release|Any CPU
{C99FA784-527A-433A-8892-71A951DF63CE}.Release|x86.ActiveCfg = Release|Any CPU
{C99FA784-527A-433A-8892-71A951DF63CE}.Release|x86.Build.0 = Release|Any CPU
{75DB2555-FFE9-459B-B0E6-092D892FBE85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{75DB2555-FFE9-459B-B0E6-092D892FBE85}.Debug|Any CPU.Build.0 = Debug|Any CPU
{75DB2555-FFE9-459B-B0E6-092D892FBE85}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{75DB2555-FFE9-459B-B0E6-092D892FBE85}.Debug|x64.ActiveCfg = Debug|Any CPU
{75DB2555-FFE9-459B-B0E6-092D892FBE85}.Debug|x64.Build.0 = Debug|Any CPU
{75DB2555-FFE9-459B-B0E6-092D892FBE85}.Debug|x86.ActiveCfg = Debug|Any CPU
{75DB2555-FFE9-459B-B0E6-092D892FBE85}.Debug|x86.Build.0 = Debug|Any CPU
{75DB2555-FFE9-459B-B0E6-092D892FBE85}.Release|Any CPU.ActiveCfg = Release|Any CPU
{75DB2555-FFE9-459B-B0E6-092D892FBE85}.Release|Any CPU.Build.0 = Release|Any CPU
{75DB2555-FFE9-459B-B0E6-092D892FBE85}.Release|x64.ActiveCfg = Release|Any CPU
{75DB2555-FFE9-459B-B0E6-092D892FBE85}.Release|x64.Build.0 = Release|Any CPU
{75DB2555-FFE9-459B-B0E6-092D892FBE85}.Release|x86.ActiveCfg = Release|Any CPU
{75DB2555-FFE9-459B-B0E6-092D892FBE85}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -112,7 +97,6 @@ Global
{8F4FA8F8-6064-41DC-B0B8-4394373EBC83} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
{7489FB6C-F47B-4178-B5DD-20D8F4608728} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
{C99FA784-527A-433A-8892-71A951DF63CE} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
{75DB2555-FFE9-459B-B0E6-092D892FBE85} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {11752BB0-7828-4D57-81A5-144236B2A82F}
Expand Down
4 changes: 4 additions & 0 deletions src/Trion.API/Trion.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.9" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Trion.Core\Trion.Core.csproj" />
</ItemGroup>

</Project>
10 changes: 10 additions & 0 deletions src/Trion.Core/Logging/LogEntry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Trion.Core.Logging;

internal readonly record struct LogEntry(
DateTimeOffset Timestamp,
LogLevel Level,
string Message,
string Category,
string Member,
string FilePath,
int Line);
10 changes: 10 additions & 0 deletions src/Trion.Core/Logging/LogLevel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Trion.Core.Logging
{
public enum LogLevel
{
Info,
Success,
Warning,
Error
}
}
19 changes: 19 additions & 0 deletions src/Trion.Core/Logging/LoggerExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;

namespace Trion.Core.Logging;

public static class LoggerExtensions
{
public static IServiceCollection AddTrionLogger(
this IServiceCollection services,
Action<LoggerOptions>? configure = null)
{
if (configure != null) services.Configure(configure);
return services.AddSingleton(sp =>
{
var opts = sp.GetRequiredService<IOptions<LoggerOptions>>().Value;
return new TrionLogger(opts);
});
}
}
22 changes: 22 additions & 0 deletions src/Trion.Core/Logging/LoggerOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace Trion.Core.Logging;

public sealed class LoggerOptions
{
public string Folder { get; set; } = "Logs";
public bool WriteToConsole { get; set; } = true;
public bool WriteToFile { get; set; } = true;
public int DaysToCompress { get; set; } = 7;
public int DaysToKeep { get; set; } = 30;

#if DEBUG
public bool ShowInfo { get; set; } = true;
public bool ShowSuccess { get; set; } = true;
public bool ShowWarning { get; set; } = true;
public bool ShowError { get; set; } = true;
#else
public bool ShowInfo { get; set; } = false;
public bool ShowSuccess { get; set; } = false;
public bool ShowWarning { get; set; } = true;
public bool ShowError { get; set; } = true;
#endif
}
Loading