Skip to content

Commit

Permalink
ci: Simple characters.json tests and automatic builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorixon committed Sep 5, 2023
1 parent 79227c7 commit 4bfa960
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 8 deletions.
20 changes: 12 additions & 8 deletions .github/workflows/dotnet-desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@ name: WinUI 3 unpackaged app
on:
workflow_dispatch:

jobs:
pull_request:
branches: [ main ]
paths:
- 'src/**'
push:
branches: [ main ]
paths:
- 'src/**'
- 'CHANGELOG.md'

jobs:
build:

strategy:
matrix:
configuration: [Release]
Expand All @@ -18,9 +26,6 @@ jobs:
runs-on: windows-latest # For a list of available runner types, refer to
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on

env:
Solution_Name: GIMI-ModManager # Replace with your solution name, i.e. App1

steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -33,9 +38,8 @@ jobs:
with:
dotnet-version: 7.0.x

# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v1.1
- name: Test
run: dotnet test ${{ github.workspace }}\src

- name: Build, publish and zip the app
run: python ${{ github.workspace }}\Build\Release.py
Expand Down
23 changes: 23 additions & 0 deletions src/GIMI-ModManager.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GIMI-ModManager.Core", "GIM
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elevator", "Elevator\Elevator.csproj", "{3C239075-C121-4DDB-88C5-B181863797B7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JASM.Tests", "JASM.Tests\JASM.Tests.csproj", "{992DF5F9-CBB9-4483-A71D-C0083C173B1C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{4E3DE2B1-EF6D-4E01-BCAB-3505C3B9E365}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -71,10 +75,29 @@ Global
{3C239075-C121-4DDB-88C5-B181863797B7}.Release|x64.ActiveCfg = Release|x64
{3C239075-C121-4DDB-88C5-B181863797B7}.Release|x64.Build.0 = Release|x64
{3C239075-C121-4DDB-88C5-B181863797B7}.Release|x86.ActiveCfg = Release|x64
{992DF5F9-CBB9-4483-A71D-C0083C173B1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{992DF5F9-CBB9-4483-A71D-C0083C173B1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{992DF5F9-CBB9-4483-A71D-C0083C173B1C}.Debug|arm64.ActiveCfg = Debug|Any CPU
{992DF5F9-CBB9-4483-A71D-C0083C173B1C}.Debug|arm64.Build.0 = Debug|Any CPU
{992DF5F9-CBB9-4483-A71D-C0083C173B1C}.Debug|x64.ActiveCfg = Debug|Any CPU
{992DF5F9-CBB9-4483-A71D-C0083C173B1C}.Debug|x64.Build.0 = Debug|Any CPU
{992DF5F9-CBB9-4483-A71D-C0083C173B1C}.Debug|x86.ActiveCfg = Debug|Any CPU
{992DF5F9-CBB9-4483-A71D-C0083C173B1C}.Debug|x86.Build.0 = Debug|Any CPU
{992DF5F9-CBB9-4483-A71D-C0083C173B1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{992DF5F9-CBB9-4483-A71D-C0083C173B1C}.Release|Any CPU.Build.0 = Release|Any CPU
{992DF5F9-CBB9-4483-A71D-C0083C173B1C}.Release|arm64.ActiveCfg = Release|Any CPU
{992DF5F9-CBB9-4483-A71D-C0083C173B1C}.Release|arm64.Build.0 = Release|Any CPU
{992DF5F9-CBB9-4483-A71D-C0083C173B1C}.Release|x64.ActiveCfg = Release|Any CPU
{992DF5F9-CBB9-4483-A71D-C0083C173B1C}.Release|x64.Build.0 = Release|Any CPU
{992DF5F9-CBB9-4483-A71D-C0083C173B1C}.Release|x86.ActiveCfg = Release|Any CPU
{992DF5F9-CBB9-4483-A71D-C0083C173B1C}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{992DF5F9-CBB9-4483-A71D-C0083C173B1C} = {4E3DE2B1-EF6D-4E01-BCAB-3505C3B9E365}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E01F4EA5-3B64-4C68-9474-CB87A51AF7D9}
EndGlobalSection
Expand Down
42 changes: 42 additions & 0 deletions src/JASM.Tests/CharactersJsonTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using GIMI_ModManager.Core.Services;

namespace JASM.Tests
{
public class CharactersJsonTests
{
private readonly string AssetsUriPath = Path.GetFullPath("..\\..\\..\\..\\GIMI-ModManager.WinUI\\Assets");

private async Task<IGenshinService> InitGenshinService()
{
if (!File.Exists(AssetsUriPath + "\\characters.json"))
throw new FileNotFoundException("Assets file not found.", AssetsUriPath);
var genshinService = new GenshinService();
await genshinService.InitializeAsync(AssetsUriPath);
return genshinService;
}

[Fact]
public async void CheckFor_DuplicateCharacterIds()
{
var genshinService = await InitGenshinService();
var characters = genshinService.GetCharacters();

var duplicateIds = characters.GroupBy(character => character.Id).Where(g => g.Count() > 1);

Assert.Empty(duplicateIds);
}


[Fact]
public async void CheckFor_DuplicateNames()
{
var genshinService = await InitGenshinService();
var characters = genshinService.GetCharacters();

var duplicateNames = characters.GroupBy(character => character.DisplayName.ToLower())
.Where(g => g.Count() > 1);

Assert.Empty(duplicateNames);
}
}
}
1 change: 1 addition & 0 deletions src/JASM.Tests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global using Xunit;
29 changes: 29 additions & 0 deletions src/JASM.Tests/JASM.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\GIMI-ModManager.Core\GIMI-ModManager.Core.csproj" />
</ItemGroup>

</Project>

0 comments on commit 4bfa960

Please sign in to comment.