steps are actually replayable!

This commit is contained in:
Francesco Renzi
2026-01-16 01:57:06 +00:00
committed by GitHub
parent b4d39971ed
commit e215a33c45
2 changed files with 28 additions and 1 deletions

View File

@@ -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.

View File

@@ -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);
}