From 55b9fe08a494c4336567f869cad36b5a9c49a082 Mon Sep 17 00:00:00 2001 From: Niall Crowe Date: Wed, 18 Sep 2024 10:39:29 +0100 Subject: [PATCH] Drop support for EOL .NET versions, remove obsolete tests (#89) and update test matrix. Dropping support from tests for versions of .NET that are now EOL. Removing tests that are rendered obsolete by recent changes. Updating the test matrix for the latest OS releases. Closes #76 --- .github/workflows/ci.yml | 84 ++++++++++++++----- .../test.json | 4 +- .../test.sh | 0 .../CsprojCompatibilityPatcherTest.cs | 36 -------- Turkey.Tests/SourceBuildTest.cs | 11 --- Turkey/CsprojCompatibilityPatcher.cs | 33 -------- Turkey/Program.cs | 30 ------- Turkey/SourceBuild.cs | 14 +--- Turkey/Test.cs | 56 ------------- Turkey/resources/project10xunit.json | 27 ------ Turkey/resources/project11xunit.json | 27 ------ 11 files changed, 66 insertions(+), 256 deletions(-) rename Samples/{BashTestSpecificToDotNet2x => BashTestSpecificToDotNet6x}/test.json (68%) rename Samples/{BashTestSpecificToDotNet2x => BashTestSpecificToDotNet6x}/test.sh (100%) delete mode 100644 Turkey.Tests/CsprojCompatibilityPatcherTest.cs delete mode 100644 Turkey/CsprojCompatibilityPatcher.cs delete mode 100644 Turkey/resources/project10xunit.json delete mode 100644 Turkey/resources/project11xunit.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 462c69f..1efdc42 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,20 +14,29 @@ jobs: fail-fast: false matrix: container_image: - - quay.io/centos/centos:stream8 - quay.io/centos/centos:stream9 - - registry.fedoraproject.org/fedora:37 - - registry.fedoraproject.org/fedora:38 + - quay.io/centos/centos:stream10-development - registry.fedoraproject.org/fedora:39 + - registry.fedoraproject.org/fedora:40 - registry.fedoraproject.org/fedora:rawhide - registry.access.redhat.com/ubi8 - registry.access.redhat.com/ubi9 dotnet_version: - "6.0" - - "7.0" + - "8.0" + exclude: + - container_image: registry.fedoraproject.org/fedora:rawhide + dotnet_version: "6.0" + - container_image: quay.io/centos/centos:stream10-development + dotnet_version: "6.0" include: - - container_image: quay.io/centos/centos:stream9 - dotnet_version: "8.0" + - container_image: registry.fedoraproject.org/fedora:40 + dotnet_version: "9.0" + - container_image: registry.fedoraproject.org/fedora:rawhide + dotnet_version: "9.0" + - container_image: quay.io/centos/centos:stream10-development + dotnet_version: "9.0" + container: image: ${{ matrix.container_image }} @@ -38,13 +47,22 @@ jobs: timeout-minutes: 5 run: | set -euo pipefail - if command -v dnf; then - dnf install -y dotnet-sdk-${{ matrix.dotnet_version }} git make - elif command -v apk; then - apk add bash curl git icu-libs krb5-libs libgcc libintl libssl1.1 libstdc++ make zlib - curl -sSLO https://dot.net/v1/dotnet-install.sh - chmod +x ./dotnet-install.sh - ./dotnet-install.sh --channel ${{ matrix.dotnet_version }} + if [[ ${{ matrix.dotnet_version }} == 9.* ]]; then + dnf install 'dnf-command(copr)' -y + cat /etc/os-release + if grep centos /etc/os-release ; then + dnf copr enable @dotnet-sig/dotnet-preview centos-stream-10-x86_64 -y + else + dnf copr enable @dotnet-sig/dotnet-preview -y + fi + dnf install -y dotnet-sdk-aot-${{ matrix.dotnet_version }} + fi + dnf install -y dotnet-sdk-${{ matrix.dotnet_version }} git make + if [[ ! ${{ matrix.dotnet_version }} == *6* ]]; then + dnf install -y \ + dotnet-sdk-dbg-${{ matrix.dotnet_version }} \ + dotnet-runtime-dbg-${{ matrix.dotnet_version }} \ + aspnetcore-runtime-dbg-${{ matrix.dotnet_version }} fi - uses: actions/checkout@v2 @@ -80,20 +98,28 @@ jobs: fail-fast: false matrix: container_image: - - quay.io/centos/centos:stream8 - quay.io/centos/centos:stream9 - - registry.fedoraproject.org/fedora:37 - - registry.fedoraproject.org/fedora:38 + - quay.io/centos/centos:stream10-development - registry.fedoraproject.org/fedora:39 + - registry.fedoraproject.org/fedora:40 - registry.fedoraproject.org/fedora:rawhide - registry.access.redhat.com/ubi8 - registry.access.redhat.com/ubi9 dotnet_version: - "6.0" - - "7.0" + - "8.0" + exclude: + - container_image: registry.fedoraproject.org/fedora:rawhide + dotnet_version: "6.0" + - container_image: quay.io/centos/centos:stream10-development + dotnet_version: "6.0" include: - - container_image: quay.io/centos/centos:stream9 - dotnet_version: "8.0" + - container_image: registry.fedoraproject.org/fedora:40 + dotnet_version: "9.0" + - container_image: registry.fedoraproject.org/fedora:rawhide + dotnet_version: "9.0" + - container_image: quay.io/centos/centos:stream10-development + dotnet_version: "9.0" container: @@ -105,7 +131,23 @@ jobs: timeout-minutes: 5 run: | set -euo pipefail + if [[ ${{ matrix.dotnet_version }} == 9.* ]]; then + dnf install 'dnf-command(copr)' -y + cat /etc/os-release + if grep centos /etc/os-release ; then + dnf copr enable @dotnet-sig/dotnet-preview centos-stream-10-x86_64 -y + else + dnf copr enable @dotnet-sig/dotnet-preview -y + fi + dnf install -y dotnet-sdk-aot-${{ matrix.dotnet_version }} + fi dnf install -y dotnet-sdk-${{ matrix.dotnet_version }} git make + if [[ ! ${{ matrix.dotnet_version }} == *6* ]]; then + dnf install -y \ + dotnet-sdk-dbg-${{ matrix.dotnet_version }} \ + dotnet-runtime-dbg-${{ matrix.dotnet_version }} \ + aspnetcore-runtime-dbg-${{ matrix.dotnet_version }} + fi # We need to fetch the tags, so 'git tag' in 'make publish' below works - uses: actions/checkout@v2 @@ -127,9 +169,7 @@ jobs: - name: Install Test dependencies timeout-minutes: 2 run: | - dnf install -y python3 wget \ - $(grep '^Dependencies(dnf): ' dotnet-regular-tests/README.md | cut -d: -f2-) \ - --skip-broken + dnf install -y python3 wget $(grep '^Dependencies(dnf): ' dotnet-regular-tests/README.md | cut -d: -f2-) --skip-broken - name: Run reproducers run: | diff --git a/Samples/BashTestSpecificToDotNet2x/test.json b/Samples/BashTestSpecificToDotNet6x/test.json similarity index 68% rename from Samples/BashTestSpecificToDotNet2x/test.json rename to Samples/BashTestSpecificToDotNet6x/test.json index cfa7c79..71b38f6 100644 --- a/Samples/BashTestSpecificToDotNet2x/test.json +++ b/Samples/BashTestSpecificToDotNet6x/test.json @@ -1,8 +1,8 @@ { - "name": "BashTestSpecificToDotNet2x", + "name": "BashTestSpecificToDotNet6x", "enabled": true, "requiresSdk": true, - "version": "2.x", + "version": "6.x", "versionSpecific": true, "type": "bash", "cleanup": true, diff --git a/Samples/BashTestSpecificToDotNet2x/test.sh b/Samples/BashTestSpecificToDotNet6x/test.sh similarity index 100% rename from Samples/BashTestSpecificToDotNet2x/test.sh rename to Samples/BashTestSpecificToDotNet6x/test.sh diff --git a/Turkey.Tests/CsprojCompatibilityPatcherTest.cs b/Turkey.Tests/CsprojCompatibilityPatcherTest.cs deleted file mode 100644 index f69e0e8..0000000 --- a/Turkey.Tests/CsprojCompatibilityPatcherTest.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; - -using Turkey; - -using Xunit; - -namespace Turkey.Tests -{ - public class CsprojCompatibilityPatcherTest - { - [Theory] - [InlineData("netcoreapp1.0", "2.1", "netcoreapp2.1")] - [InlineData("netcoreapp2.1", "3.1", "netcoreapp3.1")] - [InlineData("netcoreapp3.1", "3.1", "netcoreapp3.1")] - [InlineData("net5.0", "3.1", "netcoreapp3.1")] - [InlineData("net5.0", "2.1", "netcoreapp2.1")] - public void TargetFrameworksAreReplacedCorrectly(string currentTfm, string runtimeVersion, string expectedTfm) - { - Version newRuntimeVersion = Version.Parse(runtimeVersion); - string csproj = $@" - - - - {currentTfm} - - -"; - string patched = new CsprojCompatibilityPatcher().Patch(csproj, newRuntimeVersion); - Assert.Contains(expectedTfm, patched); - if (currentTfm != expectedTfm) - { - Assert.DoesNotContain(currentTfm, patched); - } - } - } -} diff --git a/Turkey.Tests/SourceBuildTest.cs b/Turkey.Tests/SourceBuildTest.cs index 3ce5f0b..bf6b112 100644 --- a/Turkey.Tests/SourceBuildTest.cs +++ b/Turkey.Tests/SourceBuildTest.cs @@ -48,17 +48,6 @@ protected override Task SendAsync(HttpRequestMessage messag } } - [Fact] - public async Task VerifyProdConFeedIsLookedUpAndThenTheFeedIsVerifiedToResolve() - { - var messageHandler = new ProdConHandler(); - var client = new HttpClient(messageHandler); - var sourceBuild = new SourceBuild(client); - - var feed = await sourceBuild.GetProdConFeedAsync(Version.Parse("3.1")); - - Assert.Equal(FAKE_FEED, feed); - } [Fact] public async Task VerifyProdConFeedIsNotUsedForNewReleases() diff --git a/Turkey/CsprojCompatibilityPatcher.cs b/Turkey/CsprojCompatibilityPatcher.cs deleted file mode 100644 index c676965..0000000 --- a/Turkey/CsprojCompatibilityPatcher.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Text.RegularExpressions; -using System.Threading; -using System.Threading.Tasks; - -namespace Turkey -{ - public class CsprojCompatibilityPatcher - { - public string Patch(string originalCsprojContents, Version newRuntime) - { - var pattern = @"net(?:coreapp)?\d\.\d+"; - var versionString = newRuntime.MajorMinor; - string replacement = null; - if (newRuntime.Major < 4) - { - replacement = $"netcoreapp{versionString}"; - } - else - { - replacement = $"net{versionString}"; - } - var output = Regex.Replace(originalCsprojContents, pattern, replacement); - - return output; - } - - } - -} diff --git a/Turkey/Program.cs b/Turkey/Program.cs index 957a5aa..fba1d31 100644 --- a/Turkey/Program.cs +++ b/Turkey/Program.cs @@ -152,25 +152,6 @@ public static async Task GenerateNuGetConfigIfNeededAsync(string additio var nuget = new NuGet(client); var sourceBuild = new SourceBuild(client); - if (netCoreAppVersion.Major < 4) - { - try - { - var prodConUrl = await GetProdConFeedUrlIfNeededAsync(nuget, sourceBuild, netCoreAppVersion); - if (!string.IsNullOrEmpty(prodConUrl)) - { - prodConUrl = prodConUrl.Trim(); - Console.WriteLine($"Packages are not live on nuget.org; using {prodConUrl} as additional package source"); - urls.Add(prodConUrl); - } - } - catch (HttpRequestException exception) - { - Console.WriteLine("WARNING: failed to get ProdCon url. Ignoring Exception:"); - Console.WriteLine(exception.ToString()); - } - } - string nugetConfig = null; if (useSourceBuildNuGetConfig) { @@ -233,17 +214,6 @@ public static IReadOnlySet CreateTraits(Version runtimeVersion, Version return traits; } - public static async Task GetProdConFeedUrlIfNeededAsync(NuGet nuget, SourceBuild sourceBuild, Version netCoreAppVersion) - { - bool live = await nuget.IsPackageLiveAsync("runtime.linux-x64.Microsoft.NetCore.DotNetAppHost", netCoreAppVersion); - if (!live) - { - return await sourceBuild.GetProdConFeedAsync(netCoreAppVersion); - } - - return null; - } - static async Task Main(string[] args) { var rootCommand = new RootCommand(description: "A test runner for running standalone bash-based or xunit tests"); diff --git a/Turkey/SourceBuild.cs b/Turkey/SourceBuild.cs index d12965b..ce847d9 100644 --- a/Turkey/SourceBuild.cs +++ b/Turkey/SourceBuild.cs @@ -18,18 +18,8 @@ public SourceBuild(HttpClient client) public string GetBranchContentUrl(Version version) { - string url; - if (version.Major <= 3) - { - var branchName = "release/" + version.MajorMinor; - url = $"https://raw.githubusercontent.com/dotnet/source-build/{branchName}/"; - } - else - { - var branchName = "release/" + version.MajorMinor + ".1xx"; - url = $"https://raw.githubusercontent.com/dotnet/installer/{branchName}/"; - } - + var branchName = "release/" + version.MajorMinor + ".1xx"; + var url = $"https://raw.githubusercontent.com/dotnet/installer/{branchName}/"; return url; } diff --git a/Turkey/Test.cs b/Turkey/Test.cs index 523395f..dc4b8a7 100644 --- a/Turkey/Test.cs +++ b/Turkey/Test.cs @@ -61,8 +61,6 @@ public async Task RunAsync(Action logger, CancellationToken await File.WriteAllTextAsync(path, NuGetConfig); } - UpdateProjectFilesIfPresent(); - var testResult = await InternalRunAsync(logger, cancelltionToken); if (!string.IsNullOrEmpty(NuGetConfig)) @@ -73,60 +71,6 @@ public async Task RunAsync(Action logger, CancellationToken return testResult; } - private void UpdateProjectFilesIfPresent() - { - if (SystemUnderTest.RuntimeVersion < Version.Parse("2.0")) - { - var projectJsonPath = Path.Combine(this.Directory.FullName, "project.json"); - if (File.Exists(projectJsonPath)) - { - CopyProjectJsonFile(); - } - } - else - { - var csprojFile = $"{Directory.Name}.csproj"; - var csprojPath = Path.Combine(this.Directory.FullName, csprojFile); - if (File.Exists(csprojPath)) - { - UpdateCsprojVersion(csprojPath); - } - } - } - - private void CopyProjectJsonFile() - { - string majorMinor = "" + SystemUnderTest.RuntimeVersion.Major + SystemUnderTest.RuntimeVersion.Minor; - var fileName = $"resources/project{majorMinor}xunit.json"; - var resourceLocation = FindResourceFile(fileName); - var source = resourceLocation; - var dest = Path.Combine(this.Directory.FullName, "project.json"); - File.Copy(source, dest); - } - - private static string FindResourceFile(string name) - { - var assemblyLocation = Assembly.GetExecutingAssembly().Location; - var dir = Path.GetDirectoryName(assemblyLocation); - var resourceLocation = Path.Combine(dir, name); - if (!File.Exists(resourceLocation)) - { - throw new Exception($"Resource {name} at location {resourceLocation} does not exist"); - } - return resourceLocation; - } - - private void UpdateCsprojVersion(string csprojPath) - { - var contents = File.ReadAllText(csprojPath); - var updatedContents = UpdateCsprojContents(contents); - - File.WriteAllText(csprojPath, updatedContents); - } - - private string UpdateCsprojContents(string contents) => - new CsprojCompatibilityPatcher().Patch(contents, this.SystemUnderTest.RuntimeVersion); - protected abstract Task InternalRunAsync(Action logger, CancellationToken cancellationToken); } diff --git a/Turkey/resources/project10xunit.json b/Turkey/resources/project10xunit.json deleted file mode 100644 index cdd1bda..0000000 --- a/Turkey/resources/project10xunit.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "version": "1.0.0-*", - "buildOptions": { - "warningsAsErrors": true, - "debugType": "portable" - }, - "dependencies": { - "System.Runtime.Serialization.Primitives": "4.1.1", - "xunit": "2.1.0", - "dotnet-test-xunit": "1.0.0-rc2-192208-24" - }, - "testRunner": "xunit", - "frameworks": { - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.10" - } - }, - "imports": [ - "dotnet5.4", - "portable-net451+win8" - ] - } - } -} diff --git a/Turkey/resources/project11xunit.json b/Turkey/resources/project11xunit.json deleted file mode 100644 index 88503da..0000000 --- a/Turkey/resources/project11xunit.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "version": "1.0.0-*", - "buildOptions": { - "warningsAsErrors": true, - "debugType": "portable" - }, - "dependencies": { - "System.Runtime.Serialization.Primitives": "4.3.0", - "xunit": "2.1.0", - "dotnet-test-xunit": "1.0.0-rc2-192208-24" - }, - "testRunner": "xunit", - "frameworks": { - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.1.7" - } - }, - "imports": [ - "dotnet5.4", - "portable-net451+win8" - ] - } - } -}