From 16bc08d7909ae3c61be1df7d022964ddb772cc1e Mon Sep 17 00:00:00 2001 From: William Dawson Date: Tue, 30 Jun 2026 09:50:34 +0100 Subject: [PATCH 1/9] Started to add plugin stuff --- OpenPuppet.sln | 6 ++++ .../OpenPuppet.DataTypes.csproj | 9 ++++++ src/OpenPuppet.DataTypes/Plugin.cs | 31 +++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 src/OpenPuppet.DataTypes/OpenPuppet.DataTypes.csproj create mode 100644 src/OpenPuppet.DataTypes/Plugin.cs diff --git a/OpenPuppet.sln b/OpenPuppet.sln index 03980c6..bb191a3 100644 --- a/OpenPuppet.sln +++ b/OpenPuppet.sln @@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenPuppet", "src\OpenPuppe EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenPuppet.Tests", "src\OpenPuppet.Tests\OpenPuppet.Tests.csproj", "{E2D6A937-6D8B-43B4-9EA8-6292872C2224}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenPuppet.DataTypes", "src\OpenPuppet.DataTypes\OpenPuppet.DataTypes.csproj", "{E4A8B804-ECED-4140-8B30-66B7842FD863}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +23,10 @@ Global {E2D6A937-6D8B-43B4-9EA8-6292872C2224}.Debug|Any CPU.Build.0 = Debug|Any CPU {E2D6A937-6D8B-43B4-9EA8-6292872C2224}.Release|Any CPU.ActiveCfg = Release|Any CPU {E2D6A937-6D8B-43B4-9EA8-6292872C2224}.Release|Any CPU.Build.0 = Release|Any CPU + {E4A8B804-ECED-4140-8B30-66B7842FD863}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E4A8B804-ECED-4140-8B30-66B7842FD863}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E4A8B804-ECED-4140-8B30-66B7842FD863}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E4A8B804-ECED-4140-8B30-66B7842FD863}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/OpenPuppet.DataTypes/OpenPuppet.DataTypes.csproj b/src/OpenPuppet.DataTypes/OpenPuppet.DataTypes.csproj new file mode 100644 index 0000000..fa71b7a --- /dev/null +++ b/src/OpenPuppet.DataTypes/OpenPuppet.DataTypes.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/src/OpenPuppet.DataTypes/Plugin.cs b/src/OpenPuppet.DataTypes/Plugin.cs new file mode 100644 index 0000000..b8276e9 --- /dev/null +++ b/src/OpenPuppet.DataTypes/Plugin.cs @@ -0,0 +1,31 @@ +namespace OpenPuppet.DataTypes.Plugin +{ + /// + /// Plugin interface + /// + public interface IPlugin + { + /// + /// The plugin ID + /// + public string PluginID { get; set; } + + /// + /// OnInitialized + /// This is called when the plugin is loaded, use this to prepare the plugin + /// + abstract void OnInitialized(); + } + + /// + /// Plugin metadata file + /// + public class PluginMetadata + { + public string Name { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public string Author { get; set; } = string.Empty; + public string Version { get; set; } = string.Empty; + public string Icon { get; set; } = string.Empty; + } +} \ No newline at end of file From 6bbf5284a99625d8f9744d61f529bbad68ef0b75 Mon Sep 17 00:00:00 2001 From: William Dawson Date: Tue, 30 Jun 2026 15:47:11 +0100 Subject: [PATCH 2/9] More test report stuff --- .github/workflows/test-report.yml | 37 +++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test-report.yml b/.github/workflows/test-report.yml index e377e17..ccf3c89 100644 --- a/.github/workflows/test-report.yml +++ b/.github/workflows/test-report.yml @@ -6,9 +6,22 @@ on: branches: - master + issue_comment: + types: [created] + jobs: test: - if: contains(github.event.pull_request.labels.*.name, 'run-ci') + if: >- + ( + github.event_name == 'pull_request' && + contains(github.event.pull_request.labels.*.name, 'run-ci') + ) || + ( + github.event_name == 'issue_comment' && + github.event.issue.pull_request && + github.event.comment.body == '/run tests' && + contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association) + ) runs-on: ubuntu-latest @@ -19,8 +32,14 @@ jobs: steps: # Checkout repository - - name: Checkout repository + - name: Checkout repository (pull_request) + if: github.event_name == 'pull_request' + uses: actions/checkout@v4 + - name: Checkout repository (issue_comment) + if: github.event_name == 'issue_comment' uses: actions/checkout@v4 + with: + ref: refs/pull/${{ github.event.issue.number }}/head # Set up .NET 8.0 - name: Setup .NET @@ -38,10 +57,14 @@ jobs: # Comment the results on the PR as a table - name: Publish Test Report - uses: dorny/test-reporter@v1 + uses: EnricoMi/publish-unit-test-result-action@v2 if: always() with: - name: xUnit Tests - path: ./TestResults/*.trx - reporter: dotnet-trx - fail-on-error: false + files: TestResults/*.trx + check_name: xUnit Tests + + #- name: Publish results + # uses: marocchino/sticky-pull-request-comment@v2 + # with: + # header: test-report + # path: comment.md \ No newline at end of file From e9b5920cb1d35ce2778efc1fa90fb0abc75609dd Mon Sep 17 00:00:00 2001 From: William Dawson Date: Tue, 30 Jun 2026 15:54:58 +0100 Subject: [PATCH 3/9] Trying to get PR comments working --- .github/workflows/test-report.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-report.yml b/.github/workflows/test-report.yml index ccf3c89..e4e30f0 100644 --- a/.github/workflows/test-report.yml +++ b/.github/workflows/test-report.yml @@ -20,7 +20,11 @@ jobs: github.event_name == 'issue_comment' && github.event.issue.pull_request && github.event.comment.body == '/run tests' && - contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association) + ( + github.event.comment.author_association == 'OWNER' || + github.event.comment.author_association == 'MEMBER' || + github.event.comment.author_association == 'COLLABORATOR' + ) ) runs-on: ubuntu-latest From a94e7918983abad4b8af443e60f9a405c0835067 Mon Sep 17 00:00:00 2001 From: William Dawson Date: Tue, 30 Jun 2026 15:58:47 +0100 Subject: [PATCH 4/9] Testing something --- .github/workflows/test-report.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-report.yml b/.github/workflows/test-report.yml index e4e30f0..5368d7c 100644 --- a/.github/workflows/test-report.yml +++ b/.github/workflows/test-report.yml @@ -23,7 +23,8 @@ jobs: ( github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'MEMBER' || - github.event.comment.author_association == 'COLLABORATOR' + github.event.comment.author_association == 'COLLABORATOR' || + true ) ) From 656f8eee17e5c75243754a9c6be9c0d6a10b231f Mon Sep 17 00:00:00 2001 From: William Dawson Date: Tue, 30 Jun 2026 16:00:18 +0100 Subject: [PATCH 5/9] More testing --- .github/workflows/test-report.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-report.yml b/.github/workflows/test-report.yml index 5368d7c..81ca012 100644 --- a/.github/workflows/test-report.yml +++ b/.github/workflows/test-report.yml @@ -18,8 +18,8 @@ jobs: ) || ( github.event_name == 'issue_comment' && - github.event.issue.pull_request && - github.event.comment.body == '/run tests' && + github.event.issue.pull_request != null && + github.event.comment.body == '!/run tests' && ( github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'MEMBER' || From a3c87c780e2855c5267793c823834f6ffb385c0d Mon Sep 17 00:00:00 2001 From: William Dawson Date: Tue, 30 Jun 2026 16:02:44 +0100 Subject: [PATCH 6/9] Trying to get this working --- .github/workflows/test-report.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-report.yml b/.github/workflows/test-report.yml index 81ca012..9133be7 100644 --- a/.github/workflows/test-report.yml +++ b/.github/workflows/test-report.yml @@ -18,13 +18,13 @@ jobs: ) || ( github.event_name == 'issue_comment' && - github.event.issue.pull_request != null && - github.event.comment.body == '!/run tests' && + github.event.issue.pull_request && + contains(github.event.comment.body, '/run tests') && ( github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'COLLABORATOR' || - true + github.event.comment.author_association == 'CONTRIBUTOR' ) ) From 87ee74054ef48447e39009a2d0cfe312c5da749b Mon Sep 17 00:00:00 2001 From: William Dawson Date: Tue, 30 Jun 2026 16:05:15 +0100 Subject: [PATCH 7/9] Debugging --- .github/workflows/debug-comment.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/workflows/debug-comment.yml diff --git a/.github/workflows/debug-comment.yml b/.github/workflows/debug-comment.yml new file mode 100644 index 0000000..8a7c9c7 --- /dev/null +++ b/.github/workflows/debug-comment.yml @@ -0,0 +1,13 @@ +name: Debug PR Comment + +on: + issue_comment: + types: [created] + +jobs: + debug: + if: github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '/run tests') + runs-on: ubuntu-latest + steps: + - name: Print event + run: echo "Triggered" \ No newline at end of file From 18b1fc1228affd7cd50deff944e022968abd58d3 Mon Sep 17 00:00:00 2001 From: William Dawson Date: Tue, 30 Jun 2026 16:06:19 +0100 Subject: [PATCH 8/9] Testing again --- .github/workflows/debug-comment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/debug-comment.yml b/.github/workflows/debug-comment.yml index 8a7c9c7..76c2278 100644 --- a/.github/workflows/debug-comment.yml +++ b/.github/workflows/debug-comment.yml @@ -6,7 +6,7 @@ on: jobs: debug: - if: github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '/run tests') + if: github.event_name == 'issue_comment' && github.event.issue.pull_request runs-on: ubuntu-latest steps: - name: Print event From 80df179ceaedf24201658c4c0c811c3a774f66f9 Mon Sep 17 00:00:00 2001 From: William Dawson Date: Tue, 30 Jun 2026 16:49:19 +0100 Subject: [PATCH 9/9] Paths and testing --- .github/workflows/debug-comment.yml | 13 ----- OpenPuppet.Plugins/Manager.cs | 37 +++++++++++++++ OpenPuppet.Plugins/Metadata.cs | 7 +++ OpenPuppet.Plugins/OpenPuppet.Plugins.csproj | 13 +++++ OpenPuppet.Plugins/Path.cs | 50 ++++++++++++++++++++ OpenPuppet.sln | 6 +++ src/OpenPuppet.Tests/OpenPuppet.Tests.csproj | 5 ++ src/OpenPuppet.Tests/Plugins/Path.cs | 29 ++++++++++++ src/OpenPuppet.Tests/UnitTest1.cs | 11 ----- src/OpenPuppet/OpenPuppet.csproj | 5 ++ 10 files changed, 152 insertions(+), 24 deletions(-) delete mode 100644 .github/workflows/debug-comment.yml create mode 100644 OpenPuppet.Plugins/Manager.cs create mode 100644 OpenPuppet.Plugins/Metadata.cs create mode 100644 OpenPuppet.Plugins/OpenPuppet.Plugins.csproj create mode 100644 OpenPuppet.Plugins/Path.cs create mode 100644 src/OpenPuppet.Tests/Plugins/Path.cs delete mode 100644 src/OpenPuppet.Tests/UnitTest1.cs diff --git a/.github/workflows/debug-comment.yml b/.github/workflows/debug-comment.yml deleted file mode 100644 index 76c2278..0000000 --- a/.github/workflows/debug-comment.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: Debug PR Comment - -on: - issue_comment: - types: [created] - -jobs: - debug: - if: github.event_name == 'issue_comment' && github.event.issue.pull_request - runs-on: ubuntu-latest - steps: - - name: Print event - run: echo "Triggered" \ No newline at end of file diff --git a/OpenPuppet.Plugins/Manager.cs b/OpenPuppet.Plugins/Manager.cs new file mode 100644 index 0000000..eaa8592 --- /dev/null +++ b/OpenPuppet.Plugins/Manager.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OpenPuppet.Plugins +{ + public static class Manager + { + /// + /// Installs a plugin from a path, the path can either be a directory + /// or a ZIP file. + /// + /// The path to directory/ZIP file + public static void InstallPlugin(string path) + { + if (Directory.Exists(path)) InstallPluginDir(path); + else InstallPluginArchive(path); + } + + public static async Task InstallPluginAsync(string path) + { + return; + } + + static internal void InstallPluginDir(string path) + { + + } + + static internal void InstallPluginArchive(string path) + { + + } + } +} \ No newline at end of file diff --git a/OpenPuppet.Plugins/Metadata.cs b/OpenPuppet.Plugins/Metadata.cs new file mode 100644 index 0000000..6a52b5d --- /dev/null +++ b/OpenPuppet.Plugins/Metadata.cs @@ -0,0 +1,7 @@ +namespace OpenPuppet.Plugins +{ + public static class Metadata + { + + } +} \ No newline at end of file diff --git a/OpenPuppet.Plugins/OpenPuppet.Plugins.csproj b/OpenPuppet.Plugins/OpenPuppet.Plugins.csproj new file mode 100644 index 0000000..44562a6 --- /dev/null +++ b/OpenPuppet.Plugins/OpenPuppet.Plugins.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/OpenPuppet.Plugins/Path.cs b/OpenPuppet.Plugins/Path.cs new file mode 100644 index 0000000..c686d20 --- /dev/null +++ b/OpenPuppet.Plugins/Path.cs @@ -0,0 +1,50 @@ +using OpenPuppet.DataTypes.Plugin; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using static System.Runtime.InteropServices.JavaScript.JSType; + +namespace OpenPuppet.Plugins +{ + public static class Path + { + internal static string? InstallPath + { + get + { + return System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + } + } + + public static string? PluginPath + { + get + { + return InstallPath != null ? System.IO.Path.Combine(InstallPath, "Plugins") : null; + } + } + + public static string SafePluginName(string name) + { + name = name.ToLower().Replace(' ', '-'); + name = Regex.Replace(name, @"[^a-zA-Z0-9]", ""); + + return name; + } + + public static string? GetPluginPath(string name) + { + if (PluginPath == null) return null; + return System.IO.Path.Combine(PluginPath, SafePluginName(name)); + } + + public static string? GetPluginPath(PluginMetadata metadata) + { + return GetPluginPath(metadata.Name); + } + } +} \ No newline at end of file diff --git a/OpenPuppet.sln b/OpenPuppet.sln index bb191a3..6d805c8 100644 --- a/OpenPuppet.sln +++ b/OpenPuppet.sln @@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenPuppet.Tests", "src\Ope EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenPuppet.DataTypes", "src\OpenPuppet.DataTypes\OpenPuppet.DataTypes.csproj", "{E4A8B804-ECED-4140-8B30-66B7842FD863}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenPuppet.Plugins", "OpenPuppet.Plugins\OpenPuppet.Plugins.csproj", "{D1EE7937-72B4-4A1A-9B9B-EF1759027462}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -27,6 +29,10 @@ Global {E4A8B804-ECED-4140-8B30-66B7842FD863}.Debug|Any CPU.Build.0 = Debug|Any CPU {E4A8B804-ECED-4140-8B30-66B7842FD863}.Release|Any CPU.ActiveCfg = Release|Any CPU {E4A8B804-ECED-4140-8B30-66B7842FD863}.Release|Any CPU.Build.0 = Release|Any CPU + {D1EE7937-72B4-4A1A-9B9B-EF1759027462}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D1EE7937-72B4-4A1A-9B9B-EF1759027462}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D1EE7937-72B4-4A1A-9B9B-EF1759027462}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D1EE7937-72B4-4A1A-9B9B-EF1759027462}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/OpenPuppet.Tests/OpenPuppet.Tests.csproj b/src/OpenPuppet.Tests/OpenPuppet.Tests.csproj index 9c5b30a..7eb7cbd 100644 --- a/src/OpenPuppet.Tests/OpenPuppet.Tests.csproj +++ b/src/OpenPuppet.Tests/OpenPuppet.Tests.csproj @@ -16,6 +16,11 @@ + + + + + diff --git a/src/OpenPuppet.Tests/Plugins/Path.cs b/src/OpenPuppet.Tests/Plugins/Path.cs new file mode 100644 index 0000000..35ede98 --- /dev/null +++ b/src/OpenPuppet.Tests/Plugins/Path.cs @@ -0,0 +1,29 @@ +namespace OpenPuppet.Tests.Plugins +{ + public class Path + { + [Fact] + public void TestPluginName() + { + Assert.NotEqual( + "a-b-c-d", + OpenPuppet.Plugins.Path.SafePluginName( + @"a B +`¦¬!" + '"' + @"@£$%^&*()_+-=[]{};:'@#~,./<>?\| C d" + ) + ); + } + + [Fact] + public void TestPluginPath() + { + Assert.EndsWith( + "a-b-c-d", + OpenPuppet.Plugins.Path.GetPluginPath( + @"a B +`¦¬!" + '"' + @"@£$%^&*()_+-=[]{};:'@#~,./<>?\| C d" + ) + ); + } + } +} \ No newline at end of file diff --git a/src/OpenPuppet.Tests/UnitTest1.cs b/src/OpenPuppet.Tests/UnitTest1.cs deleted file mode 100644 index 3ccfe2c..0000000 --- a/src/OpenPuppet.Tests/UnitTest1.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace OpenPuppet.Tests -{ - public class UnitTest1 - { - [Fact] - public void Test1() - { - - } - } -} \ No newline at end of file diff --git a/src/OpenPuppet/OpenPuppet.csproj b/src/OpenPuppet/OpenPuppet.csproj index 6ed5f49..625b537 100644 --- a/src/OpenPuppet/OpenPuppet.csproj +++ b/src/OpenPuppet/OpenPuppet.csproj @@ -16,4 +16,9 @@ + + + + + \ No newline at end of file