Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to .NET 8 #1302

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_BUCKET_NAME: ${{ secrets.AWS_BUCKET_NAME }}
LD_LIBRARY_PATH: '$LD_LIBRARY_PATH:${{ github.workspace }}/src/OctoshiftCLI.IntegrationTests/bin/Debug/net6.0/runtimes/ubuntu.18.04-x64/native'
run: dotnet test src/OctoshiftCLI.IntegrationTests/OctoshiftCLI.IntegrationTests.csproj --filter "${{ matrix.source-vcs }}ToGithub" --logger:"junit;LogFilePath=integration-tests.xml" /p:VersionPrefix=9.9
run: dotnet test src/OctoshiftCLI.IntegrationTests/OctoshiftCLI.IntegrationTests.csproj --filter "${{ matrix.source-vcs }}ToGithub" --logger:"junit;LogFilePath=integration-tests.xml" --logger "console;verbosity=normal" /p:VersionPrefix=9.9

- name: Publish Integration Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ jobs:
AWS_BUCKET_NAME: ${{ secrets.AWS_BUCKET_NAME }}
GEI_DEBUG_MODE: 'true'
LD_LIBRARY_PATH: '$LD_LIBRARY_PATH:${{ github.workspace }}/src/OctoshiftCLI.IntegrationTests/bin/Debug/net6.0/runtimes/ubuntu.18.04-x64/native'
run: dotnet test src/OctoshiftCLI.IntegrationTests/OctoshiftCLI.IntegrationTests.csproj --filter "${{ matrix.source-vcs }}ToGithub" --logger:"junit;LogFilePath=integration-tests.xml" /p:VersionPrefix=9.9
run: dotnet test src/OctoshiftCLI.IntegrationTests/OctoshiftCLI.IntegrationTests.csproj --filter "${{ matrix.source-vcs }}ToGithub" --logger:"junit;LogFilePath=integration-tests.xml" --logger "console;verbosity=normal" /p:VersionPrefix=9.9

