Skip to content

Commit 5307163

Browse files
authored
Refactor ModVerify to expose and use a VerificationTarget class (#31)
* start verify target impl * update deps * update sub * make app running again * reorganize solution * basic support for VerificationTarget type * start refactoring verification target selection * rename stuff * start testing automatic selector * fix and test automatic selector * update to new deps * update to new deps (just to make it compile) * make everything compile at least * to weekly deps check * update license year * rename class * make compile and run again * local deploy script * update gitignore * polishing * update module * various little changes * update deps * use filed keyword * do not thorw stepfailure exception if verification errors occured. * Fail fast should print any error to console * major refactorings * allow skip location in baselines * only search for baselines of the correct engine type * Support argument validation * Setting appFailure does not terminate the verifiers on first error. * udpate assert reporting * make tests compile again * pretty print verify info * do not print location if not exists * simply automatic selector * extract to file * nicer console output * update deps * update dpes * make compile * run tests * windows only tests * fix app is not updatebale sometimes * minor cleanup
1 parent f0da6c8 commit 5307163

119 files changed

Lines changed: 4199 additions & 1776 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/dependabot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ updates:
88
- package-ecosystem: "github-actions"
99
directory: "/"
1010
schedule:
11-
interval: "daily"
11+
interval: "weekly"
1212
groups:
1313
actions-deps:
1414
patterns:
@@ -19,7 +19,7 @@ updates:
1919
- package-ecosystem: "nuget"
2020
directory: "/"
2121
schedule:
22-
interval: "daily"
22+
interval: "weekly"
2323
target-branch: "develop"
2424
open-pull-requests-limit: 1
2525
groups:

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ jobs:
2727
with:
2828
dotnet-version: 10.0.x
2929
- name: Build & Test in Release Mode
30-
run: dotnet test --configuration Release
30+
run: dotnet test --configuration Release --report-github

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,3 +396,6 @@ FodyWeavers.xsd
396396

397397
# JetBrains Rider
398398
*.sln.iml
399+
.idea
400+
401+
.local_deploy

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<PropertyGroup>
1313
<Product>ModVerify</Product>
1414
<Authors>Alamo Engine Tools and Contributors</Authors>
15-
<Copyright>Copyright © 2025 Alamo Engine Tools and contributors. All rights reserved.</Copyright>
15+
<Copyright>Copyright © 2026 Alamo Engine Tools and contributors. All rights reserved.</Copyright>
1616
<PackageProjectUrl>https://github.com/AlamoEngine-Tools/ModVerify</PackageProjectUrl>
1717
<LicenseFile>$(RepoRootPath)LICENSE</LicenseFile>
1818
<PackageLicenseExpression>MIT</PackageLicenseExpression>
@@ -33,7 +33,7 @@
3333

3434
<ItemGroup>
3535
<PackageReference Update="SauceControl.InheritDoc" Version="2.0.2" />
36-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
36+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.102">
3737
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3838
<PrivateAssets>all</PrivateAssets>
3939
</PackageReference>

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Alamo Engine Tools
3+
Copyright (c) 2026 Alamo Engine Tools
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

deploy-local.ps1

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Local deployment script for ModVerify to test the update feature.
2+
# This script builds the application, creates an update manifest, and "deploys" it to a local directory.
3+
4+
$ErrorActionPreference = "Stop"
5+
6+
$root = $PSScriptRoot
7+
if ([string]::IsNullOrEmpty($root)) { $root = Get-Location }
8+
9+
$deployRoot = Join-Path $root ".local_deploy"
10+
$stagingDir = Join-Path $deployRoot "staging"
11+
$serverDir = Join-Path $deployRoot "server"
12+
$installDir = Join-Path $deployRoot "install"
13+
14+
$toolProj = Join-Path $root "src\ModVerify.CliApp\ModVerify.CliApp.csproj"
15+
$creatorProj = Join-Path $root "modules\ModdingToolBase\src\AnakinApps\ApplicationManifestCreator\ApplicationManifestCreator.csproj"
16+
$uploaderProj = Join-Path $root "modules\ModdingToolBase\src\AnakinApps\FtpUploader\FtpUploader.csproj"
17+
18+
$toolExe = "ModVerify.exe"
19+
$updaterExe = "AnakinRaW.ExternalUpdater.exe"
20+
$manifestCreatorDll = "AnakinRaW.ApplicationManifestCreator.dll"
21+
$uploaderDll = "AnakinRaW.FtpUploader.dll"
22+
23+
# 1. Clean and Create directories
24+
if (Test-Path $deployRoot) { Remove-Item -Recurse -Force $deployRoot }
25+
New-Item -ItemType Directory -Path $stagingDir | Out-Null
26+
New-Item -ItemType Directory -Path $serverDir | Out-Null
27+
New-Item -ItemType Directory -Path $installDir | Out-Null
28+
29+
Write-Host "--- Building ModVerify (net481) ---" -ForegroundColor Cyan
30+
dotnet build $toolProj --configuration Release -f net481 --output "$deployRoot\bin\tool" /p:DebugType=None /p:DebugSymbols=false
31+
32+
Write-Host "--- Building Manifest Creator ---" -ForegroundColor Cyan
33+
dotnet build $creatorProj --configuration Release --output "$deployRoot\bin\creator"
34+
35+
Write-Host "--- Building Local Uploader ---" -ForegroundColor Cyan
36+
dotnet build $uploaderProj --configuration Release --output "$deployRoot\bin\uploader"
37+
38+
# 2. Prepare staging
39+
Write-Host "--- Preparing Staging ---" -ForegroundColor Cyan
40+
Copy-Item "$deployRoot\bin\tool\$toolExe" $stagingDir
41+
Copy-Item "$deployRoot\bin\tool\$updaterExe" $stagingDir
42+
43+
# 3. Create Manifest
44+
# Origin must be an absolute URI for the manifest creator.
45+
# Using 127.0.0.1 and file:// is tricky with Flurl/DownloadManager sometimes.
46+
# We'll use the local path and ensure it's formatted correctly.
47+
$serverPath = (Resolve-Path $serverDir).Path
48+
$serverUri = "file:///$($serverPath.Replace('\', '/'))"
49+
# If we have 3 slashes, Flurl/DownloadManager might still fail on Windows if it expects a certain format.
50+
# However, the ManifestCreator just needs a valid URI for the 'Origin' field in the manifest.
51+
Write-Host "--- Creating Manifest (Origin: $serverUri) ---" -ForegroundColor Cyan
52+
dotnet "$deployRoot\bin\creator\$manifestCreatorDll" `
53+
-a "$stagingDir\$toolExe" `
54+
--appDataFiles "$stagingDir\$updaterExe" `
55+
--origin "$serverUri" `
56+
-o "$stagingDir" `
57+
-b "beta"
58+
59+
# 4. "Deploy" to server using the local uploader
60+
Write-Host "--- Deploying to Local Server ---" -ForegroundColor Cyan
61+
dotnet "$deployRoot\bin\uploader\$uploaderDll" local --base "$serverDir" --source "$stagingDir"
62+
63+
# 5. Setup a "test" installation
64+
Write-Host "--- Setting up Test Installation ---" -ForegroundColor Cyan
65+
Copy-Item "$deployRoot\bin\tool\*" $installDir -Recurse
66+
67+
Write-Host "`nLocal deployment complete!" -ForegroundColor Green
68+
Write-Host "Server directory: $serverDir"
69+
Write-Host "Install directory: $installDir"
70+
Write-Host "`nTo test the update:"
71+
Write-Host "1. (Optional) Modify the version in version.json and run this script again to 'push' a new version to the local server."
72+
Write-Host "2. Run ModVerify from the install directory with the following command:"
73+
Write-Host " cd '$installDir'"
74+
Write-Host " .\ModVerify.exe updateApplication --updateManifestUrl '$serverUri'"
75+
Write-Host "`n Note: You can also specify a different branch using --updateBranch if needed."

global.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"test": {
3+
"runner": "Microsoft.Testing.Platform"
4+
}
5+
}

