Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation Project v2 #444

Merged
merged 49 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
4275a77
update gitignore
LotP1 Dec 24, 2024
f538cee
please don't fail
LotP1 Dec 25, 2024
732a1af
copying is not necessary anymore
LotP1 Dec 25, 2024
748e93b
lets give this another shot
LotP1 Dec 25, 2024
b19ee23
this won't work
LotP1 Dec 25, 2024
695f9e2
v3
LotP1 Dec 25, 2024
097836b
NO-BREAK SPACE is now escaped
LotP1 Dec 25, 2024
d83d80d
here we go
LotP1 Dec 25, 2024
dac137f
test stuff
LotP1 Dec 25, 2024
1bac6ab
please
LotP1 Dec 25, 2024
8c0a82b
v4
LotP1 Dec 26, 2024
b00d80c
use outdir
LotP1 Dec 26, 2024
7b8c877
Revert "use outdir"
LotP1 Dec 26, 2024
9ca0926
confirm that it actually builds
LotP1 Dec 26, 2024
21f23f0
lets see what's actually going on
LotP1 Dec 26, 2024
c91d9d8
build target fix
LotP1 Dec 26, 2024
eb46909
manually run dotnet restore
LotP1 Dec 26, 2024
4add482
force restore
LotP1 Dec 26, 2024
35b23bc
try simplified csproj and force runtime identifier
LotP1 Dec 26, 2024
9320dec
test RuntimeIdentifiers
LotP1 Dec 26, 2024
2fe1904
use RuntimeIdentifier instead
LotP1 Dec 26, 2024
e3638d1
correct form of --runtime
LotP1 Dec 26, 2024
0cde245
forgot to remove true
LotP1 Dec 26, 2024
a317184
check target dir
LotP1 Dec 26, 2024
bad1f72
v4 first test, will fail due to new validation step
LotP1 Dec 26, 2024
1dbcaf1
missing quote, will still fail
LotP1 Dec 26, 2024
80377c1
run with dotnet dll runner
LotP1 Dec 26, 2024
8cb6767
slash instead of backslash
LotP1 Dec 26, 2024
d9f2b81
Merge remote-tracking branch 'upstream/master' into validation-v2
LotP1 Dec 26, 2024
f976c3c
simplify
LotP1 Dec 26, 2024
d39b3a5
fix locales.json to comply with validation
LotP1 Dec 26, 2024
02ff76f
revert packages.props
LotP1 Dec 26, 2024
6fb58a6
revert .gitignore
LotP1 Dec 26, 2024
fdece62
fix matching windows runner
LotP1 Dec 26, 2024
2a38f1b
only log runtime if a runtime is set
LotP1 Dec 26, 2024
aabb786
fix spelling and names
LotP1 Dec 26, 2024
aa806b1
Rename program.cs to Program.cs
GreemDev Dec 27, 2024
e2e8502
force line endings to use LF
LotP1 Dec 27, 2024
4f206d0
Merge remote-tracking branch 'upstream/master' into validation-v2
LotP1 Dec 28, 2024
9f22fc4
Merge branch 'master' into validation-v2
LotP1 Dec 28, 2024
4b84c5d
fix duplicates
LotP1 Dec 28, 2024
55f6b95
Merge remote-tracking branch 'upstream/master' into validation-v2
LotP1 Dec 28, 2024
43f6e4a
remove dupelicates
LotP1 Dec 28, 2024
4e56b14
validate that line endings are LF on build
LotP1 Dec 28, 2024
8efefea
slight refactor
LotP1 Dec 28, 2024
af44726
Merge branch 'master' into validation-v2
GreemDev Dec 28, 2024
e9b614d
remove unnecessary references
LotP1 Dec 29, 2024
0ca3aa4
Merge remote-tracking branch 'upstream/master' into validation-v2
LotP1 Dec 29, 2024
33800c1
validate json
LotP1 Dec 29, 2024
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
5 changes: 2 additions & 3 deletions Ryujinx.sln
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,12 @@ Global
{B575BCDE-2FD8-4A5D-8756-31CDD7FE81F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B575BCDE-2FD8-4A5D-8756-31CDD7FE81F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B575BCDE-2FD8-4A5D-8756-31CDD7FE81F0}.Release|Any CPU.Build.0 = Release|Any CPU
{4A89A234-4F19-497D-A576-DDE8CDFC5B22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A89A234-4F19-497D-A576-DDE8CDFC5B22}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A89A234-4F19-497D-A576-DDE8CDFC5B22}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C08931FA-1191-417A-864F-3882D93E683B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C08931FA-1191-417A-864F-3882D93E683B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C08931FA-1191-417A-864F-3882D93E683B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C08931FA-1191-417A-864F-3882D93E683B}.Release|Any CPU.Build.0 = Release|Any CPU
{4A89A234-4F19-497D-A576-DDE8CDFC5B22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A89A234-4F19-497D-A576-DDE8CDFC5B22}.Release|Any CPU.ActiveCfg = Release|Any CPU
{81EA598C-DBA1-40B0-8DA4-4796B78F2037}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{81EA598C-DBA1-40B0-8DA4-4796B78F2037}.Debug|Any CPU.Build.0 = Debug|Any CPU
{81EA598C-DBA1-40B0-8DA4-4796B78F2037}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
73 changes: 0 additions & 73 deletions src/Ryujinx.BuildValidationTasks/LocaleValidationTask.cs

