Skip to content

Commit

Permalink
Merge branch 'develop' into chore/mini-lcm-refactor
Browse files Browse the repository at this point in the history
# Conflicts:
#	backend/FwLite/LocalWebApp/Hubs/CrdtMiniLcmApiHub.cs
#	backend/LfClassicData/LfClassicRoutes.cs
  • Loading branch information
hahn-kev committed Sep 24, 2024
2 parents 2cf7bf1 + 7aafe1a commit 88b5f57
Show file tree
Hide file tree
Showing 70 changed files with 1,186 additions and 542 deletions.
103 changes: 53 additions & 50 deletions .github/workflows/fw-lite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,20 @@ jobs:
dotnet build --configuration Release
- name: Dotnet test
working-directory: backend/FwLite/LcmCrdt.Tests
run: dotnet test --configuration Release --logger GitHubActions
run: dotnet test FwLiteOnly.slnf --configuration Release --logger GitHubActions

- name: Build viewer
working-directory: frontend/viewer
run: |
corepack enable
pnpm install
pnpm run build-app
- name: Upload viewer artifacts
uses: actions/upload-artifact@v4
with:
name: fw-lite-viewer-app
if-no-files-found: error
path: frontend/viewer/dist

publish-mac:
name: Publish FW Lite app for Mac
Expand All @@ -61,19 +66,13 @@ jobs:
uses: actions/checkout@v4
with:
submodules: true
- uses: actions/download-artifact@v4
with:
name: fw-lite-viewer-app
path: frontend/viewer/dist
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'
- uses: actions/setup-node@v4
with:
node-version-file: './frontend/package.json'

- name: Build viewer
working-directory: frontend/viewer
run: |
corepack enable
pnpm install
pnpm run build-app

