mirror of
https://github.com/actions/runner.git
synced 2025-12-10 12:36:23 +00:00
Compare commits
3 Commits
v2.309.0
...
users/eric
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ecc737c6b | ||
|
|
ece9b6d04b | ||
|
|
7a18d3001d |
@@ -1,4 +1,5 @@
|
|||||||
using GitHub.DistributedTask.WebApi;
|
using GitHub.DistributedTask.Pipelines.ContextData;
|
||||||
|
using GitHub.DistributedTask.WebApi;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace GitHub.Runner.Common.Util
|
namespace GitHub.Runner.Common.Util
|
||||||
@@ -75,5 +76,29 @@ namespace GitHub.Runner.Common.Util
|
|||||||
throw new NotSupportedException(result.ToString());
|
throw new NotSupportedException(result.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static StringContextData ToContextData(this TaskResult result)
|
||||||
|
{
|
||||||
|
string str;
|
||||||
|
switch (result)
|
||||||
|
{
|
||||||
|
case TaskResult.Succeeded:
|
||||||
|
str = "success";
|
||||||
|
break;
|
||||||
|
case TaskResult.Failed:
|
||||||
|
str = "failure";
|
||||||
|
break;
|
||||||
|
case TaskResult.Canceled:
|
||||||
|
str = "cancelled";
|
||||||
|
break;
|
||||||
|
case TaskResult.Skipped:
|
||||||
|
str = "skipped";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new NotSupportedException($"Unexpected task result '{result}' when converting to context data");
|
||||||
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -342,6 +342,12 @@ namespace GitHub.Runner.Worker
|
|||||||
|
|
||||||
_logger.End();
|
_logger.End();
|
||||||
|
|
||||||
|
// update context
|
||||||
|
if (!string.IsNullOrEmpty(ContextName))
|
||||||
|
{
|
||||||
|
StepsContext.SetConclusion(ScopeName, ContextName, Result.Value.ToContextData());
|
||||||
|
}
|
||||||
|
|
||||||
return Result.Value;
|
return Result.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,13 +56,13 @@ namespace GitHub.Runner.Worker
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetResult(
|
public void SetConclusion(
|
||||||
string scopeName,
|
string scopeName,
|
||||||
string stepName,
|
string stepName,
|
||||||
string result)
|
StringContextData conclusion)
|
||||||
{
|
{
|
||||||
var step = GetStep(scopeName, stepName);
|
var step = GetStep(scopeName, stepName);
|
||||||
step["result"] = new StringContextData(result);
|
step["conclusion"] = conclusion;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DictionaryContextData GetStep(string scopeName, string stepName)
|
private DictionaryContextData GetStep(string scopeName, string stepName)
|
||||||
|
|||||||
@@ -202,5 +202,20 @@ namespace GitHub.Runner.Common.Tests.Util
|
|||||||
Assert.Equal(TaskResult.Skipped, merged);
|
Assert.Equal(TaskResult.Skipped, merged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
[Trait("Level", "L0")]
|
||||||
|
[Trait("Category", "Common")]
|
||||||
|
public void ToContextData()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
using (TestHostContext hc = new TestHostContext(this))
|
||||||
|
{
|
||||||
|
Assert.Equal("success", TaskResult.Succeeded.ToContextData().ToString());
|
||||||
|
Assert.Equal("failure", TaskResult.Failed.ToContextData().ToString());
|
||||||
|
Assert.Equal("cancelled", TaskResult.Canceled.ToContextData().ToString());
|
||||||
|
Assert.Equal("skipped", TaskResult.Skipped.ToContextData().ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user