From 17564957cb1ed45abf7378202ab2adcebbdc1bc1 Mon Sep 17 00:00:00 2001 From: benbierens Date: Mon, 26 Feb 2024 12:50:51 +0100 Subject: [PATCH] POC: codex commit blamer --- .gitignore | 3 +- Tools/CommitBlamer/CommitBlamer.csproj | 19 +++++++ Tools/CommitBlamer/Program.cs | 74 ++++++++++++++++++++++++++ cs-codex-dist-testing.sln | 14 ++--- 4 files changed, 102 insertions(+), 8 deletions(-) create mode 100644 Tools/CommitBlamer/CommitBlamer.csproj create mode 100644 Tools/CommitBlamer/Program.cs diff --git a/.gitignore b/.gitignore index c134fee..f957737 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .vs obj bin -.vscode \ No newline at end of file +.vscode +Tools/CommitBlamer/CodexTestLogs diff --git a/Tools/CommitBlamer/CommitBlamer.csproj b/Tools/CommitBlamer/CommitBlamer.csproj new file mode 100644 index 0000000..bfa923d --- /dev/null +++ b/Tools/CommitBlamer/CommitBlamer.csproj @@ -0,0 +1,19 @@ + + + + Exe + net7.0 + enable + enable + + + + + + + + + + + + diff --git a/Tools/CommitBlamer/Program.cs b/Tools/CommitBlamer/Program.cs new file mode 100644 index 0000000..05ae717 --- /dev/null +++ b/Tools/CommitBlamer/Program.cs @@ -0,0 +1,74 @@ +using LibGit2Sharp; +using CodexTests.BasicTests; +using CodexPlugin; +using System.Diagnostics; + +public static class Program +{ + public static void Main(string[] args) + { + Console.WriteLine("Hello, World!"); + + var codexPath = @"D:\Projects\nim-codex"; + + using var repo = new Repository(codexPath); + var masterBranch = repo.Branches.Single(b => b.FriendlyName == "master"); + var take = masterBranch.Commits.Take(10).ToArray(); + foreach (var c in take) + { + RunWith(c); + } + + Console.ReadLine(); + } + + private static void RunWith(Commit c) + { + var shortSha = c.Sha.Substring(0, 7); + var image = $"codexstorage/nim-codex:sha-{shortSha}-dist-tests"; + CodexContainerRecipe.DockerImageOverride = image; + + if (!DoesExist(image)) + { + return; + } + + try + { + Console.WriteLine("Running test for: " + c.MessageShort); + + var test = new ExampleTests(); + test.GlobalSetup(); + test.SetUpDistTest(); + + try + { + test.CodexLogExample(); + } + catch (Exception ex) + { + Console.WriteLine("test ex: " + ex); + } + + test.TearDownDistTest(); + test.GlobalTearDown(); + + Console.WriteLine("Test passed"); + } + catch (Exception a) + { + Console.WriteLine("ex: " + a); + } + } + + private static bool DoesExist(string image) + { + var info = new ProcessStartInfo("docker", "image pull " + image); + info.RedirectStandardOutput = false; + var process = Process.Start(info); + process.WaitForExit(); + + return process.ExitCode == 0; + } +} + diff --git a/cs-codex-dist-testing.sln b/cs-codex-dist-testing.sln index 3a403fe..58fa95d 100644 --- a/cs-codex-dist-testing.sln +++ b/cs-codex-dist-testing.sln @@ -35,8 +35,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MetricsPlugin", "ProjectPlu EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodexContinuousTests", "Tests\CodexContinuousTests\CodexContinuousTests.csproj", "{ADEC06CF-6F3A-44C5-AA57-EAB94124AC82}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodexTestsLong", "Tests\CodexLongTests\CodexTestsLong.csproj", "{0C2D067F-053C-45A8-AE0D-4EB388E77C89}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodexTests", "Tests\CodexTests\CodexTests.csproj", "{562EC700-6984-4C9A-83BF-3BF4E3EB1A64}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DistTestCore", "Tests\DistTestCore\DistTestCore.csproj", "{E849B7BA-FDCC-4CFF-998F-845ED2F1BF40}" @@ -59,6 +57,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GethConnector", "Framework\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiscordRewards", "Framework\DiscordRewards\DiscordRewards.csproj", "{B07820C4-309F-4454-BCC1-1D4902C9C67B}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommitBlamer", "Tools\CommitBlamer\CommitBlamer.csproj", "{DC08EAA2-42F4-49EE-90C8-44673094BE0A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -113,10 +113,6 @@ Global {ADEC06CF-6F3A-44C5-AA57-EAB94124AC82}.Debug|Any CPU.Build.0 = Debug|Any CPU {ADEC06CF-6F3A-44C5-AA57-EAB94124AC82}.Release|Any CPU.ActiveCfg = Release|Any CPU {ADEC06CF-6F3A-44C5-AA57-EAB94124AC82}.Release|Any CPU.Build.0 = Release|Any CPU - {0C2D067F-053C-45A8-AE0D-4EB388E77C89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0C2D067F-053C-45A8-AE0D-4EB388E77C89}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0C2D067F-053C-45A8-AE0D-4EB388E77C89}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0C2D067F-053C-45A8-AE0D-4EB388E77C89}.Release|Any CPU.Build.0 = Release|Any CPU {562EC700-6984-4C9A-83BF-3BF4E3EB1A64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {562EC700-6984-4C9A-83BF-3BF4E3EB1A64}.Debug|Any CPU.Build.0 = Debug|Any CPU {562EC700-6984-4C9A-83BF-3BF4E3EB1A64}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -161,6 +157,10 @@ Global {B07820C4-309F-4454-BCC1-1D4902C9C67B}.Debug|Any CPU.Build.0 = Debug|Any CPU {B07820C4-309F-4454-BCC1-1D4902C9C67B}.Release|Any CPU.ActiveCfg = Release|Any CPU {B07820C4-309F-4454-BCC1-1D4902C9C67B}.Release|Any CPU.Build.0 = Release|Any CPU + {DC08EAA2-42F4-49EE-90C8-44673094BE0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DC08EAA2-42F4-49EE-90C8-44673094BE0A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DC08EAA2-42F4-49EE-90C8-44673094BE0A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DC08EAA2-42F4-49EE-90C8-44673094BE0A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -178,7 +178,6 @@ Global {8B39F251-F948-40AE-8922-3D8C4E529A86} = {8F1F1C2A-E313-4E0C-BE40-58FB0BA91124} {8DE8FF65-23CB-4FB3-8BE5-6C0BEC4BAA97} = {8F1F1C2A-E313-4E0C-BE40-58FB0BA91124} {ADEC06CF-6F3A-44C5-AA57-EAB94124AC82} = {88C2A621-8A98-4D07-8625-7900FC8EF89E} - {0C2D067F-053C-45A8-AE0D-4EB388E77C89} = {88C2A621-8A98-4D07-8625-7900FC8EF89E} {562EC700-6984-4C9A-83BF-3BF4E3EB1A64} = {88C2A621-8A98-4D07-8625-7900FC8EF89E} {E849B7BA-FDCC-4CFF-998F-845ED2F1BF40} = {88C2A621-8A98-4D07-8625-7900FC8EF89E} {3417D508-E2F4-4974-8988-BB124046D9E2} = {7591C5B3-D86E-4AE4-8ED2-B272D17FE7E3} @@ -190,6 +189,7 @@ Global {570C0DBE-0EF1-47B5-9A3B-E1F7895722A5} = {7591C5B3-D86E-4AE4-8ED2-B272D17FE7E3} {F730DA73-1C92-4107-BCFB-D33759DAB0C3} = {81AE04BC-CBFA-4E6F-B039-8208E9AFAAE7} {B07820C4-309F-4454-BCC1-1D4902C9C67B} = {81AE04BC-CBFA-4E6F-B039-8208E9AFAAE7} + {DC08EAA2-42F4-49EE-90C8-44673094BE0A} = {7591C5B3-D86E-4AE4-8ED2-B272D17FE7E3} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {237BF0AA-9EC4-4659-AD9A-65DEB974250C}