diff --git a/Jenkinsfile b/Jenkinsfile index 6c03f2ad9..8005c7a62 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,4 @@ -node("Windows") { +node("Diligence") { def repoName = "StabilityMatrix" def author = "ionite34" def version = "" @@ -11,32 +11,41 @@ node("Windows") { git branch: env.BRANCH_NAME, credentialsId: 'Ionite', url: "https://github.com/${author}/${repoName}.git" } - stage('Test') { - bat "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 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('Publish') { - bat "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 ('Archive Artifacts') { - archiveArtifacts artifacts: 'out/*.exe', followSymlinks: false - } - } else { - stage('Publish') { - bat "dotnet publish .\\StabilityMatrix.Avalonia\\StabilityMatrix.Avalonia.csproj -c Release -o out -r win-x64 -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true" + } finally { + stage('Cleanup') { + cleanWs() } } + + } diff --git a/Jenkinsfile-linux b/Jenkinsfile-linux deleted file mode 100644 index f520fb3f0..000000000 --- a/Jenkinsfile-linux +++ /dev/null @@ -1,42 +0,0 @@ -node("Diligence") { - def repoName = "StabilityMatrix" - def author = "ionite34" - def version = "" - - stage('Clean') { - deleteDir() - } - - stage('Checkout') { - git branch: env.BRANCH_NAME, credentialsId: 'Ionite', url: "https://github.com/${author}/${repoName}.git" - } - - // 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' - } - } - } - - stage('Publish') { - sh "/home/jenkins/.dotnet/tools/pupnet --runtime linux-x64 --kind appimage --app-version ${version} --clean -y" - } - - stage ('Archive Artifacts') { - archiveArtifacts artifacts: 'out/*.appimage', followSymlinks: false - } - } else { - stage('Publish') { - sh "/home/jenkins/.dotnet/tools/pupnet --runtime linux-x64 --kind appimage --clean -y" - } - } -} diff --git a/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj b/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj index ff803d08d..e4c4ef881 100644 --- a/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj +++ b/StabilityMatrix.Avalonia/StabilityMatrix.Avalonia.csproj @@ -10,6 +10,7 @@ ./Assets/Icon.ico 2.0.3-dev.1 $(Version) + true diff --git a/StabilityMatrix.Core/Helper/SharedFolders.cs b/StabilityMatrix.Core/Helper/SharedFolders.cs index 8ae3918b2..a7469cd2f 100644 --- a/StabilityMatrix.Core/Helper/SharedFolders.cs +++ b/StabilityMatrix.Core/Helper/SharedFolders.cs @@ -1,4 +1,5 @@ -using NLog; +using System.Globalization; +using NLog; using StabilityMatrix.Core.Extensions; using StabilityMatrix.Core.Helper.Factory; using StabilityMatrix.Core.Models; @@ -30,6 +31,8 @@ private static void CreateLinkOrJunction(string junctionDir, string targetDir, b } else { + // Create parent directory if it doesn't exist, since CreateSymbolicLink doesn't seem to + new DirectoryPath(junctionDir).Parent?.Create(); Directory.CreateSymbolicLink(junctionDir, targetDir); } } diff --git a/StabilityMatrix.Core/StabilityMatrix.Core.csproj b/StabilityMatrix.Core/StabilityMatrix.Core.csproj index b179dec3a..30316af85 100644 --- a/StabilityMatrix.Core/StabilityMatrix.Core.csproj +++ b/StabilityMatrix.Core/StabilityMatrix.Core.csproj @@ -6,6 +6,7 @@ enable enable true + true diff --git a/StabilityMatrix.Tests/Models/InstalledPackageTests.cs b/StabilityMatrix.Tests/Models/InstalledPackageTests.cs index 4a0935d70..bb58e54fe 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); } diff --git a/StabilityMatrix.Tests/ReparsePoints/JunctionTests.cs b/StabilityMatrix.Tests/ReparsePoints/JunctionTests.cs index d8aaa16e4..46c965598 100644 --- a/StabilityMatrix.Tests/ReparsePoints/JunctionTests.cs +++ b/StabilityMatrix.Tests/ReparsePoints/JunctionTests.cs @@ -1,4 +1,5 @@ -using StabilityMatrix.Core.ReparsePoints; +using System.Runtime.InteropServices; +using StabilityMatrix.Core.ReparsePoints; namespace StabilityMatrix.Tests.ReparsePoints; @@ -13,6 +14,12 @@ public class JunctionTest [TestInitialize] public void Initialize() { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + Assert.Inconclusive("Test cannot be run on anything but Windows currently."); + return; + } + tempFolder = Path.GetTempFileName(); File.Delete(tempFolder); Directory.CreateDirectory(tempFolder); diff --git a/StabilityMatrix.Tests/StabilityMatrix.Tests.csproj b/StabilityMatrix.Tests/StabilityMatrix.Tests.csproj index 205cbf38a..e97701ccd 100644 --- a/StabilityMatrix.Tests/StabilityMatrix.Tests.csproj +++ b/StabilityMatrix.Tests/StabilityMatrix.Tests.csproj @@ -5,7 +5,7 @@ win-x64;linux-x64;osx-x64;osx-arm64 enable enable - + true false true