- name: Dotnet build
working-directory: backend/FwLite/LocalWebApp
Expand All @@ -94,39 +93,23 @@ jobs:
if-no-files-found: error
path: backend/FwLite/artifacts/publish/LocalWebApp/*


publish-app:
name: Publish FW Lite app

# only publish if tag matches fwlite-v* pattern
# iif: startsWith(github.ref, 'refs/tags/fwlite-v')
publish-linux:
name: Publish FW Lite app for Linux
needs: build-and-test
timeout-minutes: 30
runs-on: windows-latest
env:
NuGetPackageSourceCredentials_github: ${{ secrets.GH_NUGET_PACKAGE_CREDS }}
enable-msix: false #we can't sign the msix installer so we'll disable the build for now
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- uses: actions/download-artifact@v4
with:
name: fw-lite-viewer-app
path: frontend/viewer/dist
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'
- uses: actions/setup-node@v4
with:
node-version-file: './frontend/package.json'

- name: Setup Maui
run: dotnet workload install maui-windows

- name: Build viewer
working-directory: frontend/viewer
run: |
corepack enable
pnpm install
pnpm run build-app

- name: Dotnet build
working-directory: backend/FwLite/LocalWebApp
Expand All @@ -136,35 +119,55 @@ jobs:
working-directory: backend/FwLite/LocalWebApp
run: dotnet publish -r linux-x64 --artifacts-path ../artifacts

- name: Publish Windows
working-directory: backend/FwLite/LocalWebApp
run: dotnet publish -r win-x64 --artifacts-path ../artifacts

- name: Publish Windows ARM
working-directory: backend/FwLite/LocalWebApp
run: dotnet publish -r win-arm64 --artifacts-path ../artifacts

- name: Upload local web app artifacts
- name: Upload FWLite Desktop artifacts
uses: actions/upload-artifact@v4
with:
name: fw-lite-local-web-app
name: fw-lite-local-web-app-linux
if-no-files-found: error
path: backend/FwLite/artifacts/publish/LocalWebApp/*

- name: Publish Windows MAUI unpackaged app
publish-win:
name: Publish FW Lite app

# only publish if tag matches fwlite-v* pattern
# iif: startsWith(github.ref, 'refs/tags/fwlite-v')
needs: build-and-test
timeout-minutes: 30
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- uses: actions/download-artifact@v4
with:
name: fw-lite-viewer-app
path: frontend/viewer/dist
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'

- name: Setup Maui
run: dotnet workload install maui-windows

- name: Dotnet build
working-directory: backend/FwLite/LocalWebApp
run: dotnet build --configuration Release

- name: Publish Windows MAUI portable app
working-directory: backend/FwLite/FwLiteDesktop
run: |
dotnet publish -r win-x64 --artifacts-path ../artifacts -p:WindowsPackageType=None
dotnet publish -r win-arm64 --artifacts-path ../artifacts -p:WindowsPackageType=None
- name: Upload FWLite Desktop artifacts
uses: actions/upload-artifact@v4
with:
name: fw-lite-unpackaged
name: fw-lite-portable
if-no-files-found: error
path: backend/FwLite/artifacts/publish/FwLiteDesktop/*

- name: Publish Windows MAUI msix app
if: ${{env.enable-msix}}
if: false
working-directory: backend/FwLite/FwLiteDesktop
run: |
dotnet publish -f net8.0-windows10.0.19041.0 -r win-x64 --artifacts-path ../artifacts -p:Platform=x64
Expand All @@ -174,7 +177,7 @@ jobs:
- name: Upload FWLite Desktop artifacts
uses: actions/upload-artifact@v4
if: ${{env.enable-msix}}
if: false
with:
name: fw-lite-msix
if-no-files-found: error
Expand All @@ -184,7 +187,7 @@ jobs:
#disabled as this doesn't work since ltops-signing doesn't have the signtool
if: false
name: Sign FWLite MSIX installer
needs: publish-app
needs: publish-win
runs-on: [self-hosted, ltops-signing]
steps:
- uses: actions/download-artifact@v4
Expand Down
18 changes: 18 additions & 0 deletions FwLiteOnly.slnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"solution": {
"path": "LexBox.sln",
"projects": [
"backend\\FwLite\\MiniLcm\\MiniLcm.csproj",
"backend\\harmony\\src\\SIL.Harmony.Core\\SIL.Harmony.Core.csproj",
"backend\\harmony\\src\\SIL.Harmony\\SIL.Harmony.csproj",
"backend\\FwLite\\LcmCrdt\\LcmCrdt.csproj",
"backend\\FwLite\\LcmCrdt.Tests\\LcmCrdt.Tests.csproj",
"backend\\FWLite\\LocalWebApp\\LocalWebApp.csproj",
"backend\\FwLite\\FwLiteDesktop\\FwLiteDesktop.csproj",
"backend\\FWLite\\FwDataMiniLcmBridge\\FwDataMiniLcmBridge.csproj",
"backend\\FwLite\\FwDataMiniLcmBridge.Tests\\FwDataMiniLcmBridge.Tests.csproj",
"backend\\FWLite\\FwLiteProjectSync\\FwLiteProjectSync.csproj",
"backend\\FWLite\\FwLiteProjectSync.Tests\\FwLiteProjectSync.Tests.csproj",
]
}
}
2 changes: 1 addition & 1 deletion backend/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
<WarningsAsErrors>Nullable</WarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.8.14" PrivateAssets="all"/>
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.11.20" PrivateAssets="all"/>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,22 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0"/>
<PackageReference Include="FluentAssertions" Version="6.12.0"/>
<PackageReference Include="xunit" Version="2.5.3"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3"/>
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
</ItemGroup>

Expand Down
19 changes: 12 additions & 7 deletions backend/FwLite/FwDataMiniLcmBridge.Tests/PartOfSpeechTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,24 @@ public async Task InitializeAsync()
_api = fixture.CreateApi(projectName);
_api.Should().NotBeNull();

var partOfSpeech = new PartOfSpeech()
var nounPos = new PartOfSpeech()
{
Id = Guid.NewGuid(), Name = { { "en", "new-part-of-speech" } }
Id = Guid.NewGuid(), Name = { { "en", "Noun" } }
};
await _api.CreatePartOfSpeech(partOfSpeech);
await _api.CreatePartOfSpeech(nounPos);

await _api.CreatePartOfSpeech(new() { Id = Guid.NewGuid(), Name = { { "en", "Verb" } } });

await _api.CreateEntry(new Entry()
{
Id = Guid.NewGuid(),
LexemeForm = {{"en", "new-lexeme-form"}},
LexemeForm = {{"en", "Apple"}},
Senses = new List<Sense>()
{
new Sense()
{
Gloss = {{"en", "new-sense-gloss"}},
PartOfSpeechId = partOfSpeech.Id
Gloss = {{"en", "Fruit"}},
PartOfSpeechId = nounPos.Id
}
}});
}
Expand All @@ -46,7 +48,10 @@ public async Task DisposeAsync()
public async Task GetPartsOfSpeech_ReturnsAllPartsOfSpeech()
{
var partOfSpeeches = await _api.GetPartsOfSpeech().ToArrayAsync();
partOfSpeeches.Should().AllSatisfy(po => po.Id.Should().NotBe(Guid.Empty));
partOfSpeeches.Should()
.NotBeEmpty()
.And
.AllSatisfy(po => po.Id.Should().NotBe(Guid.Empty));
}

[Fact]
Expand Down
15 changes: 15 additions & 0 deletions backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,26 @@ public Task DeleteEntry(Guid id)
internal void CreateSense(ILexEntry lexEntry, Sense sense)
{
var lexSense = LexSenseFactory.Create(sense.Id, lexEntry);
var msa = new SandboxGenericMSA() { MsaType = lexSense.GetDesiredMsaType() };
if (sense.PartOfSpeechId.HasValue && PartOfSpeechRepository.TryGetObject(sense.PartOfSpeechId.Value, out var pos))
{
msa.MainPOS = pos;
}
lexSense.SandboxMSA = msa;
ApplySenseToLexSense(sense, lexSense);
}

private void ApplySenseToLexSense(Sense sense, ILexSense lexSense)
{
if (lexSense.MorphoSyntaxAnalysisRA.GetPartOfSpeech()?.Guid != sense.PartOfSpeechId)
{
IPartOfSpeech? pos = null;
if (sense.PartOfSpeechId.HasValue)
{
pos = PartOfSpeechRepository.GetObject(sense.PartOfSpeechId.Value);
}
lexSense.MorphoSyntaxAnalysisRA.SetMsaPartOfSpeech(pos);
}
UpdateLcmMultiString(lexSense.Gloss, sense.Gloss);
UpdateLcmMultiString(lexSense.Definition, sense.Definition);
foreach (var senseSemanticDomain in sense.SemanticDomains)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public static class MorphoSyntaxExtensions
{
public static void SetMsaPartOfSpeech(this IMoMorphSynAnalysis msa, IPartOfSpeech? pos)
{
ArgumentNullException.ThrowIfNull(msa);

switch (msa.ClassID)
{
case MoDerivAffMsaTags.kClassId:
Expand All @@ -31,6 +33,7 @@ public static void SetMsaPartOfSpeech(this IMoMorphSynAnalysis msa, IPartOfSpeec

public static IPartOfSpeech? GetPartOfSpeech(this IMoMorphSynAnalysis msa)
{
ArgumentNullException.ThrowIfNull(msa);
switch (msa.ClassID)
{
case MoDerivAffMsaTags.kClassId:
Expand Down
4 changes: 3 additions & 1 deletion backend/FwLite/FwLiteDesktop/FwLiteDesktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
either BOTH runtimes must be indicated or ONLY macatalyst-x64. -->
<!-- For example: <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers> -->

<OutputType>Exe</OutputType>
<OutputType>Exe</OutputType>
<RootNamespace>FwLiteDesktop</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
Expand Down Expand Up @@ -49,6 +49,8 @@
<!-- single file disabled as it's less efficient for updates-->
<PublishSingleFile>false</PublishSingleFile>
<PublishTrimmed>false</PublishTrimmed>
<!-- only trim assemblies that explicitly support it-->
<TrimMode>partial</TrimMode>
</PropertyGroup>
<PropertyGroup Condition="'$(WindowsPackageType)' == 'None'">
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
Expand Down
5 changes: 4 additions & 1 deletion backend/FwLite/FwLiteDesktop/FwLiteDesktopKernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ public static void AddFwLiteDesktopServices(this IServiceCollection services,
config.ProjectPath = FileSystem.AppDataDirectory;
});
webAppBuilder.Services.Configure<AuthConfig>(config =>
config.CacheFileName = Path.Combine(FileSystem.AppDataDirectory, "msal.cache"));
{
config.CacheFileName = Path.Combine(FileSystem.AppDataDirectory, "msal.cache");
config.SystemWebViewLogin = true;
});
});
//using a lambda here means that the serverManager will be disposed when the app is disposed
services.AddSingleton<ServerManager>(_ => serverManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,23 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0"/>
<PackageReference Include="FluentAssertions" Version="6.12.0"/>
<PackageReference Include="Soenneker.Utils.AutoBogus" Version="2.1.278" />
<PackageReference Include="xunit" Version="2.5.3"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3"/>
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0"/>
</ItemGroup>

Expand Down
Loading

0 comments on commit 88b5f57

Please sign in to comment.