Skip to content

Commit

Permalink
Merge pull request #1313 from github/improve-int-test-outputs
Browse files Browse the repository at this point in the history
Improve integration test console output
  • Loading branch information
ArinGhazarian authored Dec 10, 2024
2 parents 8175b52 + d00db0d commit 8beedac
Show file tree
Hide file tree
Showing 7 changed files with 489 additions and 824 deletions.
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/net8.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/net8.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
1,239 changes: 455 additions & 784 deletions ThirdPartyNotices.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CliWrap" Version="3.6.7" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="JunitXml.TestLogger" Version="3.0.134" />
<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 @@ -27,4 +28,10 @@
<ProjectReference Include="..\Octoshift\Octoshift.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
51 changes: 17 additions & 34 deletions src/OctoshiftCLI.IntegrationTests/TestHelper.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Azure.Storage.Blobs;
using CliWrap;
using FluentAssertions;
using Newtonsoft.Json.Linq;
using OctoshiftCLI.Services;
Expand Down Expand Up @@ -526,7 +526,7 @@ public static string GetOsName()
: throw new InvalidOperationException("Could not determine OS");
}

public async Task RunCliMigration(string generateScriptCommand, string cliName, IDictionary<string, string> tokens)
public async Task RunCliMigration(string generateScriptCommand, string cliName, IReadOnlyDictionary<string, string> tokens)
{
await RunCliCommand(generateScriptCommand, cliName, tokens);
LogMigrationScript("migrate.ps1");
Expand All @@ -541,51 +541,34 @@ private void LogMigrationScript(string filename)
_output.WriteLine(scriptContents);
}

public async Task RunPowershellScript(string script, IDictionary<string, string> tokens) =>
public async Task RunPowershellScript(string script, IReadOnlyDictionary<string, string> tokens) =>
await RunShellCommand($"-File {Path.Join(GetOsDistPath(), script)}", "pwsh", GetOsDistPath(), tokens);

public async Task RunCliCommand(string command, string cliName, IDictionary<string, string> tokens) =>
public async Task RunCliCommand(string command, string cliName, IReadOnlyDictionary<string, string> tokens) =>
await RunShellCommand(command, cliName, GetOsDistPath(), tokens);

private async Task RunShellCommand(string command, string fileName, string workingDirectory = null, IDictionary<string, string> environmentVariables = null)
private async Task RunShellCommand(string command, string fileName, string workingDirectory = null, IReadOnlyDictionary<string, string> environmentVariables = null)
{
var startInfo = new ProcessStartInfo
{
WorkingDirectory = workingDirectory ?? Directory.GetCurrentDirectory(),
FileName = fileName,
Arguments = command
};

if (environmentVariables != null)
{
foreach (var token in environmentVariables)
{
if (startInfo.EnvironmentVariables.ContainsKey(token.Key))
{
startInfo.EnvironmentVariables[token.Key] = token.Value;
}
else
{
startInfo.EnvironmentVariables.Add(token.Key, token.Value);
}
}
}

_output.WriteLine($"Running command: {startInfo.FileName} {startInfo.Arguments}");
_output.WriteLine($"Running command: {fileName} {command}");

var p = Process.Start(startInfo);
await p.WaitForExitAsync();
var result = await Cli.Wrap(fileName)
.WithArguments(command)
.WithWorkingDirectory(workingDirectory ?? Directory.GetCurrentDirectory())
.WithEnvironmentVariables(environmentVariables ?? new Dictionary<string, string>())
.WithStandardOutputPipe(PipeTarget.ToDelegate(line => _output.WriteLine(line)))
.WithStandardErrorPipe(PipeTarget.ToDelegate(line => _output.WriteLine(line)))
.ExecuteAsync();

p.ExitCode.Should().Be(0, $"{fileName} should return an exit code of 0.");
result.ExitCode.Should().Be(0, $"{fileName} should return an exit code of 0.");
}

public async Task RunAdoToGithubCliMigration(string generateScriptCommand, IDictionary<string, string> tokens) =>
public async Task RunAdoToGithubCliMigration(string generateScriptCommand, IReadOnlyDictionary<string, string> tokens) =>
await RunCliMigration($"ado2gh {generateScriptCommand}", "gh", tokens);

public async Task RunGeiCliMigration(string generateScriptCommand, IDictionary<string, string> tokens) =>
public async Task RunGeiCliMigration(string generateScriptCommand, IReadOnlyDictionary<string, string> tokens) =>
await RunCliMigration($"gei {generateScriptCommand}", "gh", tokens);

public async Task RunBbsCliMigration(string generateScriptCommand, IDictionary<string, string> tokens) =>
public async Task RunBbsCliMigration(string generateScriptCommand, IReadOnlyDictionary<string, string> tokens) =>
await RunCliMigration($"bbs2gh {generateScriptCommand}", "gh", tokens);

public static string GetOsDistPath()
Expand Down
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
}
4 changes: 2 additions & 2 deletions src/OctoshiftCLI.Tests/OctoshiftCLI.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />

<PackageReference Include="System.CommandLine.NamingConventionBinder" Version="2.0.0-beta4.22272.1" />
<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 Down

0 comments on commit 8beedac

Please sign in to comment.