This file was deleted.

117 changes: 117 additions & 0 deletions src/Ryujinx.BuildValidationTasks/LocalesValidationTask.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.Json;
using System.Text.Encodings.Web;

namespace Ryujinx.BuildValidationTasks
{
public class LocalesValidationTask : ValidationTask
{
public LocalesValidationTask() { }

public bool Execute(string projectPath, bool isGitRunner)
{
Console.WriteLine("Running Locale Validation Task...");

string path = projectPath + "src/Ryujinx/Assets/locales.json";
string data;

using (StreamReader sr = new(path))
{
data = sr.ReadToEnd();
}

LocalesJson json;

if (isGitRunner && data.Contains("\r\n"))
throw new FormatException("locales.json is using CRLF line endings! It should be using LF line endings, build locally to fix...");

try
{
json = JsonSerializer.Deserialize<LocalesJson>(data);

}
catch (JsonException e)
{
throw new JsonException(e.Message); //shorter and easier stacktrace
}



bool encounteredIssue = false;

for (int i = 0; i < json.Locales.Count; i++)
{
LocalesEntry locale = json.Locales[i];

foreach (string langCode in json.Languages.Where(lang => !locale.Translations.ContainsKey(lang)))
{
encounteredIssue = true;

if (!isGitRunner)
{
locale.Translations.Add(langCode, string.Empty);
Console.WriteLine($"Added '{langCode}' to Locale '{locale.ID}'");
}
else
{
Console.WriteLine($"Missing '{langCode}' in Locale '{locale.ID}'!");
}
}

foreach (string langCode in json.Languages.Where(lang => locale.Translations.ContainsKey(lang) && lang != "en_US" && locale.Translations[lang] == locale.Translations["en_US"]))
{
encounteredIssue = true;

if (!isGitRunner)
{
locale.Translations[langCode] = string.Empty;
Console.WriteLine($"Lanugage '{langCode}' is a duplicate of en_US in Locale '{locale.ID}'! Resetting it...");
}
else
{
Console.WriteLine($"Lanugage '{langCode}' is a duplicate of en_US in Locale '{locale.ID}'!");
}
}

locale.Translations = locale.Translations.OrderBy(pair => pair.Key).ToDictionary(pair => pair.Key, pair => pair.Value);
json.Locales[i] = locale;
}

if (isGitRunner && encounteredIssue)
throw new JsonException("1 or more locales are invalid!");

JsonSerializerOptions jsonOptions = new JsonSerializerOptions()
{
WriteIndented = true,
NewLine = "\n",
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
};

string jsonString = JsonSerializer.Serialize(json, jsonOptions);

using (StreamWriter sw = new(path))
{
sw.Write(jsonString);
}

Console.WriteLine("Finished Locale Validation Task!");

return true;
}

struct LocalesJson
{
public List<string> Languages { get; set; }
public List<LocalesEntry> Locales { get; set; }
}

struct LocalesEntry
{
public string ID { get; set; }
public Dictionary<string, string> Translations { get; set; }
}
}
}
37 changes: 37 additions & 0 deletions src/Ryujinx.BuildValidationTasks/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.IO;
using System.Linq;

namespace Ryujinx.BuildValidationTasks
{
public class Program
{
static void Main(string[] args)
{
// Display the number of command line arguments.
if (args.Length == 0)
throw new ArgumentException("Error: too few arguments!");

string path = args[0];

if (string.IsNullOrEmpty(path))
throw new ArgumentException("Error: path is null or empty!");

if (!Path.Exists(path))
throw new FileLoadException($"path {{{path}}} does not exist!");

path = Path.GetFullPath(path);

if (!Directory.GetDirectories(path).Contains($"{path}src"))
throw new FileLoadException($"path {{{path}}} is not a valid ryujinx project!");

bool isGitRunner = path.Contains("runner") || path.Contains("D:\\a\\Ryujinx\\Ryujinx");
if (isGitRunner)
Console.WriteLine("Is Git Runner!");

// Run tasks
// Pass extra info needed in the task constructors
new LocalesValidationTask().Execute(path, isGitRunner);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Build.Utilities.Core" />
<PackageReference Include="Newtonsoft.Json" />
</ItemGroup>
<Target Name="PostBuildTarget" AfterTargets="AfterBuild">
<Message Text="Running Validation Project" Importance="high" />

<UsingTask TaskName="Ryujinx.BuildValidationTasks.LocaleValidationTask" TaskFactory="TaskHostFactory" AssemblyFile="$(OutDir)Ryujinx.BuildValidationTasks.dll" />

<Target Name="LocalesJsonValidation" AfterTargets="AfterRebuild">
<LocaleValidationTask />
<Exec WorkingDirectory="$(ProjectDir)bin\Debug\$(TargetFramework)\"
Command="dotnet Ryujinx.BuildValidationTasks.dll &quot;$(ProjectDir)..\..\\&quot;"
ConsoleToMsBuild="true"
/>
</Target>

</Project>
</Project>
7 changes: 7 additions & 0 deletions src/Ryujinx.BuildValidationTasks/ValidationTask.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Ryujinx.BuildValidationTasks
{
public interface ValidationTask
{
public bool Execute(string projectPath, bool isGitRunner);
}
}
Loading
Loading