From eafb4d60c4e59ed4bd1a2132cbfd20054f7ccc2b Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Thu, 5 Sep 2024 09:04:23 -0700 Subject: [PATCH] Add tests (#30) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * check for viability * attempt 2 * make directory exist silly git * checkout * add simple test * im becoming jokerfied * correct artifact creation * Add tests using a legacy-style csproj based on RPM * nuget needs a sln file to not freak out 🙄 * I cannot type * fix "repo" root * always get that one wrong * fix for real * Unify CI workflow * delete nuget workflow --- .../workflows/{nuget.yml => internal-ci.yml} | 36 ++++----- .../workflows/internal-test-plugin-legacy.yml | 26 +++++++ .github/workflows/internal-test-plugin.yml | 26 +++++++ KSPBuildTools.csproj | 5 ++ tests/plugin-mod-legacy/.gitignore | 4 + tests/plugin-mod-legacy/PluginModLegacy.sln | 22 ++++++ .../Properties/AssemblyInfo.cs | 10 +++ .../PluginModLegacy/packages.config | 4 + .../PluginModLegacy/plugin-mod-legacy.csproj | 77 +++++++++++++++++++ tests/plugin-mod/.gitignore | 3 + tests/plugin-mod/plugin-mod.csproj | 51 ++++++++++++ 11 files changed, 246 insertions(+), 18 deletions(-) rename .github/workflows/{nuget.yml => internal-ci.yml} (78%) create mode 100644 .github/workflows/internal-test-plugin-legacy.yml create mode 100644 .github/workflows/internal-test-plugin.yml create mode 100644 tests/plugin-mod-legacy/.gitignore create mode 100644 tests/plugin-mod-legacy/PluginModLegacy.sln create mode 100644 tests/plugin-mod-legacy/PluginModLegacy/Properties/AssemblyInfo.cs create mode 100644 tests/plugin-mod-legacy/PluginModLegacy/packages.config create mode 100644 tests/plugin-mod-legacy/PluginModLegacy/plugin-mod-legacy.csproj create mode 100644 tests/plugin-mod/.gitignore create mode 100644 tests/plugin-mod/plugin-mod.csproj diff --git a/.github/workflows/nuget.yml b/.github/workflows/internal-ci.yml similarity index 78% rename from .github/workflows/nuget.yml rename to .github/workflows/internal-ci.yml index 0aa6aff..2451e50 100644 --- a/.github/workflows/nuget.yml +++ b/.github/workflows/internal-ci.yml @@ -1,42 +1,42 @@ -name: Build for NuGet +# This is an internal workflow for KSPBuildTools and not intended to be used by other projects + +name: CI on: push: tags: - '*.*.*' branches: - - 'main' - paths: - - '**/*.csproj' - - '**/*.props' - - '**/*.targets' - - '.github/workflows/nuget.yml' + - 'main' pull_request: - paths: - - '**/*.csproj' - - '**/*.props' - - '**/*.targets' - - '.github/workflows/nuget.yml' workflow_dispatch: env: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 - DOTNET_NOLOGO: true NuGetDirectory: ${{ github.workspace}}/nuget jobs: + test-plugin: + uses: './.github/workflows/internal-test-plugin.yml' + + test-plugin-legacy: + uses: './.github/workflows/internal-test-plugin-legacy.yml' + build: + env: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 + DOTNET_NOLOGO: true runs-on: ubuntu-latest + needs: [ test-plugin, test-plugin-legacy ] steps: - uses: actions/checkout@v4 with: fetch-depth: 0 # get full history, not shallow clone - + - name: Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: 8.0.x - + - name: Build run: dotnet build KSPBuildTools.csproj @@ -55,7 +55,7 @@ jobs: environment: name: "NuGet" url: "https://www.nuget.org/packages/KSPBuildTools" - if: github.event_name == 'push' + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') steps: - name: Setup .NET uses: actions/setup-dotnet@v4 @@ -80,4 +80,4 @@ jobs: - name: Publish Package to Github run: | - dotnet nuget push --source "github" ${{ env.NuGetDirectory }}/*.nupkg \ No newline at end of file + dotnet nuget push --source "github" ${{ env.NuGetDirectory }}/*.nupkg diff --git a/.github/workflows/internal-test-plugin-legacy.yml b/.github/workflows/internal-test-plugin-legacy.yml new file mode 100644 index 0000000..68a8192 --- /dev/null +++ b/.github/workflows/internal-test-plugin-legacy.yml @@ -0,0 +1,26 @@ +# This is an internal test for KSPBuildTools and not intended to be used by other projects +name: Test Plugin Mod (Legacy) + +on: + workflow_call: + +env: + TESTDIR: tests/plugin-mod-legacy + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: ./.github/actions/setup-ckan + + - uses: ./.github/actions/compile + with: + solution-file-path: ${{ env.TESTDIR }}/PluginModLegacy.sln + ksp-zip-url: https://github.com/KSPModdingLibs/KSPLibs/raw/main/KSP-1.12.5.zip + + - uses: ./.github/actions/assemble-release + with: + artifacts: ${{ env.TESTDIR }}/GameData + output-file-name: plugin-mod-legacy diff --git a/.github/workflows/internal-test-plugin.yml b/.github/workflows/internal-test-plugin.yml new file mode 100644 index 0000000..2058e10 --- /dev/null +++ b/.github/workflows/internal-test-plugin.yml @@ -0,0 +1,26 @@ +# This is an internal test for KSPBuildTools and not intended to be used by other projects +name: Test Plugin Mod + +on: + workflow_call: + +env: + TESTDIR: tests/plugin-mod + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: ./.github/actions/setup-ckan + + - uses: ./.github/actions/compile + with: + solution-file-path: ${{ env.TESTDIR }}/plugin-mod.csproj + ksp-zip-url: https://github.com/KSPModdingLibs/KSPLibs/raw/main/KSP-1.12.5.zip + + - uses: ./.github/actions/assemble-release + with: + artifacts: ${{ env.TESTDIR }}/GameData + output-file-name: plugin-mod diff --git a/KSPBuildTools.csproj b/KSPBuildTools.csproj index ba3a5da..4eb983e 100644 --- a/KSPBuildTools.csproj +++ b/KSPBuildTools.csproj @@ -32,4 +32,9 @@ + + + + + \ No newline at end of file diff --git a/tests/plugin-mod-legacy/.gitignore b/tests/plugin-mod-legacy/.gitignore new file mode 100644 index 0000000..c29446b --- /dev/null +++ b/tests/plugin-mod-legacy/.gitignore @@ -0,0 +1,4 @@ +packages +obj +bin +GameData \ No newline at end of file diff --git a/tests/plugin-mod-legacy/PluginModLegacy.sln b/tests/plugin-mod-legacy/PluginModLegacy.sln new file mode 100644 index 0000000..20a4cfd --- /dev/null +++ b/tests/plugin-mod-legacy/PluginModLegacy.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "plugin-mod-legacy", "PluginModLegacy\plugin-mod-legacy.csproj", "{F19C7AB4-50C2-4378-9673-CC039CA12E10}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F19C7AB4-50C2-4378-9673-CC039CA12E10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F19C7AB4-50C2-4378-9673-CC039CA12E10}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F19C7AB4-50C2-4378-9673-CC039CA12E10}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F19C7AB4-50C2-4378-9673-CC039CA12E10}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/tests/plugin-mod-legacy/PluginModLegacy/Properties/AssemblyInfo.cs b/tests/plugin-mod-legacy/PluginModLegacy/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..9bf32e5 --- /dev/null +++ b/tests/plugin-mod-legacy/PluginModLegacy/Properties/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. +[assembly: AssemblyTitle ("PluginModLegacy")] +[assembly: AssemblyDescription ("Test mod using a legacy csproj")] + +// This supposedly helps avoid plugin depencency problems. +[assembly: KSPAssembly("plugin-mod-legacy", 1, 2, 3)] \ No newline at end of file diff --git a/tests/plugin-mod-legacy/PluginModLegacy/packages.config b/tests/plugin-mod-legacy/PluginModLegacy/packages.config new file mode 100644 index 0000000..20174bf --- /dev/null +++ b/tests/plugin-mod-legacy/PluginModLegacy/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/tests/plugin-mod-legacy/PluginModLegacy/plugin-mod-legacy.csproj b/tests/plugin-mod-legacy/PluginModLegacy/plugin-mod-legacy.csproj new file mode 100644 index 0000000..76b0a7a --- /dev/null +++ b/tests/plugin-mod-legacy/PluginModLegacy/plugin-mod-legacy.csproj @@ -0,0 +1,77 @@ + + + + + Debug + AnyCPU + {F19C7AB4-50C2-4378-9673-CC039CA12E10} + Library + JSI + PluginModMono + v4.8 + 65001 + + + + + + true + portable + false + bin\Debug + DEBUG; + prompt + 4 + false + AnyCPU + false + + + true + bin\Release + prompt + 4 + false + AnyCPU + false + portable + true + + + Always + + + true + bin\Profile\ + ENABLE_PROFILER + true + portable + AnyCPU + prompt + MinimumRecommendedRules.ruleset + + + $(MSBuildThisFileDirectory)../ + GameData/plugin-mod-legacy + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/tests/plugin-mod/.gitignore b/tests/plugin-mod/.gitignore new file mode 100644 index 0000000..4e4c3a8 --- /dev/null +++ b/tests/plugin-mod/.gitignore @@ -0,0 +1,3 @@ +obj +bin +GameData \ No newline at end of file diff --git a/tests/plugin-mod/plugin-mod.csproj b/tests/plugin-mod/plugin-mod.csproj new file mode 100644 index 0000000..cf2b274 --- /dev/null +++ b/tests/plugin-mod/plugin-mod.csproj @@ -0,0 +1,51 @@ + + + + + + all + runtime; build; native; contentfiles; analyzers + + + + + + net48 + 7.3 + false + x64 + 1701;1702;CS0649;CS1591; + 2024 KSPModdingLibs Contributors + PluginMod + $(MSBuildThisFileDirectory) + GameData/plugin-mod + + + + + + $(KSPRoot)/GameData/000_Harmony/0Harmony.dll + Harmony2 + 2.2.1.0 + False + + + + + + + $(RepoRootPath)$(BinariesOutputRelativePath)/plugin-mod.version + + + + + true + true + + + + + + + +