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

Use helix reporting #7383

Merged
merged 18 commits into from
Jul 1, 2021
Merged
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,9 @@ node_modules/
# Python Compile Outputs

*.pyc

# IntelliJ
.idea/

# vscode python env files
.env
5 changes: 5 additions & 0 deletions eng/test-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"version": 1,
"defaultOnFailure": "rerun",
"localRerunCount": 1
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System;
using System.IO;
using Xunit;
using System.Net;
using Newtonsoft.Json;

namespace Microsoft.DotNet.Helix.Sdk.Tests
{
Expand Down Expand Up @@ -35,5 +38,18 @@ public void VerifyNonEncodedFowardSlashIsConverted()

Assert.Equal(workItemNameExpected, actual);
}

[Fact]
public void FailOnceThenPass()
{
var target = Path.Combine(Path.GetTempPath(), "my-test-file-123456.snt");
bool exists = File.Exists(target);
if (!exists)
{
File.WriteAllText(target, "Test failed once");
}

Assert.True(exists, $"File should exist: {target}");
}
}
}
35 changes: 31 additions & 4 deletions src/Microsoft.DotNet.Helix/Sdk/SendHelixJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Threading;
Expand Down Expand Up @@ -33,6 +34,7 @@ public static class MetadataNames
public const string Uri = "Uri";
public const string Destination = "Destination";
public const string IncludeDirectoryName = "IncludeDirectoryName";
public const string AsArchive = "AsArchive";
}

/// <summary>
Expand Down Expand Up @@ -521,16 +523,41 @@ private IJobDefinition AddCorrelationPayload(IJobDefinition def, ITaskItem corre
if (Directory.Exists(path))
{
string includeDirectoryNameStr = correlationPayload.GetMetadata(MetadataNames.IncludeDirectoryName);
bool.TryParse(includeDirectoryNameStr, out bool includeDirectoryName);
if (!bool.TryParse(includeDirectoryNameStr, out bool includeDirectoryName))
{
includeDirectoryName = false;
}

Log.LogMessage(MessageImportance.Low, $"Adding Correlation Payload Directory '{path}', destination '{destination}'");
Log.LogMessage(
MessageImportance.Low,
$"Adding Correlation Payload Directory '{path}', destination '{destination}'"
);
return def.WithCorrelationPayloadDirectory(path, includeDirectoryName, destination);

}

if (File.Exists(path))
{
Log.LogMessage(MessageImportance.Low, $"Adding Correlation Payload Archive '{path}', destination '{destination}'");
return def.WithCorrelationPayloadArchive(path, destination);
string asArchiveStr = correlationPayload.GetMetadata(MetadataNames.AsArchive);
if (!bool.TryParse(asArchiveStr, out bool asArchive))
{
asArchive = false;
}

if (asArchive)
{
Log.LogMessage(
MessageImportance.Low,
$"Adding Correlation Payload Archive '{path}', destination '{destination}'"
);
return def.WithCorrelationPayloadArchive(path, destination);
}

Log.LogMessage(
MessageImportance.Low,
$"Adding Correlation Payload File '{path}', destination '{destination}'"
);
return def.WithCorrelationPayloadFiles(path);
}

Log.LogError(FailureCategory.Build, $"Correlation Payload '{path}' not found.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
<PropertyGroup>
<EnableXUnitReporter Condition=" '$(EnableXUnitReporter)' != 'true' ">false</EnableXUnitReporter>
</PropertyGroup>


<PropertyGroup Condition=" '$(HelixTestConfigurationFilePath)' == '' ">
<HelixTestConfigurationFilePath Condition=" '$(RepositoryEngineeringDir)' != '' ">$(RepositoryEngineeringDir)/test-configuration.json</HelixTestConfigurationFilePath>
</PropertyGroup>

<Choose>
<When Condition="$(HelixTargetQueue.ToLowerInvariant().Contains('windows'))">
<PropertyGroup>
Expand Down Expand Up @@ -36,6 +40,10 @@
<HelixProperties Condition="'$(HelixArchitecture)' != ''" Include="architecture" Value="$(HelixArchitecture)" />
<HelixProperties Include="operatingSystem" Value="$(HelixTargetQueue)" />
</ItemGroup>

<ItemGroup Condition="Exists('$(HelixTestConfigurationFilePath)')">
<HelixCorrelationPayload Include="$(HelixTestConfigurationFilePath)" AsArchive="false" />
</ItemGroup>

<Target Name="CoreBuild">
</Target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<PropertyGroup>
<HelixPostCommands Condition="$(IsPosixShell)">
$(HelixPostCommands);
/bin/sh $HELIX_CORRELATION_PAYLOAD/reporter/run.sh $(SYSTEM_TEAMFOUNDATIONCOLLECTIONURI) $(SYSTEM_TEAMPROJECT) $(TestRunId) $(SYSTEM_ACCESSTOKEN) || exit $?
$HELIX_PYTHONPATH $HELIX_CORRELATION_PAYLOAD/reporter/run.py $(SYSTEM_TEAMFOUNDATIONCOLLECTIONURI) $(SYSTEM_TEAMPROJECT) $(TestRunId) $(SYSTEM_ACCESSTOKEN) || exit $?
</HelixPostCommands>
<HelixPostCommands Condition="!$(IsPosixShell)">
$(HelixPostCommands);
call %HELIX_CORRELATION_PAYLOAD%\reporter\run.bat $(SYSTEM_TEAMFOUNDATIONCOLLECTIONURI) $(SYSTEM_TEAMPROJECT) $(TestRunId) $(SYSTEM_ACCESSTOKEN) || exit /b
%HELIX_PYTHONPATH% %HELIX_CORRELATION_PAYLOAD%\reporter\run.py $(SYSTEM_TEAMFOUNDATIONCOLLECTIONURI) $(SYSTEM_TEAMPROJECT) $(TestRunId) $(SYSTEM_ACCESSTOKEN) || exit /b
</HelixPostCommands>
</PropertyGroup>

Expand Down
Loading