mirror of
https://github.com/actions/runner.git
synced 2025-12-11 04:46:58 +00:00
Compare commits
2 Commits
v2.306.0
...
users/cory
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3647a1563a | ||
|
|
f25c9dfba3 |
@@ -1 +1 @@
|
||||
2.306.0
|
||||
<Update to ./src/runnerversion when creating release>
|
||||
|
||||
@@ -78,6 +78,7 @@ namespace GitHub.Runner.Worker
|
||||
List<string> StepEnvironmentOverrides { get; }
|
||||
|
||||
ExecutionContext Root { get; }
|
||||
ExecutionContext Parent { get; }
|
||||
|
||||
// Initialize
|
||||
void InitializeJob(Pipelines.AgentJobRequestMessage message, CancellationToken token);
|
||||
@@ -264,6 +265,14 @@ namespace GitHub.Runner.Worker
|
||||
}
|
||||
}
|
||||
|
||||
public ExecutionContext Parent
|
||||
{
|
||||
get
|
||||
{
|
||||
return _parentExecutionContext;
|
||||
}
|
||||
}
|
||||
|
||||
public JobContext JobContext
|
||||
{
|
||||
get
|
||||
@@ -406,7 +415,7 @@ namespace GitHub.Runner.Worker
|
||||
|
||||
/// <summary>
|
||||
/// An embedded execution context shares the same record ID, record name, logger,
|
||||
/// and a linked cancellation token.
|
||||
/// but NOT the cancellation token (just like workflow steps contexts - they don't share a token)
|
||||
/// </summary>
|
||||
public IExecutionContext CreateEmbeddedChild(
|
||||
string scopeName,
|
||||
@@ -416,7 +425,7 @@ namespace GitHub.Runner.Worker
|
||||
Dictionary<string, string> intraActionState = null,
|
||||
string siblingScopeName = null)
|
||||
{
|
||||
return Root.CreateChild(_record.Id, _record.Name, _record.Id.ToString("N"), scopeName, contextName, stage, logger: _logger, isEmbedded: true, cancellationTokenSource: CancellationTokenSource.CreateLinkedTokenSource(_cancellationTokenSource.Token), intraActionState: intraActionState, embeddedId: embeddedId, siblingScopeName: siblingScopeName);
|
||||
return Root.CreateChild(_record.Id, _record.Name, _record.Id.ToString("N"), scopeName, contextName, stage, logger: _logger, isEmbedded: true, cancellationTokenSource: null, intraActionState: intraActionState, embeddedId: embeddedId, siblingScopeName: siblingScopeName);
|
||||
}
|
||||
|
||||
public void Start(string currentOperation = null)
|
||||
@@ -597,9 +606,33 @@ namespace GitHub.Runner.Worker
|
||||
if (timeout != null)
|
||||
{
|
||||
_cancellationTokenSource.CancelAfter(timeout.Value);
|
||||
m_timeoutStartedAt = DateTime.UtcNow;
|
||||
m_timeout = timeout.Value;
|
||||
}
|
||||
}
|
||||
|
||||
DateTime? m_timeoutStartedAt;
|
||||
TimeSpan? m_timeout;
|
||||
public TimeSpan? GetRemainingTimeout()
|
||||
{
|
||||
if (m_timeoutStartedAt != null && m_timeout != null)
|
||||
{
|
||||
var elapsedSinceTimeoutSet = DateTime.UtcNow - m_timeoutStartedAt.Value;
|
||||
var remainingTimeout = m_timeout.Value - elapsedSinceTimeoutSet;
|
||||
if (remainingTimeout.Ticks > 0)
|
||||
{
|
||||
return remainingTimeout;
|
||||
}
|
||||
else
|
||||
{
|
||||
// there was a timeout and it has expired
|
||||
return TimeSpan.Zero;
|
||||
}
|
||||
}
|
||||
// no timeout was ever set
|
||||
return null;
|
||||
}
|
||||
|
||||
public void Progress(int percentage, string currentOperation = null)
|
||||
{
|
||||
if (percentage > 100 || percentage < 0)
|
||||
|
||||
@@ -310,6 +310,7 @@ namespace GitHub.Runner.Worker.Handlers
|
||||
// Mark job as cancelled
|
||||
ExecutionContext.Root.Result = TaskResult.Canceled;
|
||||
ExecutionContext.Root.JobContext.Status = ExecutionContext.Root.Result?.ToActionResult();
|
||||
step.ExecutionContext.SetGitHubContext("action_status", (ExecutionContext.Root.Result?.ToActionResult() ?? ActionResult.Cancelled).ToString().ToLowerInvariant());
|
||||
|
||||
step.ExecutionContext.Debug($"Re-evaluate condition on job cancellation for step: '{step.DisplayName}'.");
|
||||
var conditionReTestTraceWriter = new ConditionTraceWriter(Trace, null); // host tracing only
|
||||
@@ -420,6 +421,8 @@ namespace GitHub.Runner.Worker.Handlers
|
||||
{
|
||||
Trace.Info($"Starting: {step.DisplayName}");
|
||||
step.ExecutionContext.Debug($"Starting: {step.DisplayName}");
|
||||
// composite steps inherit the timeout from the parent, set by https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepstimeout-minutes
|
||||
step.ExecutionContext.SetTimeout(step.ExecutionContext.Parent.GetRemainingTimeout());
|
||||
|
||||
await Common.Util.EncodingUtil.SetEncoding(HostContext, Trace, step.ExecutionContext.CancellationToken);
|
||||
|
||||
|
||||
@@ -238,6 +238,7 @@ namespace GitHub.Runner.Common.Tests.Worker
|
||||
"MY_KEY_4<<EOF",
|
||||
"EOF EOF",
|
||||
"EOF",
|
||||
"MY_KEY_5=abc << def",
|
||||
};
|
||||
TestUtil.WriteContent(stateFile, content);
|
||||
_fileCmdExtension.ProcessCommand(_executionContext.Object, stateFile, null);
|
||||
@@ -247,6 +248,7 @@ namespace GitHub.Runner.Common.Tests.Worker
|
||||
Assert.Equal($"hello=two", _store["MY_KEY_2"]);
|
||||
Assert.Equal($" EOF", _store["MY_KEY_3"]);
|
||||
Assert.Equal($"EOF EOF", _store["MY_KEY_4"]);
|
||||
Assert.Equal($"abc << def", _store["MY_KEY_5"]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user