mirror of
https://github.com/actions/runner.git
synced 2025-12-11 04:46:58 +00:00
Compare commits
1 Commits
v2.160.2
...
users/eric
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8770849c3b |
@@ -2,10 +2,11 @@
|
|||||||
- N/A
|
- N/A
|
||||||
|
|
||||||
## Bugs
|
## Bugs
|
||||||
- Fixed an issue with Strong Name Validation when running as a service on Windows (#185)
|
- Reverted removal of additional fields error and warning fields (#147)
|
||||||
|
- Actions cache would incorrectly cache the action if the tag was updated (#148)
|
||||||
|
|
||||||
## Misc
|
## Misc
|
||||||
- N/A
|
- Updated to .NET Core 3.0 (#127)
|
||||||
|
|
||||||
## Agent Downloads
|
## Agent Downloads
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ namespace GitHub.Runner.Common
|
|||||||
// Action command extensions.
|
// Action command extensions.
|
||||||
case "GitHub.Runner.Worker.IActionCommandExtension":
|
case "GitHub.Runner.Worker.IActionCommandExtension":
|
||||||
Add<T>(extensions, "GitHub.Runner.Worker.InternalPluginSetRepoPathCommandExtension, Runner.Worker");
|
Add<T>(extensions, "GitHub.Runner.Worker.InternalPluginSetRepoPathCommandExtension, Runner.Worker");
|
||||||
|
Add<T>(extensions, "GitHub.Runner.Worker.SetWorkspaceCommandExtension, Runner.Worker");
|
||||||
Add<T>(extensions, "GitHub.Runner.Worker.SetEnvCommandExtension, Runner.Worker");
|
Add<T>(extensions, "GitHub.Runner.Worker.SetEnvCommandExtension, Runner.Worker");
|
||||||
Add<T>(extensions, "GitHub.Runner.Worker.SetOutputCommandExtension, Runner.Worker");
|
Add<T>(extensions, "GitHub.Runner.Worker.SetOutputCommandExtension, Runner.Worker");
|
||||||
Add<T>(extensions, "GitHub.Runner.Worker.SaveStateCommandExtension, Runner.Worker");
|
Add<T>(extensions, "GitHub.Runner.Worker.SaveStateCommandExtension, Runner.Worker");
|
||||||
|
|||||||
BIN
src/Runner.Service/Windows/FinalPublicKey.snk
Normal file
BIN
src/Runner.Service/Windows/FinalPublicKey.snk
Normal file
Binary file not shown.
@@ -9,8 +9,9 @@
|
|||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>RunnerService</RootNamespace>
|
<RootNamespace>RunnerService</RootNamespace>
|
||||||
<AssemblyName>RunnerService</AssemblyName>
|
<AssemblyName>RunnerService</AssemblyName>
|
||||||
<SignAssembly>false</SignAssembly>
|
<SignAssembly>true</SignAssembly>
|
||||||
<DelaySign>false</DelaySign>
|
<AssemblyOriginatorKeyFile>FinalPublicKey.snk</AssemblyOriginatorKeyFile>
|
||||||
|
<DelaySign>true</DelaySign>
|
||||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
@@ -63,6 +64,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
|
<None Include="FinalPublicKey.snk" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="Resource.resx">
|
<EmbeddedResource Include="Resource.resx">
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ namespace GitHub.Runner.Worker
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// process action command in serialize order.
|
// process action command in serialize oreder.
|
||||||
lock (_commandSerializeLock)
|
lock (_commandSerializeLock)
|
||||||
{
|
{
|
||||||
if (_stopProcessCommand)
|
if (_stopProcessCommand)
|
||||||
@@ -107,19 +107,32 @@ namespace GitHub.Runner.Worker
|
|||||||
}
|
}
|
||||||
else if (_commandExtensions.TryGetValue(actionCommand.Command, out IActionCommandExtension extension))
|
else if (_commandExtensions.TryGetValue(actionCommand.Command, out IActionCommandExtension extension))
|
||||||
{
|
{
|
||||||
if (context.EchoOnActionCommand && !extension.OmitEcho)
|
bool commandHasBeenOutput = false;
|
||||||
{
|
|
||||||
context.Output(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (context.EchoOnActionCommand)
|
||||||
|
{
|
||||||
|
context.Output(input);
|
||||||
|
context.Debug($"Processing command '{actionCommand.Command}'");
|
||||||
|
commandHasBeenOutput = true;
|
||||||
|
}
|
||||||
|
|
||||||
extension.ProcessCommand(context, input, actionCommand);
|
extension.ProcessCommand(context, input, actionCommand);
|
||||||
|
|
||||||
|
if (context.EchoOnActionCommand)
|
||||||
|
{
|
||||||
|
context.Debug($"Processed command '{actionCommand.Command}' successfully");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
var commandInformation = extension.OmitEcho ? extension.Command : input;
|
if (!commandHasBeenOutput)
|
||||||
context.Error($"Unable to process command '{commandInformation}' successfully.");
|
{
|
||||||
|
context.Output(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
context.Error($"Unable to process command '{input}' successfully.");
|
||||||
context.Error(ex);
|
context.Error(ex);
|
||||||
context.CommandResult = TaskResult.Failed;
|
context.CommandResult = TaskResult.Failed;
|
||||||
}
|
}
|
||||||
@@ -138,7 +151,6 @@ namespace GitHub.Runner.Worker
|
|||||||
public interface IActionCommandExtension : IExtension
|
public interface IActionCommandExtension : IExtension
|
||||||
{
|
{
|
||||||
string Command { get; }
|
string Command { get; }
|
||||||
bool OmitEcho { get; }
|
|
||||||
|
|
||||||
void ProcessCommand(IExecutionContext context, string line, ActionCommand command);
|
void ProcessCommand(IExecutionContext context, string line, ActionCommand command);
|
||||||
}
|
}
|
||||||
@@ -146,7 +158,6 @@ namespace GitHub.Runner.Worker
|
|||||||
public sealed class InternalPluginSetRepoPathCommandExtension : RunnerService, IActionCommandExtension
|
public sealed class InternalPluginSetRepoPathCommandExtension : RunnerService, IActionCommandExtension
|
||||||
{
|
{
|
||||||
public string Command => "internal-set-repo-path";
|
public string Command => "internal-set-repo-path";
|
||||||
public bool OmitEcho => false;
|
|
||||||
|
|
||||||
public Type ExtensionType => typeof(IActionCommandExtension);
|
public Type ExtensionType => typeof(IActionCommandExtension);
|
||||||
|
|
||||||
@@ -173,10 +184,43 @@ namespace GitHub.Runner.Worker
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public sealed class SetWorkspaceCommandExtension : RunnerService, IActionCommandExtension
|
||||||
|
{
|
||||||
|
public string Command => "set-workspace";
|
||||||
|
|
||||||
|
public Type ExtensionType => typeof(IActionCommandExtension);
|
||||||
|
|
||||||
|
public void ProcessCommand(IExecutionContext context, string line, ActionCommand command)
|
||||||
|
{
|
||||||
|
string path = command.Data;
|
||||||
|
if (string.IsNullOrWhiteSpace(path))
|
||||||
|
{
|
||||||
|
throw new Exception("Path not specified");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Path.IsPathRooted(path))
|
||||||
|
{
|
||||||
|
throw new Exception("Expected a rooted path");
|
||||||
|
}
|
||||||
|
|
||||||
|
string runnerWorkspace = context.GetRunnerContext("workspace");
|
||||||
|
ArgUtil.Directory(runnerWorkspace, nameof(runnerWorkspace));
|
||||||
|
|
||||||
|
// Must be under runner workspace
|
||||||
|
path = Path.GetFullPath(path); // remove relative pathing and normalize slashes
|
||||||
|
if (!path.StartsWith(runnerWorkspace + Path.DirectorySeparatorChar, IOUtil.FilePathStringComparison))
|
||||||
|
{
|
||||||
|
throw new Exception($"Expected path to be under {runnerWorkspace}");
|
||||||
|
}
|
||||||
|
|
||||||
|
Trace.Info($"Setting GitHub workspace to '{path}'");
|
||||||
|
context.SetGitHubContext("workspace", path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public sealed class SetEnvCommandExtension : RunnerService, IActionCommandExtension
|
public sealed class SetEnvCommandExtension : RunnerService, IActionCommandExtension
|
||||||
{
|
{
|
||||||
public string Command => "set-env";
|
public string Command => "set-env";
|
||||||
public bool OmitEcho => false;
|
|
||||||
|
|
||||||
public Type ExtensionType => typeof(IActionCommandExtension);
|
public Type ExtensionType => typeof(IActionCommandExtension);
|
||||||
|
|
||||||
@@ -201,7 +245,6 @@ namespace GitHub.Runner.Worker
|
|||||||
public sealed class SetOutputCommandExtension : RunnerService, IActionCommandExtension
|
public sealed class SetOutputCommandExtension : RunnerService, IActionCommandExtension
|
||||||
{
|
{
|
||||||
public string Command => "set-output";
|
public string Command => "set-output";
|
||||||
public bool OmitEcho => false;
|
|
||||||
|
|
||||||
public Type ExtensionType => typeof(IActionCommandExtension);
|
public Type ExtensionType => typeof(IActionCommandExtension);
|
||||||
|
|
||||||
@@ -225,7 +268,6 @@ namespace GitHub.Runner.Worker
|
|||||||
public sealed class SaveStateCommandExtension : RunnerService, IActionCommandExtension
|
public sealed class SaveStateCommandExtension : RunnerService, IActionCommandExtension
|
||||||
{
|
{
|
||||||
public string Command => "save-state";
|
public string Command => "save-state";
|
||||||
public bool OmitEcho => false;
|
|
||||||
|
|
||||||
public Type ExtensionType => typeof(IActionCommandExtension);
|
public Type ExtensionType => typeof(IActionCommandExtension);
|
||||||
|
|
||||||
@@ -249,7 +291,6 @@ namespace GitHub.Runner.Worker
|
|||||||
public sealed class AddMaskCommandExtension : RunnerService, IActionCommandExtension
|
public sealed class AddMaskCommandExtension : RunnerService, IActionCommandExtension
|
||||||
{
|
{
|
||||||
public string Command => "add-mask";
|
public string Command => "add-mask";
|
||||||
public bool OmitEcho => true;
|
|
||||||
|
|
||||||
public Type ExtensionType => typeof(IActionCommandExtension);
|
public Type ExtensionType => typeof(IActionCommandExtension);
|
||||||
|
|
||||||
@@ -261,11 +302,6 @@ namespace GitHub.Runner.Worker
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (context.EchoOnActionCommand)
|
|
||||||
{
|
|
||||||
context.Output($"::{Command}::***");
|
|
||||||
}
|
|
||||||
|
|
||||||
HostContext.SecretMasker.AddValue(command.Data);
|
HostContext.SecretMasker.AddValue(command.Data);
|
||||||
Trace.Info($"Add new secret mask with length of {command.Data.Length}");
|
Trace.Info($"Add new secret mask with length of {command.Data.Length}");
|
||||||
}
|
}
|
||||||
@@ -275,7 +311,6 @@ namespace GitHub.Runner.Worker
|
|||||||
public sealed class AddPathCommandExtension : RunnerService, IActionCommandExtension
|
public sealed class AddPathCommandExtension : RunnerService, IActionCommandExtension
|
||||||
{
|
{
|
||||||
public string Command => "add-path";
|
public string Command => "add-path";
|
||||||
public bool OmitEcho => false;
|
|
||||||
|
|
||||||
public Type ExtensionType => typeof(IActionCommandExtension);
|
public Type ExtensionType => typeof(IActionCommandExtension);
|
||||||
|
|
||||||
@@ -290,7 +325,6 @@ namespace GitHub.Runner.Worker
|
|||||||
public sealed class AddMatcherCommandExtension : RunnerService, IActionCommandExtension
|
public sealed class AddMatcherCommandExtension : RunnerService, IActionCommandExtension
|
||||||
{
|
{
|
||||||
public string Command => "add-matcher";
|
public string Command => "add-matcher";
|
||||||
public bool OmitEcho => false;
|
|
||||||
|
|
||||||
public Type ExtensionType => typeof(IActionCommandExtension);
|
public Type ExtensionType => typeof(IActionCommandExtension);
|
||||||
|
|
||||||
@@ -337,7 +371,6 @@ namespace GitHub.Runner.Worker
|
|||||||
public sealed class RemoveMatcherCommandExtension : RunnerService, IActionCommandExtension
|
public sealed class RemoveMatcherCommandExtension : RunnerService, IActionCommandExtension
|
||||||
{
|
{
|
||||||
public string Command => "remove-matcher";
|
public string Command => "remove-matcher";
|
||||||
public bool OmitEcho => false;
|
|
||||||
|
|
||||||
public Type ExtensionType => typeof(IActionCommandExtension);
|
public Type ExtensionType => typeof(IActionCommandExtension);
|
||||||
|
|
||||||
@@ -405,7 +438,6 @@ namespace GitHub.Runner.Worker
|
|||||||
public sealed class DebugCommandExtension : RunnerService, IActionCommandExtension
|
public sealed class DebugCommandExtension : RunnerService, IActionCommandExtension
|
||||||
{
|
{
|
||||||
public string Command => "debug";
|
public string Command => "debug";
|
||||||
public bool OmitEcho => true;
|
|
||||||
|
|
||||||
public Type ExtensionType => typeof(IActionCommandExtension);
|
public Type ExtensionType => typeof(IActionCommandExtension);
|
||||||
|
|
||||||
@@ -433,7 +465,6 @@ namespace GitHub.Runner.Worker
|
|||||||
{
|
{
|
||||||
public abstract IssueType Type { get; }
|
public abstract IssueType Type { get; }
|
||||||
public abstract string Command { get; }
|
public abstract string Command { get; }
|
||||||
public bool OmitEcho => true;
|
|
||||||
|
|
||||||
public Type ExtensionType => typeof(IActionCommandExtension);
|
public Type ExtensionType => typeof(IActionCommandExtension);
|
||||||
|
|
||||||
@@ -513,8 +544,6 @@ namespace GitHub.Runner.Worker
|
|||||||
public abstract class GroupingCommandExtension : RunnerService, IActionCommandExtension
|
public abstract class GroupingCommandExtension : RunnerService, IActionCommandExtension
|
||||||
{
|
{
|
||||||
public abstract string Command { get; }
|
public abstract string Command { get; }
|
||||||
public bool OmitEcho => false;
|
|
||||||
|
|
||||||
public Type ExtensionType => typeof(IActionCommandExtension);
|
public Type ExtensionType => typeof(IActionCommandExtension);
|
||||||
|
|
||||||
public void ProcessCommand(IExecutionContext context, string line, ActionCommand command)
|
public void ProcessCommand(IExecutionContext context, string line, ActionCommand command)
|
||||||
@@ -527,7 +556,6 @@ namespace GitHub.Runner.Worker
|
|||||||
public sealed class EchoCommandExtension : RunnerService, IActionCommandExtension
|
public sealed class EchoCommandExtension : RunnerService, IActionCommandExtension
|
||||||
{
|
{
|
||||||
public string Command => "echo";
|
public string Command => "echo";
|
||||||
public bool OmitEcho => false;
|
|
||||||
|
|
||||||
public Type ExtensionType => typeof(IActionCommandExtension);
|
public Type ExtensionType => typeof(IActionCommandExtension);
|
||||||
|
|
||||||
|
|||||||
@@ -94,21 +94,7 @@ namespace GitHub.Runner.Worker
|
|||||||
{
|
{
|
||||||
postDisplayName = $"Post {this.DisplayName}";
|
postDisplayName = $"Post {this.DisplayName}";
|
||||||
}
|
}
|
||||||
|
ExecutionContext.RegisterPostJobAction(postDisplayName, handlerData.CleanupCondition, Action);
|
||||||
var repositoryReference = Action.Reference as RepositoryPathReference;
|
|
||||||
var pathString = string.IsNullOrEmpty(repositoryReference.Path) ? string.Empty : $"/{repositoryReference.Path}";
|
|
||||||
var repoString = string.IsNullOrEmpty(repositoryReference.Ref) ? $"{repositoryReference.Name}{pathString}" :
|
|
||||||
$"{repositoryReference.Name}{pathString}@{repositoryReference.Ref}";
|
|
||||||
|
|
||||||
ExecutionContext.Debug($"Register post job cleanup for action: {repoString}");
|
|
||||||
|
|
||||||
var actionRunner = HostContext.CreateService<IActionRunner>();
|
|
||||||
actionRunner.Action = Action;
|
|
||||||
actionRunner.Stage = ActionRunStage.Post;
|
|
||||||
actionRunner.Condition = handlerData.CleanupCondition;
|
|
||||||
actionRunner.DisplayName = postDisplayName;
|
|
||||||
|
|
||||||
ExecutionContext.RegisterPostJobStep($"{actionRunner.Action.Name}_post", actionRunner);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IStepHost stepHost = HostContext.CreateService<IDefaultStepHost>();
|
IStepHost stepHost = HostContext.CreateService<IDefaultStepHost>();
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ using GitHub.Runner.Common;
|
|||||||
using GitHub.Runner.Sdk;
|
using GitHub.Runner.Sdk;
|
||||||
using GitHub.DistributedTask.Pipelines.ContextData;
|
using GitHub.DistributedTask.Pipelines.ContextData;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using GitHub.DistributedTask.Pipelines.ObjectTemplating;
|
|
||||||
|
|
||||||
namespace GitHub.Runner.Worker
|
namespace GitHub.Runner.Worker
|
||||||
{
|
{
|
||||||
@@ -39,14 +38,6 @@ namespace GitHub.Runner.Worker
|
|||||||
List<ContainerInfo> containers = data as List<ContainerInfo>;
|
List<ContainerInfo> containers = data as List<ContainerInfo>;
|
||||||
ArgUtil.NotNull(containers, nameof(containers));
|
ArgUtil.NotNull(containers, nameof(containers));
|
||||||
|
|
||||||
var postJobStep = new JobExtensionRunner(runAsync: this.StopContainersAsync,
|
|
||||||
condition: $"{PipelineTemplateConstants.Always}()",
|
|
||||||
displayName: "Stop containers",
|
|
||||||
data: data);
|
|
||||||
|
|
||||||
executionContext.Debug($"Register post job cleanup for stoping/deleting containers.");
|
|
||||||
executionContext.RegisterPostJobStep(nameof(StopContainersAsync), postJobStep);
|
|
||||||
|
|
||||||
// Check whether we are inside a container.
|
// Check whether we are inside a container.
|
||||||
// Our container feature requires to map working directory from host to the container.
|
// Our container feature requires to map working directory from host to the container.
|
||||||
// If we are already inside a container, we will not able to find out the real working direcotry path on the host.
|
// If we are already inside a container, we will not able to find out the real working direcotry path on the host.
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ namespace GitHub.Runner.Worker
|
|||||||
void Start(string currentOperation = null);
|
void Start(string currentOperation = null);
|
||||||
TaskResult Complete(TaskResult? result = null, string currentOperation = null, string resultCode = null);
|
TaskResult Complete(TaskResult? result = null, string currentOperation = null, string resultCode = null);
|
||||||
void SetEnvContext(string name, string value);
|
void SetEnvContext(string name, string value);
|
||||||
|
string GetRunnerContext(string name);
|
||||||
void SetRunnerContext(string name, string value);
|
void SetRunnerContext(string name, string value);
|
||||||
string GetGitHubContext(string name);
|
string GetGitHubContext(string name);
|
||||||
void SetGitHubContext(string name, string value);
|
void SetGitHubContext(string name, string value);
|
||||||
@@ -98,7 +99,7 @@ namespace GitHub.Runner.Worker
|
|||||||
|
|
||||||
// others
|
// others
|
||||||
void ForceTaskComplete();
|
void ForceTaskComplete();
|
||||||
void RegisterPostJobStep(string refName, IStep step);
|
void RegisterPostJobAction(string displayName, string condition, Pipelines.ActionStep action);
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class ExecutionContext : RunnerService, IExecutionContext
|
public sealed class ExecutionContext : RunnerService, IExecutionContext
|
||||||
@@ -240,10 +241,27 @@ namespace GitHub.Runner.Worker
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegisterPostJobStep(string refName, IStep step)
|
public void RegisterPostJobAction(string displayName, string condition, Pipelines.ActionStep action)
|
||||||
{
|
{
|
||||||
step.ExecutionContext = Root.CreatePostChild(step.DisplayName, refName, IntraActionState);
|
if (action.Reference.Type != ActionSourceType.Repository)
|
||||||
Root.PostJobSteps.Push(step);
|
{
|
||||||
|
throw new NotSupportedException("Only action that has `action.yml` can define post job execution.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var repositoryReference = action.Reference as RepositoryPathReference;
|
||||||
|
var pathString = string.IsNullOrEmpty(repositoryReference.Path) ? string.Empty : $"/{repositoryReference.Path}";
|
||||||
|
var repoString = string.IsNullOrEmpty(repositoryReference.Ref) ? $"{repositoryReference.Name}{pathString}" :
|
||||||
|
$"{repositoryReference.Name}{pathString}@{repositoryReference.Ref}";
|
||||||
|
|
||||||
|
this.Debug($"Register post job cleanup for action: {repoString}");
|
||||||
|
|
||||||
|
var actionRunner = HostContext.CreateService<IActionRunner>();
|
||||||
|
actionRunner.Action = action;
|
||||||
|
actionRunner.Stage = ActionRunStage.Post;
|
||||||
|
actionRunner.Condition = condition;
|
||||||
|
actionRunner.DisplayName = displayName;
|
||||||
|
actionRunner.ExecutionContext = Root.CreatePostChild(displayName, $"{actionRunner.Action.Name}_post", IntraActionState);
|
||||||
|
Root.PostJobSteps.Push(actionRunner);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IExecutionContext CreateChild(Guid recordId, string displayName, string refName, string scopeName, string contextName, Dictionary<string, string> intraActionState = null, int? recordOrder = null)
|
public IExecutionContext CreateChild(Guid recordId, string displayName, string refName, string scopeName, string contextName, Dictionary<string, string> intraActionState = null, int? recordOrder = null)
|
||||||
@@ -348,6 +366,13 @@ namespace GitHub.Runner.Worker
|
|||||||
return Result.Value;
|
return Result.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetRunnerContext(string name)
|
||||||
|
{
|
||||||
|
ArgUtil.NotNullOrEmpty(name, nameof(name));
|
||||||
|
var runnerContext = ExpressionValues["runner"] as RunnerContext;
|
||||||
|
return runnerContext[name].AssertString($"runner[{name}]");
|
||||||
|
}
|
||||||
|
|
||||||
public void SetRunnerContext(string name, string value)
|
public void SetRunnerContext(string name, string value)
|
||||||
{
|
{
|
||||||
ArgUtil.NotNullOrEmpty(name, nameof(name));
|
ArgUtil.NotNullOrEmpty(name, nameof(name));
|
||||||
|
|||||||
@@ -110,7 +110,9 @@ namespace GitHub.Runner.Worker
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build up 2 lists of steps, pre-job, job
|
// Build up 3 lists of steps, pre-job, job, post-job
|
||||||
|
var postJobStepsBuilder = new Stack<IStep>();
|
||||||
|
|
||||||
// Download actions not already in the cache
|
// Download actions not already in the cache
|
||||||
Trace.Info("Downloading actions");
|
Trace.Info("Downloading actions");
|
||||||
var actionManager = HostContext.GetService<IActionManager>();
|
var actionManager = HostContext.GetService<IActionManager>();
|
||||||
@@ -132,6 +134,10 @@ namespace GitHub.Runner.Worker
|
|||||||
condition: $"{PipelineTemplateConstants.Success}()",
|
condition: $"{PipelineTemplateConstants.Success}()",
|
||||||
displayName: "Initialize containers",
|
displayName: "Initialize containers",
|
||||||
data: (object)containers));
|
data: (object)containers));
|
||||||
|
postJobStepsBuilder.Push(new JobExtensionRunner(runAsync: containerProvider.StopContainersAsync,
|
||||||
|
condition: $"{PipelineTemplateConstants.Always}()",
|
||||||
|
displayName: "Stop containers",
|
||||||
|
data: (object)containers));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add action steps
|
// Add action steps
|
||||||
@@ -181,9 +187,33 @@ namespace GitHub.Runner.Worker
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add post-job steps
|
||||||
|
Trace.Info("Adding post-job steps");
|
||||||
|
while (postJobStepsBuilder.Count > 0)
|
||||||
|
{
|
||||||
|
postJobSteps.Add(postJobStepsBuilder.Pop());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create execution context for post-job steps
|
||||||
|
foreach (var step in postJobSteps)
|
||||||
|
{
|
||||||
|
if (step is JobExtensionRunner)
|
||||||
|
{
|
||||||
|
JobExtensionRunner extensionStep = step as JobExtensionRunner;
|
||||||
|
ArgUtil.NotNull(extensionStep, extensionStep.DisplayName);
|
||||||
|
Guid stepId = Guid.NewGuid();
|
||||||
|
extensionStep.ExecutionContext = jobContext.CreateChild(stepId, extensionStep.DisplayName, stepId.ToString("N"), null, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<IStep> steps = new List<IStep>();
|
List<IStep> steps = new List<IStep>();
|
||||||
steps.AddRange(preJobSteps);
|
steps.AddRange(preJobSteps);
|
||||||
steps.AddRange(jobSteps);
|
steps.AddRange(jobSteps);
|
||||||
|
steps.AddRange(postJobSteps);
|
||||||
|
|
||||||
|
// Start agent log plugin host process
|
||||||
|
// var logPlugin = HostContext.GetService<IAgentLogPlugin>();
|
||||||
|
// await logPlugin.StartAsync(context, steps, jobContext.CancellationToken);
|
||||||
|
|
||||||
// Prepare for orphan process cleanup
|
// Prepare for orphan process cleanup
|
||||||
_processCleanup = jobContext.Variables.GetBoolean("process.clean") ?? true;
|
_processCleanup = jobContext.Variables.GetBoolean("process.clean") ?? true;
|
||||||
|
|||||||
@@ -206,22 +206,8 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
var action2 = jobContext.CreateChild(Guid.NewGuid(), "action_2", "action_2", null, null);
|
var action2 = jobContext.CreateChild(Guid.NewGuid(), "action_2", "action_2", null, null);
|
||||||
action2.IntraActionState["state"] = "2";
|
action2.IntraActionState["state"] = "2";
|
||||||
|
|
||||||
|
action1.RegisterPostJobAction("post1", "always()", new Pipelines.ActionStep() { Name = "post1", DisplayName = "Test 1", Reference = new Pipelines.RepositoryPathReference() { Name = "actions/action" } });
|
||||||
var postRunner1 = hc.CreateService<IActionRunner>();
|
action2.RegisterPostJobAction("post2", "always()", new Pipelines.ActionStep() { Name = "post2", DisplayName = "Test 2", Reference = new Pipelines.RepositoryPathReference() { Name = "actions/action" } });
|
||||||
postRunner1.Action = new Pipelines.ActionStep() { Name = "post1", DisplayName = "Test 1", Reference = new Pipelines.RepositoryPathReference() { Name = "actions/action" } };
|
|
||||||
postRunner1.Stage = ActionRunStage.Post;
|
|
||||||
postRunner1.Condition = "always()";
|
|
||||||
postRunner1.DisplayName = "post1";
|
|
||||||
|
|
||||||
|
|
||||||
var postRunner2 = hc.CreateService<IActionRunner>();
|
|
||||||
postRunner2.Action = new Pipelines.ActionStep() { Name = "post2", DisplayName = "Test 2", Reference = new Pipelines.RepositoryPathReference() { Name = "actions/action" } };
|
|
||||||
postRunner2.Stage = ActionRunStage.Post;
|
|
||||||
postRunner2.Condition = "always()";
|
|
||||||
postRunner2.DisplayName = "post2";
|
|
||||||
|
|
||||||
action1.RegisterPostJobStep("post1", postRunner1);
|
|
||||||
action2.RegisterPostJobStep("post2", postRunner2);
|
|
||||||
|
|
||||||
Assert.NotNull(jobContext.JobSteps);
|
Assert.NotNull(jobContext.JobSteps);
|
||||||
Assert.NotNull(jobContext.PostJobSteps);
|
Assert.NotNull(jobContext.PostJobSteps);
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
2.160.2
|
2.160.0
|
||||||
Reference in New Issue
Block a user