From 682fa49e80be5aea1a955b5ecb5ca994e550f132 Mon Sep 17 00:00:00 2001 From: JT Date: Wed, 26 Jul 2023 00:34:02 -0700 Subject: [PATCH] fix path tests on linux? --- Jenkinsfile | 54 ++++++++++--------- .../Models/InstalledPackageTests.cs | 13 ++++- 2 files changed, 41 insertions(+), 26 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index fd94e675..8005c7a6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,37 +11,41 @@ node("Diligence") { git branch: env.BRANCH_NAME, credentialsId: 'Ionite', url: "https://github.com/${author}/${repoName}.git" } - stage('Test') { - sh "dotnet test StabilityMatrix.Tests" - } + try { + stage('Test') { + sh "dotnet test StabilityMatrix.Tests" + } - if (env.BRANCH_NAME == 'main') { - - stage('Set Version') { - script { - if (env.TAG_NAME) { - version = env.TAG_NAME.replaceFirst(/^v/, '') - } else { - version = VersionNumber projectStartDate: '2023-06-21', versionNumberString: '${BUILDS_ALL_TIME}', worstResultForIncrement: 'SUCCESS' + if (env.BRANCH_NAME == 'main') { + + stage('Set Version') { + script { + if (env.TAG_NAME) { + version = env.TAG_NAME.replaceFirst(/^v/, '') + } else { + version = VersionNumber projectStartDate: '2023-06-21', versionNumberString: '${BUILDS_ALL_TIME}', worstResultForIncrement: 'SUCCESS' + } } } - } - - stage('Publish Windows') { - sh "dotnet publish ./StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj -c Release -o out -r win-x64 -p:PublishSingleFile=true -p:VersionPrefix=2.0.0 -p:VersionSuffix=${version} -p:IncludeNativeLibrariesForSelfExtract=true" - } + + stage('Publish Windows') { + sh "dotnet publish ./StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj -c Release -o out -r win-x64 -p:PublishSingleFile=true -p:VersionPrefix=2.0.0 -p:VersionSuffix=${version} -p:IncludeNativeLibrariesForSelfExtract=true" + } - stage('Publish Linux') { - sh "/home/jenkins/.dotnet/tools/pupnet --runtime linux-x64 --kind appimage --app-version ${version} --clean -y" + stage('Publish Linux') { + sh "/home/jenkins/.dotnet/tools/pupnet --runtime linux-x64 --kind appimage --app-version ${version} --clean -y" + } + + stage ('Archive Artifacts') { + archiveArtifacts artifacts: 'out/*.exe', followSymlinks: false + archiveArtifacts artifacts: 'out/*.appimage', followSymlinks: false + } } - - stage ('Archive Artifacts') { - archiveArtifacts artifacts: 'out/*.exe', followSymlinks: false - archiveArtifacts artifacts: 'out/*.appimage', followSymlinks: false + } finally { + stage('Cleanup') { + cleanWs() } } - stage('Cleanup') { - cleanWs() - } + } diff --git a/StabilityMatrix.Tests/Models/InstalledPackageTests.cs b/StabilityMatrix.Tests/Models/InstalledPackageTests.cs index 4a0935d7..bb58e54f 100644 --- a/StabilityMatrix.Tests/Models/InstalledPackageTests.cs +++ b/StabilityMatrix.Tests/Models/InstalledPackageTests.cs @@ -1,4 +1,5 @@ -using StabilityMatrix.Core.Models; +using System.Runtime.InteropServices; +using StabilityMatrix.Core.Models; namespace StabilityMatrix.Tests.Models; @@ -12,6 +13,16 @@ public class InstalledPackageTests [DataRow("C:\\User\\AppData\\StabilityMatrix", "C:\\User\\AppData\\StabilityMatrix\\Packages\\abc", "Packages\\abc")] public void TestGetSubPath(string relativeTo, string path, string? expected) { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + relativeTo = relativeTo.Replace("C:\\", $"{Path.DirectorySeparatorChar}") + .Replace('\\', Path.DirectorySeparatorChar); + path = path.Replace("C:\\", $"{Path.DirectorySeparatorChar}") + .Replace('\\', Path.DirectorySeparatorChar); + expected = expected?.Replace("C:\\", $"{Path.DirectorySeparatorChar}") + .Replace('\\', Path.DirectorySeparatorChar); + } + var result = InstalledPackage.GetSubPath(relativeTo, path); Assert.AreEqual(expected, result); }