-
Notifications
You must be signed in to change notification settings - Fork 1.3k
support background steps #4416
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
base: main
Are you sure you want to change the base?
support background steps #4416
Changes from all commits
b3cb470
1002fd1
f74e5c6
4d32df6
9937faf
3520669
ce32f15
000b3bd
2fbefec
804a893
5913ea5
15762cf
59bece8
4944e63
c787934
826a427
5ccf8d3
e7c7f88
d2b95ea
1736185
4f57f13
428f25d
c54a06e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| using System; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace GitHub.Runner.Worker | ||
| { | ||
| /// <summary> | ||
| /// Tracks a background step's execution state. | ||
| /// </summary> | ||
| internal sealed class BackgroundStepContext | ||
| { | ||
| public string StepId { get; } | ||
| public IStep Step { get; } | ||
| public Task ExecutionTask { get; set; } | ||
| public CancellationTokenSource Cts { get; set; } | ||
| public GitHub.DistributedTask.WebApi.TaskResult? Result { get; set; } | ||
| public bool IsCompleted => ExecutionTask?.IsCompleted ?? false; | ||
| public string ExternalId => Step.ExecutionContext.Id.ToString("N"); | ||
|
|
||
| public BackgroundStepContext(string stepId, IStep step) | ||
| { | ||
| StepId = stepId; | ||
| Step = step; | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| using System; | ||
|
|
||
| namespace GitHub.Runner.Worker | ||
| { | ||
| public enum ControlFlowType | ||
| { | ||
| Wait, | ||
| WaitAll, | ||
| Cancel, | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Data for control-flow steps (wait, wait-all, cancel). | ||
| /// Used with JobExtensionRunner instead of dedicated IStep implementations. | ||
| /// </summary> | ||
| public sealed class ControlFlowStepData | ||
| { | ||
| public ControlFlowType Type { get; set; } | ||
| public Guid StepId { get; set; } | ||
| public string StepName { get; set; } | ||
|
|
||
| // Wait: IDs of background steps to wait for | ||
| public string[] WaitStepIds { get; set; } | ||
|
|
||
| // Cancel: IDs of background steps to cancel | ||
| public string[] CancelStepIds { get; set; } | ||
|
|
||
| // Parallel group ID for grouping steps in the UI | ||
| public string ParallelGroupId { get; set; } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,9 @@ namespace GitHub.Runner.Worker | |
| { | ||
| public sealed class GlobalContext | ||
| { | ||
| // Lock for thread-safe access to shared collections during concurrent background step execution | ||
| public readonly object CollectionLock = new object(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of using lock, should we change everything to be thread-safe, ex: using concurrecnybag/dictionary/queue, etc.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, I looked into this. The main challenge is that List uses .AddRange() in a couple of places and there's no ConcurrentHashSet in .NET, so swapping types ends up touching ~20 call sites across 8 files. Feels too invasive for this PR, happy to do it as a follow-up.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can front load the change in its own PR, and change all the consumers. |
||
|
|
||
| public ContainerInfo Container { get; set; } | ||
| public List<ServiceEndpoint> Endpoints { get; set; } | ||
| public IDictionary<String, String> EnvironmentVariables { get; set; } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.