mirror of
https://github.com/actions/runner.git
synced 2026-01-17 09:12:08 +08:00
steps are actually replayable!
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
@@ -95,6 +95,7 @@ namespace GitHub.Runner.Worker
|
||||
// timeline record update methods
|
||||
void Start(string currentOperation = null);
|
||||
TaskResult Complete(TaskResult? result = null, string currentOperation = null, string resultCode = null);
|
||||
void ResetForRerun();
|
||||
void SetEnvContext(string name, string value);
|
||||
void SetRunnerContext(string name, string value);
|
||||
string GetGitHubContext(string name);
|
||||
@@ -545,6 +546,29 @@ namespace GitHub.Runner.Worker
|
||||
return Result.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the execution context for re-running (e.g., after step-back in DAP debugging).
|
||||
/// Creates a new CancellationTokenSource since the previous one was disposed in Complete().
|
||||
/// </summary>
|
||||
public void ResetForRerun()
|
||||
{
|
||||
// Create a new CancellationTokenSource since the old one was disposed
|
||||
_cancellationTokenSource = new CancellationTokenSource();
|
||||
|
||||
// Reset record state to allow re-execution
|
||||
_record.State = TimelineRecordState.Pending;
|
||||
_record.FinishTime = null;
|
||||
_record.PercentComplete = 0;
|
||||
_record.ResultCode = null;
|
||||
|
||||
// Reset result
|
||||
Result = null;
|
||||
Outcome = null;
|
||||
|
||||
// Reset the force completed task
|
||||
_forceCompleted = new TaskCompletionSource<int>();
|
||||
}
|
||||
|
||||
public void UpdateGlobalStepsContext()
|
||||
{
|
||||
// Skip if generated context name. Generated context names start with "__". After 3.2 the server will never send an empty context name.
|
||||
|
||||
@@ -222,9 +222,12 @@ namespace GitHub.Runner.Worker
|
||||
}
|
||||
|
||||
// Queue the checkpoint's step and remaining steps
|
||||
// Reset execution context for rerun since CancellationTokenSource was disposed in Complete()
|
||||
checkpoint.CurrentStep.ExecutionContext.ResetForRerun();
|
||||
jobContext.JobSteps.Enqueue(checkpoint.CurrentStep);
|
||||
foreach (var remainingStep in checkpoint.RemainingSteps)
|
||||
{
|
||||
remainingStep.ExecutionContext.ResetForRerun();
|
||||
jobContext.JobSteps.Enqueue(remainingStep);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user