- name: Publish Integration Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.413",
"version": "8.0.404",
"rollForward": "minor"
}
}
24 changes: 12 additions & 12 deletions publish.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if ((Test-Path env:SKIP_WINDOWS) -And $env:SKIP_WINDOWS.ToUpper() -eq "TRUE") {
Write-Output "Skipping ado2gh Windows build because SKIP_WINDOWS is set"
}
else {
dotnet publish src/ado2gh/ado2gh.csproj -c Release -o dist/win-x64/ -r win-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true --self-contained true /p:DebugType=None /p:IncludeNativeLibrariesForSelfExtract=true /p:VersionPrefix=$AssemblyVersion
dotnet publish src/ado2gh/ado2gh.csproj -c Release -o dist/win-x64/ -r win-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true -p:TrimMode=partial --self-contained true /p:DebugType=None /p:IncludeNativeLibrariesForSelfExtract=true /p:VersionPrefix=$AssemblyVersion

if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
Expand All @@ -27,7 +27,7 @@ else {

Copy-Item ./dist/win-x64/ado2gh.exe ./dist/win-x64/ado2gh-windows-amd64.exe

dotnet publish src/ado2gh/ado2gh.csproj -c Release -o dist/win-x86/ -r win-x86 -p:PublishSingleFile=true -p:PublishTrimmed=true --self-contained true /p:DebugType=None /p:IncludeNativeLibrariesForSelfExtract=true /p:VersionPrefix=$AssemblyVersion
dotnet publish src/ado2gh/ado2gh.csproj -c Release -o dist/win-x86/ -r win-x86 -p:PublishSingleFile=true -p:PublishTrimmed=true -p:TrimMode=partial --self-contained true /p:DebugType=None /p:IncludeNativeLibrariesForSelfExtract=true /p:VersionPrefix=$AssemblyVersion

if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
Expand All @@ -46,7 +46,7 @@ if ((Test-Path env:SKIP_LINUX) -And $env:SKIP_LINUX.ToUpper() -eq "TRUE") {
Write-Output "Skipping ado2gh Linux build because SKIP_LINUX is set"
}
else {
dotnet publish src/ado2gh/ado2gh.csproj -c Release -o dist/linux-x64/ -r linux-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true --self-contained true /p:DebugType=None /p:IncludeNativeLibrariesForSelfExtract=true /p:VersionPrefix=$AssemblyVersion
dotnet publish src/ado2gh/ado2gh.csproj -c Release -o dist/linux-x64/ -r linux-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true -p:TrimMode=partial --self-contained true /p:DebugType=None /p:IncludeNativeLibrariesForSelfExtract=true /p:VersionPrefix=$AssemblyVersion

if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
Expand All @@ -65,7 +65,7 @@ if ((Test-Path env:SKIP_MACOS) -And $env:SKIP_MACOS.ToUpper() -eq "TRUE") {
Write-Output "Skipping ado2gh MacOS build because SKIP_MACOS is set"
}
else {
dotnet publish src/ado2gh/ado2gh.csproj -c Release -o dist/osx-x64/ -r osx-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true --self-contained true /p:DebugType=None /p:IncludeNativeLibrariesForSelfExtract=true /p:VersionPrefix=$AssemblyVersion
dotnet publish src/ado2gh/ado2gh.csproj -c Release -o dist/osx-x64/ -r osx-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true -p:TrimMode=partial --self-contained true /p:DebugType=None /p:IncludeNativeLibrariesForSelfExtract=true /p:VersionPrefix=$AssemblyVersion

if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
Expand All @@ -86,7 +86,7 @@ if ((Test-Path env:SKIP_WINDOWS) -And $env:SKIP_WINDOWS.ToUpper() -eq "TRUE") {
Write-Output "Skipping gei Windows build because SKIP_WINDOWS is set"
}
else {
dotnet publish src/gei/gei.csproj -c Release -o dist/win-x64/ -r win-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true --self-contained true /p:DebugType=None /p:IncludeNativeLibrariesForSelfExtract=true /p:VersionPrefix=$AssemblyVersion
dotnet publish src/gei/gei.csproj -c Release -o dist/win-x64/ -r win-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true -p:TrimMode=partial --self-contained true /p:DebugType=None /p:IncludeNativeLibrariesForSelfExtract=true /p:VersionPrefix=$AssemblyVersion

if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
Expand All @@ -98,7 +98,7 @@ else {

Rename-Item ./dist/win-x64/gei.exe gei-windows-amd64.exe

dotnet publish src/gei/gei.csproj -c Release -o dist/win-x86/ -r win-x86 -p:PublishSingleFile=true -p:PublishTrimmed=true --self-contained true /p:DebugType=None /p:IncludeNativeLibrariesForSelfExtract=true /p:VersionPrefix=$AssemblyVersion
dotnet publish src/gei/gei.csproj -c Release -o dist/win-x86/ -r win-x86 -p:PublishSingleFile=true -p:PublishTrimmed=true -p:TrimMode=partial --self-contained true /p:DebugType=None /p:IncludeNativeLibrariesForSelfExtract=true /p:VersionPrefix=$AssemblyVersion

if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
Expand All @@ -115,7 +115,7 @@ if ((Test-Path env:SKIP_LINUX) -And $env:SKIP_LINUX.ToUpper() -eq "TRUE") {
Write-Output "Skipping gei Linux build because SKIP_LINUX is set"
}
else {
dotnet publish src/gei/gei.csproj -c Release -o dist/linux-x64/ -r linux-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true --self-contained true /p:DebugType=None /p:IncludeNativeLibrariesForSelfExtract=true /p:VersionPrefix=$AssemblyVersion
dotnet publish src/gei/gei.csproj -c Release -o dist/linux-x64/ -r linux-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true -p:TrimMode=partial --self-contained true /p:DebugType=None /p:IncludeNativeLibrariesForSelfExtract=true /p:VersionPrefix=$AssemblyVersion

if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
Expand All @@ -132,7 +132,7 @@ if ((Test-Path env:SKIP_MACOS) -And $env:SKIP_MACOS.ToUpper() -eq "TRUE") {
Write-Output "Skipping gei MacOS build because SKIP_MACOS is set"
}
else {
dotnet publish src/gei/gei.csproj -c Release -o dist/osx-x64/ -r osx-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true --self-contained true /p:DebugType=None /p:IncludeNativeLibrariesForSelfExtract=true /p:VersionPrefix=$AssemblyVersion
dotnet publish src/gei/gei.csproj -c Release -o dist/osx-x64/ -r osx-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true -p:TrimMode=partial --self-contained true /p:DebugType=None /p:IncludeNativeLibrariesForSelfExtract=true /p:VersionPrefix=$AssemblyVersion

if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
Expand All @@ -150,7 +150,7 @@ if ((Test-Path env:SKIP_WINDOWS) -And $env:SKIP_WINDOWS.ToUpper() -eq "TRUE") {
Write-Output "Skipping bbs2gh Windows build because SKIP_WINDOWS is set"
}
else {
dotnet publish src/bbs2gh/bbs2gh.csproj -c Release -o dist/win-x64/ -r win-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true --self-contained true /p:DebugType=None /p:IncludeNativeLibrariesForSelfExtract=true /p:VersionPrefix=$AssemblyVersion
dotnet publish src/bbs2gh/bbs2gh.csproj -c Release -o dist/win-x64/ -r win-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true -p:TrimMode=partial --self-contained true /p:DebugType=None /p:IncludeNativeLibrariesForSelfExtract=true /p:VersionPrefix=$AssemblyVersion

if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
Expand All @@ -162,7 +162,7 @@ else {

Rename-Item ./dist/win-x64/bbs2gh.exe bbs2gh-windows-amd64.exe

dotnet publish src/bbs2gh/bbs2gh.csproj -c Release -o dist/win-x86/ -r win-x86 -p:PublishSingleFile=true -p:PublishTrimmed=true --self-contained true /p:DebugType=None /p:IncludeNativeLibrariesForSelfExtract=true /p:VersionPrefix=$AssemblyVersion
dotnet publish src/bbs2gh/bbs2gh.csproj -c Release -o dist/win-x86/ -r win-x86 -p:PublishSingleFile=true -p:PublishTrimmed=true -p:TrimMode=partial --self-contained true /p:DebugType=None /p:IncludeNativeLibrariesForSelfExtract=true /p:VersionPrefix=$AssemblyVersion

if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
Expand All @@ -179,7 +179,7 @@ if ((Test-Path env:SKIP_LINUX) -And $env:SKIP_LINUX.ToUpper() -eq "TRUE") {
Write-Output "Skipping bbs2gh Linux build because SKIP_LINUX is set"
}
else {
dotnet publish src/bbs2gh/bbs2gh.csproj -c Release -o dist/linux-x64/ -r linux-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true --self-contained true /p:DebugType=None /p:IncludeNativeLibrariesForSelfExtract=true /p:VersionPrefix=$AssemblyVersion
dotnet publish src/bbs2gh/bbs2gh.csproj -c Release -o dist/linux-x64/ -r linux-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true -p:TrimMode=partial --self-contained true /p:DebugType=None /p:IncludeNativeLibrariesForSelfExtract=true /p:VersionPrefix=$AssemblyVersion

if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
Expand All @@ -196,7 +196,7 @@ if ((Test-Path env:SKIP_MACOS) -And $env:SKIP_MACOS.ToUpper() -eq "TRUE") {
Write-Output "Skipping bbs2gh MacOS build because SKIP_MACOS is set"
}
else {
dotnet publish src/bbs2gh/bbs2gh.csproj -c Release -o dist/osx-x64/ -r osx-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true --self-contained true /p:DebugType=None /p:IncludeNativeLibrariesForSelfExtract=true /p:VersionPrefix=$AssemblyVersion
dotnet publish src/bbs2gh/bbs2gh.csproj -c Release -o dist/osx-x64/ -r osx-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true -p:TrimMode=partial --self-contained true /p:DebugType=None /p:IncludeNativeLibrariesForSelfExtract=true /p:VersionPrefix=$AssemblyVersion

if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
Expand Down
3 changes: 2 additions & 1 deletion src/Octoshift/Octoshift.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>OctoshiftCLI</RootNamespace>
<LangVersion>12</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Octoshift/Services/CodeScanningAlertService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected internal virtual async Task MigrateAlerts(string sourceOrg, string sou

// no reason to call the target on a dry run - there will be no alerts
var targetAlerts = dryRun ?
new List<CodeScanningAlert>() :
[] :
(await _targetGithubApi.GetCodeScanningAlertsForRepository(targetOrg, targetRepo, branch)).ToList();

var successCount = 0;
Expand Down
8 changes: 4 additions & 4 deletions src/Octoshift/Services/OctoLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal static class LogLevel
public class OctoLogger
{
public virtual bool Verbose { get; set; }
private readonly HashSet<string> _secrets = new();
private readonly HashSet<string> _secrets = [];
private readonly string _logFilePath;
private readonly string _verboseFilePath;
private readonly bool _debugMode;
Expand All @@ -31,11 +31,11 @@ public class OctoLogger

private const string GENERIC_ERROR_MESSAGE = "An unexpected error happened. Please see the logs for details.";

private readonly List<string> _redactionPatterns = new()
{
private readonly List<string> _redactionPatterns =
[
"\\b(?<=token=)(.+?)\\b",
"\\b(?<=X-Amz-Credential=)(.+?)\\b",
};
];

public OctoLogger()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<LangVersion>12</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="JunitXml.TestLogger" Version="3.0.134" />
<PackageReference Include="JunitXml.TestLogger" Version="4.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="Moq" Version="4.20.69" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand All @@ -26,4 +27,7 @@
<ProjectReference Include="..\Octoshift\Octoshift.csproj" />
</ItemGroup>

<ItemGroup>
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</Project>
4 changes: 4 additions & 0 deletions src/OctoshiftCLI.IntegrationTests/xunit.runner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
"showLiveOutput": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class AbortMigrationCommandBaseTests
private readonly Mock<ITargetGithubApiFactory> _mockGithubApiFactory = new();
private readonly Mock<OctoLogger> _mockOctoLogger = TestHelpers.CreateMock<OctoLogger>();
private readonly ServiceProvider _serviceProvider;
private readonly AbortMigrationCommandBase _command = new();
private readonly AbortMigrationCommandBase _command = [];

private const string REPO_MIGRATION_ID = "RM_MIGRATION_ID";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class CreateTeamCommandTests
private readonly Mock<OctoLogger> _mockOctoLogger = TestHelpers.CreateMock<OctoLogger>();

private readonly ServiceProvider _serviceProvider;
private readonly CreateTeamCommandBase _command = new();
private readonly CreateTeamCommandBase _command = [];

public CreateTeamCommandTests()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class CreateTeamCommandHandlerTests
private const string GITHUB_ORG = "FooOrg";
private const string TEAM_NAME = "foo-team";
private const string IDP_GROUP = "foo-group";
private readonly List<string> TEAM_MEMBERS = new() { "dylan", "dave" };
private readonly List<string> TEAM_MEMBERS = ["dylan", "dave"];
private const int IDP_GROUP_ID = 42;
private const string TEAM_SLUG = "foo-slug";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class GenerateMannequinCsvCommandBaseTests
private readonly Mock<OctoLogger> _mockOctoLogger = TestHelpers.CreateMock<OctoLogger>();
private readonly Mock<ITargetGithubApiFactory> _mockGithubApiFactory = new();
private readonly ServiceProvider _serviceProvider;
private readonly GenerateMannequinCsvCommandBase _command = new();
private readonly GenerateMannequinCsvCommandBase _command = [];
private const string GITHUB_ORG = "FooOrg";

public GenerateMannequinCsvCommandBaseTests()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class GrantMigratorRoleCommandBaseTests
private readonly Mock<OctoLogger> _mockOctoLogger = TestHelpers.CreateMock<OctoLogger>();

private readonly ServiceProvider _serviceProvider;
private readonly GrantMigratorRoleCommandBase _command = new();
private readonly GrantMigratorRoleCommandBase _command = [];

public GrantMigratorRoleCommandBaseTests()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ReclaimMannequinCommandBaseTests
private readonly Mock<ConfirmationService> _mockConfirmationService = TestHelpers.CreateMock<ConfirmationService>();
private readonly Mock<ITargetGithubApiFactory> _mockGithubApiFactory = new();
private readonly ServiceProvider _serviceProvider;
private readonly ReclaimMannequinCommandBase _command = new();
private readonly ReclaimMannequinCommandBase _command = [];

private const string GITHUB_ORG = "FooOrg";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class RevokeMigratorRoleCommandBaseTests
private readonly Mock<OctoLogger> _mockOctoLogger = TestHelpers.CreateMock<OctoLogger>();

private readonly ServiceProvider _serviceProvider;
private readonly RevokeMigratorRoleCommandBase _command = new();
private readonly RevokeMigratorRoleCommandBase _command = [];

public RevokeMigratorRoleCommandBaseTests()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class WaitForMigrationCommandBaseTests
private readonly Mock<OctoLogger> _mockOctoLogger = TestHelpers.CreateMock<OctoLogger>();
private readonly Mock<WarningsCountLogger> _mockWarningsCountLogger = TestHelpers.CreateMock<WarningsCountLogger>();
private readonly ServiceProvider _serviceProvider;
private readonly WaitForMigrationCommandBase _command = new();
private readonly WaitForMigrationCommandBase _command = [];

private const string REPO_MIGRATION_ID = "RM_MIGRATION_ID";
public WaitForMigrationCommandBaseTests()
Expand Down
11 changes: 5 additions & 6 deletions src/OctoshiftCLI.Tests/Octoshift/Services/GithubApiTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Net;
Expand Down Expand Up @@ -1995,20 +1994,20 @@ ... on User {
{
CreateAttributionInvitation = null
},
Errors = new Collection<ErrorData>{new ErrorData
Errors = [new ErrorData
{
Type = "UNPROCESSABLE",
Message = "Target must be a member of the octocat organization",
Path = new Collection<string> { "createAttributionInvitation" },
Locations = new Collection<Location> {
Path = ["createAttributionInvitation"],
Locations = [
new Location()
{
Line = 2,
Column = 14
}
}
}
]
}
]
};

_githubClientMock
Expand Down
Loading
Loading