Skip to content

Commit

Permalink
Remove support for upgrades to .NET 7
Browse files Browse the repository at this point in the history
- Remove support for upgrading to .NET 7 as it goes out of support on 14th May.
- Fix xunit analyser suggestion about non-serializable test case.
  • Loading branch information
martincostello committed May 5, 2024
1 parent f024c11 commit a718756
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 93 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ jobs:
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
9.0.x
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ jobs:
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
9.0.x
Expand Down Expand Up @@ -135,7 +134,6 @@ jobs:
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
9.0.x
Expand Down
6 changes: 0 additions & 6 deletions src/DotNetBumper.Core/Upgraders/RuntimeIdentifierUpgrader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ internal sealed partial class RuntimeIdentifierUpgrader(
StatusContext context,
CancellationToken cancellationToken)
{
if (upgrade.Channel < DotNetVersions.EightPointZero)
{
// RIDs only need updating if upgrading to .NET 8.0+
return ProcessingResult.None;
}

Log.UpgradingRuntimeIdentifier(Logger);

var result = ProcessingResult.None;
Expand Down
4 changes: 2 additions & 2 deletions tests/DotNetBumper.Tests/DotNetChannelTestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ public sealed class DotNetChannelTestData : TheoryData<string>
{
public DotNetChannelTestData()
{
const int MinimumVersion = 7;
const int MinimumVersion = 8;

foreach (int version in Enumerable.Range(MinimumVersion, 4))
foreach (int version in Enumerable.Range(MinimumVersion, 3))
{
Add(version.ToString("N1", CultureInfo.InvariantCulture));
}
Expand Down
1 change: 0 additions & 1 deletion tests/DotNetBumper.Tests/EndToEndTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public static TheoryData<BumperTestCase> TestCases()
var testCases = new TheoryData<BumperTestCase>
{
new("7.0.100", ["net6.0", "net7.0"]),
new("6.0.100", ["net6.0"], ["--channel=7.0"]),
new("6.0.100", ["net6.0"], ["--channel=8.0"]),
new("6.0.100", ["net6.0"], ["--channel=9.0"]),
new("6.0.100", ["net6.0"], ["--upgrade-type=latest"]),
Expand Down
30 changes: 19 additions & 11 deletions tests/DotNetBumper.Tests/IAnsiConsoleExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,37 @@ namespace MartinCostello.DotNetBumper;

public static class IAnsiConsoleExtensionsTests
{
public static TheoryData<IEnvironment> Environments()
public static TheoryData<bool, bool> Environments()
{
var testCases = new TheoryData<IEnvironment>();
var testCases = new TheoryData<bool, bool>();

foreach (bool isLocal in new[] { true, false })
{
var environment = Substitute.For<IEnvironment>();

environment.IsGitHubActions.Returns(!isLocal);
environment.SupportsLinks.Returns(isLocal);

testCases.Add(environment);
testCases.Add(!isLocal, isLocal);
}

return testCases;
}

[Theory]
[MemberData(nameof(Environments))]
public static void WriteDisclaimer_Does_Not_Throw(IEnvironment environment)
public static void WriteDisclaimer_Does_Not_Throw(bool isGitHubActions, bool supportsLinks)
{
// Arrange
var console = Substitute.For<IAnsiConsole>();
var environment = CreateEnvironment(isGitHubActions, supportsLinks);

// Act and Assert
Should.NotThrow(() => console.WriteDisclaimer(environment, new(8, 0)));
}

[Theory]
[MemberData(nameof(Environments))]
public static void WriteRuntimeNearingEndOfSupportWarning_Does_Not_Throw(IEnvironment environment)
public static void WriteRuntimeNearingEndOfSupportWarning_Does_Not_Throw(bool isGitHubActions, bool supportsLinks)
{
// Arrange
var console = Substitute.For<IAnsiConsole>();
var environment = CreateEnvironment(isGitHubActions, supportsLinks);

var upgrade = new UpgradeInfo()
{
Expand Down Expand Up @@ -81,10 +78,11 @@ public static void WriteExceptionLine_Does_Not_Throw()

[Theory]
[MemberData(nameof(Environments))]
public static void WriteProgressLine_Does_Not_Throw(IEnvironment environment)
public static void WriteProgressLine_Does_Not_Throw(bool isGitHubActions, bool supportsLinks)
{
// Arrange
var console = Substitute.For<IAnsiConsole>();
var environment = CreateEnvironment(isGitHubActions, supportsLinks);

// Act and Assert
Should.NotThrow(() => console.WriteProgressLine(environment, "A progress message."));
Expand Down Expand Up @@ -128,4 +126,14 @@ public static void WriteUnsupportedLambdaRuntimeWarning_Does_Not_Throw()
// Act and Assert
Should.NotThrow(() => console.WriteUnsupportedLambdaRuntimeWarning(upgrade));
}

private static IEnvironment CreateEnvironment(bool isGitHubActions, bool supportsLinks)
{
var environment = Substitute.For<IEnvironment>();

environment.IsGitHubActions.Returns(isGitHubActions);
environment.SupportsLinks.Returns(supportsLinks);

return environment;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public static TheoryData<string> Channels()
#pragma warning disable IDE0028 // See https://github.com/dotnet/roslyn/issues/72668
return new()
{
"7.0",
"8.0",
"9.0",
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public async Task UpgradeAsync_Upgrades_Properties(string channel)

[Theory]
[InlineData("7.0", DotNetReleaseType.Sts, DotNetSupportPhase.Active)]
[InlineData("7.0", DotNetReleaseType.Sts, DotNetSupportPhase.Eol)]
[InlineData("9.0", DotNetReleaseType.Sts, DotNetSupportPhase.Preview)]
[InlineData("9.0", DotNetReleaseType.Sts, DotNetSupportPhase.GoLive)]
[InlineData("9.0", DotNetReleaseType.Sts, DotNetSupportPhase.Active)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public class AwsSamTemplateUpgraderTests(ITestOutputHelper outputHelper)
return new()
{
{ "7.0", DotNetReleaseType.Sts, DotNetSupportPhase.Active },
{ "7.0", DotNetReleaseType.Sts, DotNetSupportPhase.Eol },
{ "9.0", DotNetReleaseType.Sts, DotNetSupportPhase.Preview },
{ "9.0", DotNetReleaseType.Sts, DotNetSupportPhase.GoLive },
{ "9.0", DotNetReleaseType.Sts, DotNetSupportPhase.Active },
Expand Down Expand Up @@ -197,6 +198,7 @@ public async Task UpgradeAsync_Upgrades_Yaml_Template(string channel, string fil

[Theory]
[InlineData("7.0", DotNetReleaseType.Sts, DotNetSupportPhase.Active)]
[InlineData("7.0", DotNetReleaseType.Sts, DotNetSupportPhase.Eol)]
[InlineData("9.0", DotNetReleaseType.Sts, DotNetSupportPhase.Preview)]
[InlineData("9.0", DotNetReleaseType.Sts, DotNetSupportPhase.GoLive)]
[InlineData("9.0", DotNetReleaseType.Sts, DotNetSupportPhase.Active)]
Expand Down
31 changes: 11 additions & 20 deletions tests/DotNetBumper.Tests/Upgraders/DotNetCodeUpgraderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ public static TheoryData<string> Channels()
#pragma warning disable IDE0028 // See https://github.com/dotnet/roslyn/issues/72668
return new()
{
"7.0",
//// "8.0", See https://github.com/dotnet/sdk/issues/39742
//// "9.0", See https://github.com/dotnet/sdk/issues/39909 and https://github.com/dotnet/sdk/issues/40174
"8.0",
"9.0",
};
#pragma warning restore IDE0028
}
Expand All @@ -23,10 +22,8 @@ public static TheoryData<string> Channels()
[MemberData(nameof(Channels))]
public async Task UpgradeAsync_Applies_Code_Fix(string channel)
{
#if NET9_0_OR_GREATER
// HACK For some yet-unknown reason, this test fails with .NET 9
Skip.If(true, "Fails with .NET 9.");
#endif
Skip.If(channel is "8.0", "See https://github.com/dotnet/sdk/issues/39742");
Skip.If(channel is "9.0", "See https://github.com/dotnet/sdk/issues/39909 and https://github.com/dotnet/sdk/issues/40174");

// Arrange
var upgrade = await GetUpgradeAsync(channel);
Expand Down Expand Up @@ -76,10 +73,8 @@ public class Person
[MemberData(nameof(Channels))]
public async Task UpgradeAsync_Applies_Code_Fixes(string channel)
{
#if NET9_0_OR_GREATER
// HACK For some yet-unknown reason, this test fails with .NET 9
Skip.If(true, "Fails with .NET 9.");
#endif
Skip.If(channel is "8.0", "See https://github.com/dotnet/sdk/issues/39742");
Skip.If(channel is "9.0", "See https://github.com/dotnet/sdk/issues/39909 and https://github.com/dotnet/sdk/issues/40174");

// Arrange
var upgrade = await GetUpgradeAsync(channel);
Expand Down Expand Up @@ -129,14 +124,12 @@ public class Person
actual.ShouldBe(ProcessingResult.None);
}

[SkippableTheory(Skip = "Flaky test.")]
[SkippableTheory]
[MemberData(nameof(Channels))]
public async Task UpgradeAsync_Honors_User_Project_Settings(string channel)
{
#if NET9_0_OR_GREATER
// HACK For some yet-unknown reason, this test fails with .NET 9
Skip.If(true, "Fails with .NET 9.");
#endif
Skip.If(channel is "8.0", "See https://github.com/dotnet/sdk/issues/39742");
Skip.If(channel is "9.0", "See https://github.com/dotnet/sdk/issues/39909 and https://github.com/dotnet/sdk/issues/40174");

// Arrange
var upgrade = await GetUpgradeAsync(channel);
Expand Down Expand Up @@ -179,10 +172,8 @@ public class Person
[MemberData(nameof(Channels))]
public async Task UpgradeAsync_Does_Not_Fix_Information_Diagnostics(string channel)
{
#if NET9_0_OR_GREATER
// HACK For some yet-unknown reason, this test fails with .NET 9
Skip.If(true, "Fails with .NET 9.");
#endif
Skip.If(channel is "8.0", "See https://github.com/dotnet/sdk/issues/39742");
Skip.If(channel is "9.0", "See https://github.com/dotnet/sdk/issues/39909 and https://github.com/dotnet/sdk/issues/40174");

// Arrange
var upgrade = await GetUpgradeAsync(channel);
Expand Down
28 changes: 14 additions & 14 deletions tests/DotNetBumper.Tests/Upgraders/PowerShellScriptUpgraderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ public async Task UpgradeAsync_Upgrades_PowerShell_Script_Embedded_In_Actions_Wo
name: build
on: [push]
jobs:
build:
runs-on: ubuntu-latest
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v3
Expand All @@ -145,8 +145,8 @@ public async Task UpgradeAsync_Upgrades_PowerShell_Script_Embedded_In_Actions_Wo
name: build
on: [push]
jobs:
build:
runs-on: ubuntu-latest
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v3
Expand Down Expand Up @@ -196,8 +196,8 @@ public async Task UpgradeAsync_Upgrades_PowerShell_Script_Embedded_In_Actions_Wo
name: build
on: [push]
jobs:
build:
runs-on: ubuntu-latest
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v3
Expand All @@ -211,8 +211,8 @@ public async Task UpgradeAsync_Upgrades_PowerShell_Script_Embedded_In_Actions_Wo
name: build
on: [push]
jobs:
build:
runs-on: ubuntu-latest
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v3
Expand Down Expand Up @@ -264,8 +264,8 @@ public async Task UpgradeAsync_Upgrades_PowerShell_Scripts_Embedded_In_Actions_W

jobs:

build:
runs-on: ubuntu-latest
build:
runs-on: ubuntu-latest
steps:

- name: Install .NET
Expand Down Expand Up @@ -305,8 +305,8 @@ public async Task UpgradeAsync_Upgrades_PowerShell_Scripts_Embedded_In_Actions_W

jobs:

build:
runs-on: ubuntu-latest
build:
runs-on: ubuntu-latest
steps:

- name: Install .NET
Expand Down Expand Up @@ -378,8 +378,8 @@ public async Task UpgradeAsync_Ignores_Actions_Workflows_With_No_PowerShell()
name: build
on: [push]
jobs:
build:
runs-on: ubuntu-latest
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,40 +296,6 @@ public async Task UpgradeAsync_Handles_Invalid_Xml(string content, ProcessingRes
actual.ShouldBe(expected);
}

[Fact]
public async Task UpgradeAsync_Does_Not_Change_DotNet_7_Runtime_Identifiers()
{
// Arrange
var builder = Project
.Create(hasSdk: true)
.Property("RuntimeIdentifier", "win10-x64");

var fileContents = builder.Xml;

using var fixture = new UpgraderFixture(outputHelper);
var projectFile = await fixture.Project.AddFileAsync("Directory.Build.props", fileContents);

var upgrade = new UpgradeInfo()
{
Channel = Version.Parse("7.0"),
EndOfLife = DateOnly.MaxValue,
ReleaseType = DotNetReleaseType.Lts,
SdkVersion = new("7.0.100"),
SupportPhase = DotNetSupportPhase.Active,
};

var target = CreateTarget(fixture);

// Act
ProcessingResult actualUpdated = await target.UpgradeAsync(upgrade, CancellationToken.None);

// Assert
actualUpdated.ShouldBe(ProcessingResult.None);

string actualContent = await File.ReadAllTextAsync(projectFile);
actualContent.ShouldBe(fileContents);
}

[Theory]
[ClassData(typeof(FileEncodingTestData))]
public async Task UpgradeAsync_Preserves_Bom(string newLine, bool hasUtf8Bom)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public class TargetFrameworkUpgraderTests(ITestOutputHelper outputHelper)
{
string[] channels =
[
"7.0",
"8.0",
"9.0",
"10.0",
Expand Down

0 comments on commit a718756

Please sign in to comment.