From 95b18307f44cdd05e44fe044687ac38bdd1817f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Luthi?= Date: Tue, 28 May 2024 11:20:40 +0200 Subject: [PATCH] Fix continuous integration workflow --- .github/workflows/ci.yml | 4 +- build.cmd | 4 -- build.sh | 4 -- targets/DotnetSdkManager.cs | 78 ------------------------------------- targets/Program.cs | 24 ------------ targets/Targets.csproj | 15 ------- 6 files changed, 2 insertions(+), 127 deletions(-) delete mode 100644 build.cmd delete mode 100755 build.sh delete mode 100644 targets/DotnetSdkManager.cs delete mode 100644 targets/Program.cs delete mode 100644 targets/Targets.csproj diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ccb0524..8b96543b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,9 +9,9 @@ jobs: steps: - uses: actions/checkout@master - name: Set up .NET Core - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v4 with: dotnet-version: '8.0.x' - run: dotnet --info - name: Build solution and run all tests - run: ./build.sh \ No newline at end of file + run: dotnet test --verbosity normal \ No newline at end of file diff --git a/build.cmd b/build.cmd deleted file mode 100644 index 8671bd1b..00000000 --- a/build.cmd +++ /dev/null @@ -1,4 +0,0 @@ -@echo Off -cd %~dp0 - -dotnet run --project targets --no-launch-profile -- %* \ No newline at end of file diff --git a/build.sh b/build.sh deleted file mode 100755 index 2da3b1fe..00000000 --- a/build.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -dotnet run --project targets --no-launch-profile -- "$@" \ No newline at end of file diff --git a/targets/DotnetSdkManager.cs b/targets/DotnetSdkManager.cs deleted file mode 100644 index fc3fb0b0..00000000 --- a/targets/DotnetSdkManager.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Drawing; -using System.IO; -using System.Linq; -using System.Net; -using System.Runtime.InteropServices; -using static SimpleExec.Command; -using Console = Colorful.Console; - -class DotnetSdkManager -{ - const string customSdkInstallDir = ".dotnet"; - const string buildSupportDir = ".build"; - - string dotnetPath = null; - - public string GetDotnetCliPath() - { - if (dotnetPath == null) - { - var (customSdk, sdkPath, sdkVersion) = EnsureRequiredSdkIsInstalled(); - Console.WriteLine($"Build will be executed using {(customSdk ? "user defined SDK" : "default SDK")}, Version '{sdkVersion}'.{(customSdk ? $" Installed at '{sdkPath}'" : "")}"); - dotnetPath = customSdk - ? Path.Combine(sdkPath, "dotnet") - : "dotnet"; - } - - return dotnetPath; - } - - (bool customSdk, string sdkPath, string sdkVersion) EnsureRequiredSdkIsInstalled() - { - var currentSdkVersion = Read("dotnet", "--version").TrimEnd(Environment.NewLine.ToCharArray()); - var requiredSdkFile = Directory.EnumerateFiles(".", ".required-sdk", SearchOption.TopDirectoryOnly).SingleOrDefault(); - - if (string.IsNullOrWhiteSpace(requiredSdkFile)) - { - Console.WriteLine("No custom SDK is required.", Color.Green); - return (false, "", currentSdkVersion); - } - - var requiredSdkVersion = File.ReadAllText(requiredSdkFile).TrimEnd(Environment.NewLine.ToCharArray()); - - if (string.Compare(currentSdkVersion, requiredSdkVersion) == 0) - { - Console.WriteLine("Insalled SDK is the same as required one, '.required-sdk' file is not necessary. Build will use the SDK available on the machine.", Color.Yellow); - return (false, "", currentSdkVersion); - } - - Console.WriteLine($"Installed SDK ({currentSdkVersion}) doesn't match required one ({requiredSdkVersion}).", Color.Yellow); - Console.WriteLine($"{requiredSdkVersion} will be installed and and used to run the build.", Color.Yellow); - - var installScriptName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - ? "dotnet-install.ps1" - : "dotnet-install.sh"; - - var installScriptUrl = $"https://dot.net/v1/{installScriptName}"; - - Console.WriteLine($"Downloading {installScriptName} script, from {installScriptUrl}."); - - Directory.CreateDirectory(buildSupportDir); - new WebClient().DownloadFile(installScriptUrl, Path.Combine(buildSupportDir, installScriptName)); - - Console.WriteLine($"Ready to install custom SDK, version {requiredSdkVersion}."); - - var installScriptLocation = Path.Combine(".", buildSupportDir, installScriptName); - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - Run("powershell", $@"{installScriptLocation} -Version {requiredSdkVersion} -InstallDir {customSdkInstallDir}"); - } - else - { - Run("bash", $@"{installScriptLocation} --version {requiredSdkVersion} --install-dir {customSdkInstallDir}"); - } - - return (true, customSdkInstallDir, requiredSdkVersion); - } -} \ No newline at end of file diff --git a/targets/Program.cs b/targets/Program.cs deleted file mode 100644 index d94c3878..00000000 --- a/targets/Program.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.IO; -using static Bullseye.Targets; -using static SimpleExec.Command; - -internal class Program -{ - public static void Main(string[] args) - { - var sdk = new DotnetSdkManager(); - - Target("default", DependsOn("test")); - - Target("build", - Directory.EnumerateFiles(".", "*.sln", SearchOption.AllDirectories), - solution => Run(sdk.GetDotnetCliPath(), $"build \"{solution}\" --configuration Release")); - - Target("test", DependsOn("build"), - Directory.EnumerateFiles("tests", "*Tests.csproj", SearchOption.AllDirectories), - proj => Run(sdk.GetDotnetCliPath(), $"test \"{proj}\" --configuration Release --no-build")); - - RunTargetsAndExit(args); - } -} diff --git a/targets/Targets.csproj b/targets/Targets.csproj deleted file mode 100644 index 5174a0d8..00000000 --- a/targets/Targets.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - latest - Exe - net7.0 - - - - - - - - -