modules/ModdingToolBase

Submodule ModdingToolBase updated 24 files
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using AET.ModVerify.App.Reporting;
2+
using AET.ModVerify.App.Settings;
3+
using AET.ModVerify.App.Utilities;
4+
using AET.ModVerify.Reporting;
5+
using Microsoft.Extensions.DependencyInjection;
6+
using Microsoft.Extensions.Logging;
7+
using System;
8+
using System.Collections.Generic;
9+
using System.IO.Abstractions;
10+
using System.Threading.Tasks;
11+
12+
namespace AET.ModVerify.App;
13+
14+
internal sealed class CreateBaselineAction(AppBaselineSettings settings, IServiceProvider serviceProvider)
15+
: ModVerifyApplicationAction<AppBaselineSettings>(settings, serviceProvider)
16+
{
17+
private readonly IFileSystem _fileSystem = serviceProvider.GetRequiredService<IFileSystem>();
18+
19+
protected override void PrintAction(VerificationTarget target)
20+
{
21+
Console.WriteLine();
22+
Console.ForegroundColor = ConsoleColor.DarkGreen;
23+
Console.WriteLine($"Creating baseline for {target.Name}...");
24+
Console.WriteLine();
25+
ModVerifyConsoleUtilities.WriteSelectedTarget(target);
26+
Console.WriteLine();
27+
}
28+
29+
protected override async Task<int> ProcessVerifyFindings(
30+
VerificationTarget verificationTarget,
31+
IReadOnlyCollection<VerificationError> allErrors)
32+
{
33+
var baselineFactory = ServiceProvider.GetRequiredService<IBaselineFactory>();
34+
var baseline = baselineFactory.CreateBaseline(verificationTarget, Settings, allErrors);
35+
36+
var fullPath = _fileSystem.Path.GetFullPath(Settings.NewBaselinePath);
37+
Logger?.LogInformation(ModVerifyConstants.ConsoleEventId,
38+
"Writing Baseline to '{FullPath}' with {Number} findings", fullPath, allErrors.Count);
39+
40+
await baselineFactory.WriteBaselineAsync(baseline, Settings.NewBaselinePath);
41+
42+
Logger?.LogDebug("Baseline successfully created.");
43+
44+
Console.WriteLine();
45+
Console.ForegroundColor = ConsoleColor.DarkGreen;
46+
Console.WriteLine($"Baseline for {verificationTarget.Name} created.");
47+
Console.ResetColor();
48+
49+
return ModVerifyConstants.Success;
50+
}
51+
52+
protected override VerificationBaseline GetBaseline(VerificationTarget verificationTarget)
53+
{
54+
return VerificationBaseline.Empty;
55+
}
56+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using System.Threading.Tasks;
2+
3+
namespace AET.ModVerify.App;
4+
5+
internal interface IModVerifyAppAction
6+
{
7+
Task<int> ExecuteAsync();
8+
}

0 commit comments

Comments
 (0)