mirror of
https://github.com/actions/runner.git
synced 2025-12-11 12:57:05 +00:00
Compare commits
6 Commits
users/eric
...
robherley/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e552c0cced | ||
|
|
e112193313 | ||
|
|
386fa86f91 | ||
|
|
412dc5c836 | ||
|
|
0361ffcbf9 | ||
|
|
25f6cb1d78 |
@@ -33,9 +33,6 @@ namespace GitHub.Runner.Common
|
|||||||
[DataMember(EmitDefaultValue = false)]
|
[DataMember(EmitDefaultValue = false)]
|
||||||
public string PoolName { get; set; }
|
public string PoolName { get; set; }
|
||||||
|
|
||||||
[DataMember(EmitDefaultValue = false)]
|
|
||||||
public bool DisableUpdate { get; set; }
|
|
||||||
|
|
||||||
[DataMember(EmitDefaultValue = false)]
|
[DataMember(EmitDefaultValue = false)]
|
||||||
public bool Ephemeral { get; set; }
|
public bool Ephemeral { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ namespace GitHub.Runner.Common
|
|||||||
Externals,
|
Externals,
|
||||||
Root,
|
Root,
|
||||||
Actions,
|
Actions,
|
||||||
|
StepSummary,
|
||||||
Temp,
|
Temp,
|
||||||
Tools,
|
Tools,
|
||||||
Update,
|
Update,
|
||||||
@@ -129,7 +130,6 @@ namespace GitHub.Runner.Common
|
|||||||
public static readonly string Ephemeral = "ephemeral";
|
public static readonly string Ephemeral = "ephemeral";
|
||||||
public static readonly string Help = "help";
|
public static readonly string Help = "help";
|
||||||
public static readonly string Replace = "replace";
|
public static readonly string Replace = "replace";
|
||||||
public static readonly string DisableUpdate = "disableupdate";
|
|
||||||
public static readonly string Once = "once"; // Keep this around since customers still relies on it
|
public static readonly string Once = "once"; // Keep this around since customers still relies on it
|
||||||
public static readonly string RunAsService = "runasservice";
|
public static readonly string RunAsService = "runasservice";
|
||||||
public static readonly string Unattended = "unattended";
|
public static readonly string Unattended = "unattended";
|
||||||
@@ -197,6 +197,7 @@ namespace GitHub.Runner.Common
|
|||||||
public static readonly string DiagDirectory = "_diag";
|
public static readonly string DiagDirectory = "_diag";
|
||||||
public static readonly string ExternalsDirectory = "externals";
|
public static readonly string ExternalsDirectory = "externals";
|
||||||
public static readonly string RunnerDiagnosticLogPrefix = "Runner_";
|
public static readonly string RunnerDiagnosticLogPrefix = "Runner_";
|
||||||
|
public static readonly string StepSummaryDirectory = "_step_summary";
|
||||||
public static readonly string TempDirectory = "_temp";
|
public static readonly string TempDirectory = "_temp";
|
||||||
public static readonly string ToolDirectory = "_tool";
|
public static readonly string ToolDirectory = "_tool";
|
||||||
public static readonly string UpdateDirectory = "_update";
|
public static readonly string UpdateDirectory = "_update";
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ namespace GitHub.Runner.Common
|
|||||||
this.SecretMasker.AddValueEncoder(ValueEncoders.Base64StringEscape);
|
this.SecretMasker.AddValueEncoder(ValueEncoders.Base64StringEscape);
|
||||||
this.SecretMasker.AddValueEncoder(ValueEncoders.Base64StringEscapeShift1);
|
this.SecretMasker.AddValueEncoder(ValueEncoders.Base64StringEscapeShift1);
|
||||||
this.SecretMasker.AddValueEncoder(ValueEncoders.Base64StringEscapeShift2);
|
this.SecretMasker.AddValueEncoder(ValueEncoders.Base64StringEscapeShift2);
|
||||||
this.SecretMasker.AddValueEncoder(ValueEncoders.BashComparand);
|
|
||||||
this.SecretMasker.AddValueEncoder(ValueEncoders.CommandLineArgumentEscape);
|
this.SecretMasker.AddValueEncoder(ValueEncoders.CommandLineArgumentEscape);
|
||||||
this.SecretMasker.AddValueEncoder(ValueEncoders.ExpressionStringEscape);
|
this.SecretMasker.AddValueEncoder(ValueEncoders.ExpressionStringEscape);
|
||||||
this.SecretMasker.AddValueEncoder(ValueEncoders.JsonStringEscape);
|
this.SecretMasker.AddValueEncoder(ValueEncoders.JsonStringEscape);
|
||||||
@@ -244,6 +243,12 @@ namespace GitHub.Runner.Common
|
|||||||
path = new DirectoryInfo(GetDirectory(WellKnownDirectory.Bin)).Parent.FullName;
|
path = new DirectoryInfo(GetDirectory(WellKnownDirectory.Bin)).Parent.FullName;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WellKnownDirectory.StepSummary:
|
||||||
|
path = Path.Combine(
|
||||||
|
GetDirectory(WellKnownDirectory.Temp),
|
||||||
|
Constants.Path.StepSummaryDirectory);
|
||||||
|
break;
|
||||||
|
|
||||||
case WellKnownDirectory.Temp:
|
case WellKnownDirectory.Temp:
|
||||||
path = Path.Combine(
|
path = Path.Combine(
|
||||||
GetDirectory(WellKnownDirectory.Work),
|
GetDirectory(WellKnownDirectory.Work),
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ namespace GitHub.Runner.Listener
|
|||||||
{
|
{
|
||||||
Constants.Runner.CommandLine.Flags.Check,
|
Constants.Runner.CommandLine.Flags.Check,
|
||||||
Constants.Runner.CommandLine.Flags.Commit,
|
Constants.Runner.CommandLine.Flags.Commit,
|
||||||
Constants.Runner.CommandLine.Flags.DisableUpdate,
|
|
||||||
Constants.Runner.CommandLine.Flags.Ephemeral,
|
Constants.Runner.CommandLine.Flags.Ephemeral,
|
||||||
Constants.Runner.CommandLine.Flags.Help,
|
Constants.Runner.CommandLine.Flags.Help,
|
||||||
Constants.Runner.CommandLine.Flags.Once,
|
Constants.Runner.CommandLine.Flags.Once,
|
||||||
@@ -69,7 +68,6 @@ namespace GitHub.Runner.Listener
|
|||||||
public bool Unattended => TestFlag(Constants.Runner.CommandLine.Flags.Unattended);
|
public bool Unattended => TestFlag(Constants.Runner.CommandLine.Flags.Unattended);
|
||||||
public bool Version => TestFlag(Constants.Runner.CommandLine.Flags.Version);
|
public bool Version => TestFlag(Constants.Runner.CommandLine.Flags.Version);
|
||||||
public bool Ephemeral => TestFlag(Constants.Runner.CommandLine.Flags.Ephemeral);
|
public bool Ephemeral => TestFlag(Constants.Runner.CommandLine.Flags.Ephemeral);
|
||||||
public bool DisableUpdate => TestFlag(Constants.Runner.CommandLine.Flags.DisableUpdate);
|
|
||||||
|
|
||||||
// Keep this around since customers still relies on it
|
// Keep this around since customers still relies on it
|
||||||
public bool RunOnce => TestFlag(Constants.Runner.CommandLine.Flags.Once);
|
public bool RunOnce => TestFlag(Constants.Runner.CommandLine.Flags.Once);
|
||||||
|
|||||||
@@ -196,7 +196,6 @@ namespace GitHub.Runner.Listener.Configuration
|
|||||||
TaskAgent agent;
|
TaskAgent agent;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
runnerSettings.DisableUpdate = command.DisableUpdate;
|
|
||||||
runnerSettings.Ephemeral = command.Ephemeral;
|
runnerSettings.Ephemeral = command.Ephemeral;
|
||||||
runnerSettings.AgentName = command.GetRunnerName();
|
runnerSettings.AgentName = command.GetRunnerName();
|
||||||
|
|
||||||
@@ -214,22 +213,11 @@ namespace GitHub.Runner.Listener.Configuration
|
|||||||
if (command.GetReplace())
|
if (command.GetReplace())
|
||||||
{
|
{
|
||||||
// Update existing agent with new PublicKey, agent version.
|
// Update existing agent with new PublicKey, agent version.
|
||||||
agent = UpdateExistingAgent(agent, publicKey, userLabels, runnerSettings.Ephemeral, command.DisableUpdate);
|
agent = UpdateExistingAgent(agent, publicKey, userLabels, runnerSettings.Ephemeral);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
agent = await _runnerServer.ReplaceAgentAsync(runnerSettings.PoolId, agent);
|
agent = await _runnerServer.ReplaceAgentAsync(runnerSettings.PoolId, agent);
|
||||||
if (command.DisableUpdate &&
|
|
||||||
command.DisableUpdate != agent.DisableUpdate)
|
|
||||||
{
|
|
||||||
throw new NotSupportedException("The GitHub server does not support configuring a self-hosted runner with 'DisableUpdate' flag.");
|
|
||||||
}
|
|
||||||
if (command.Ephemeral &&
|
|
||||||
command.Ephemeral != agent.Ephemeral)
|
|
||||||
{
|
|
||||||
throw new NotSupportedException("The GitHub server does not support configuring a self-hosted runner with 'Ephemeral' flag.");
|
|
||||||
}
|
|
||||||
|
|
||||||
_term.WriteSuccessMessage("Successfully replaced the runner");
|
_term.WriteSuccessMessage("Successfully replaced the runner");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -248,22 +236,11 @@ namespace GitHub.Runner.Listener.Configuration
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Create a new agent.
|
// Create a new agent.
|
||||||
agent = CreateNewAgent(runnerSettings.AgentName, publicKey, userLabels, runnerSettings.Ephemeral, command.DisableUpdate);
|
agent = CreateNewAgent(runnerSettings.AgentName, publicKey, userLabels, runnerSettings.Ephemeral);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
agent = await _runnerServer.AddAgentAsync(runnerSettings.PoolId, agent);
|
agent = await _runnerServer.AddAgentAsync(runnerSettings.PoolId, agent);
|
||||||
if (command.DisableUpdate &&
|
|
||||||
command.DisableUpdate != agent.DisableUpdate)
|
|
||||||
{
|
|
||||||
throw new NotSupportedException("The GitHub server does not support configuring a self-hosted runner with 'DisableUpdate' flag.");
|
|
||||||
}
|
|
||||||
if (command.Ephemeral &&
|
|
||||||
command.Ephemeral != agent.Ephemeral)
|
|
||||||
{
|
|
||||||
throw new NotSupportedException("The GitHub server does not support configuring a self-hosted runner with 'Ephemeral' flag.");
|
|
||||||
}
|
|
||||||
|
|
||||||
_term.WriteSuccessMessage("Runner successfully added");
|
_term.WriteSuccessMessage("Runner successfully added");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -489,7 +466,7 @@ namespace GitHub.Runner.Listener.Configuration
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private TaskAgent UpdateExistingAgent(TaskAgent agent, RSAParameters publicKey, ISet<string> userLabels, bool ephemeral, bool disableUpdate)
|
private TaskAgent UpdateExistingAgent(TaskAgent agent, RSAParameters publicKey, ISet<string> userLabels, bool ephemeral)
|
||||||
{
|
{
|
||||||
ArgUtil.NotNull(agent, nameof(agent));
|
ArgUtil.NotNull(agent, nameof(agent));
|
||||||
agent.Authorization = new TaskAgentAuthorization
|
agent.Authorization = new TaskAgentAuthorization
|
||||||
@@ -501,7 +478,6 @@ namespace GitHub.Runner.Listener.Configuration
|
|||||||
agent.Version = BuildConstants.RunnerPackage.Version;
|
agent.Version = BuildConstants.RunnerPackage.Version;
|
||||||
agent.OSDescription = RuntimeInformation.OSDescription;
|
agent.OSDescription = RuntimeInformation.OSDescription;
|
||||||
agent.Ephemeral = ephemeral;
|
agent.Ephemeral = ephemeral;
|
||||||
agent.DisableUpdate = disableUpdate;
|
|
||||||
agent.MaxParallelism = 1;
|
agent.MaxParallelism = 1;
|
||||||
|
|
||||||
agent.Labels.Clear();
|
agent.Labels.Clear();
|
||||||
@@ -518,7 +494,7 @@ namespace GitHub.Runner.Listener.Configuration
|
|||||||
return agent;
|
return agent;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TaskAgent CreateNewAgent(string agentName, RSAParameters publicKey, ISet<string> userLabels, bool ephemeral, bool disableUpdate)
|
private TaskAgent CreateNewAgent(string agentName, RSAParameters publicKey, ISet<string> userLabels, bool ephemeral)
|
||||||
{
|
{
|
||||||
TaskAgent agent = new TaskAgent(agentName)
|
TaskAgent agent = new TaskAgent(agentName)
|
||||||
{
|
{
|
||||||
@@ -530,7 +506,6 @@ namespace GitHub.Runner.Listener.Configuration
|
|||||||
Version = BuildConstants.RunnerPackage.Version,
|
Version = BuildConstants.RunnerPackage.Version,
|
||||||
OSDescription = RuntimeInformation.OSDescription,
|
OSDescription = RuntimeInformation.OSDescription,
|
||||||
Ephemeral = ephemeral,
|
Ephemeral = ephemeral,
|
||||||
DisableUpdate = disableUpdate
|
|
||||||
};
|
};
|
||||||
|
|
||||||
agent.Labels.Add(new AgentLabel("self-hosted", LabelType.System));
|
agent.Labels.Add(new AgentLabel("self-hosted", LabelType.System));
|
||||||
|
|||||||
@@ -540,7 +540,6 @@ Config Options:
|
|||||||
--work string Relative runner work directory (default {Constants.Path.WorkDirectory})
|
--work string Relative runner work directory (default {Constants.Path.WorkDirectory})
|
||||||
--replace Replace any existing runner with the same name (default false)
|
--replace Replace any existing runner with the same name (default false)
|
||||||
--pat GitHub personal access token used for checking network connectivity when executing `.{separator}run.{ext} --check`
|
--pat GitHub personal access token used for checking network connectivity when executing `.{separator}run.{ext} --check`
|
||||||
--disableupdate Disable self-hosted runner automatic update to the latest released version`
|
|
||||||
--ephemeral Configure the runner to only take one job and then let the service un-configure the runner after the job finishes (default false)");
|
--ephemeral Configure the runner to only take one job and then let the service un-configure the runner after the job finishes (default false)");
|
||||||
|
|
||||||
#if OS_WINDOWS
|
#if OS_WINDOWS
|
||||||
|
|||||||
@@ -469,7 +469,7 @@ namespace GitHub.Runner.Plugins.Artifact
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
uploadTimer.Restart();
|
uploadTimer.Restart();
|
||||||
using (HttpResponseMessage response = await _fileContainerHttpClient.UploadFileAsync(_containerId, itemPath, fs, _projectId, cancellationToken: token))
|
using (HttpResponseMessage response = await _fileContainerHttpClient.UploadFileAsync(_containerId, itemPath, fs, _projectId, cancellationToken: token, chunkSize: 4 * 1024 * 1024))
|
||||||
{
|
{
|
||||||
if (response == null || response.StatusCode != HttpStatusCode.Created)
|
if (response == null || response.StatusCode != HttpStatusCode.Created)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
using System;
|
using GitHub.DistributedTask.WebApi;
|
||||||
|
using Pipelines = GitHub.DistributedTask.Pipelines;
|
||||||
|
using GitHub.Runner.Common.Util;
|
||||||
|
using GitHub.Services.Common;
|
||||||
|
using GitHub.Services.WebApi;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using GitHub.DistributedTask.WebApi;
|
using System.Net.Http;
|
||||||
using GitHub.Runner.Common;
|
using GitHub.Runner.Common;
|
||||||
using GitHub.Runner.Common.Util;
|
|
||||||
using GitHub.Runner.Sdk;
|
using GitHub.Runner.Sdk;
|
||||||
using GitHub.Services.Common;
|
|
||||||
using GitHub.Services.WebApi;
|
|
||||||
using Pipelines = GitHub.DistributedTask.Pipelines;
|
|
||||||
|
|
||||||
namespace GitHub.Runner.Worker
|
namespace GitHub.Runner.Worker
|
||||||
{
|
{
|
||||||
@@ -25,7 +25,6 @@ namespace GitHub.Runner.Worker
|
|||||||
public sealed class JobRunner : RunnerService, IJobRunner
|
public sealed class JobRunner : RunnerService, IJobRunner
|
||||||
{
|
{
|
||||||
private IJobServerQueue _jobServerQueue;
|
private IJobServerQueue _jobServerQueue;
|
||||||
private RunnerSettings _runnerSettings;
|
|
||||||
private ITempDirectoryManager _tempDirectoryManager;
|
private ITempDirectoryManager _tempDirectoryManager;
|
||||||
|
|
||||||
public async Task<TaskResult> RunAsync(Pipelines.AgentJobRequestMessage message, CancellationToken jobRequestCancellationToken)
|
public async Task<TaskResult> RunAsync(Pipelines.AgentJobRequestMessage message, CancellationToken jobRequestCancellationToken)
|
||||||
@@ -109,8 +108,8 @@ namespace GitHub.Runner.Worker
|
|||||||
jobContext.SetRunnerContext("os", VarUtil.OS);
|
jobContext.SetRunnerContext("os", VarUtil.OS);
|
||||||
jobContext.SetRunnerContext("arch", VarUtil.OSArchitecture);
|
jobContext.SetRunnerContext("arch", VarUtil.OSArchitecture);
|
||||||
|
|
||||||
_runnerSettings = HostContext.GetService<IConfigurationStore>().GetSettings();
|
var runnerSettings = HostContext.GetService<IConfigurationStore>().GetSettings();
|
||||||
jobContext.SetRunnerContext("name", _runnerSettings.AgentName);
|
jobContext.SetRunnerContext("name", runnerSettings.AgentName);
|
||||||
|
|
||||||
string toolsDirectory = HostContext.GetDirectory(WellKnownDirectory.Tools);
|
string toolsDirectory = HostContext.GetDirectory(WellKnownDirectory.Tools);
|
||||||
Directory.CreateDirectory(toolsDirectory);
|
Directory.CreateDirectory(toolsDirectory);
|
||||||
@@ -210,53 +209,6 @@ namespace GitHub.Runner.Worker
|
|||||||
jobContext.Debug($"Finishing: {message.JobDisplayName}");
|
jobContext.Debug($"Finishing: {message.JobDisplayName}");
|
||||||
TaskResult result = jobContext.Complete(taskResult);
|
TaskResult result = jobContext.Complete(taskResult);
|
||||||
|
|
||||||
if (_runnerSettings.DisableUpdate == true)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var currentVersion = new PackageVersion(BuildConstants.RunnerPackage.Version);
|
|
||||||
ServiceEndpoint systemConnection = message.Resources.Endpoints.Single(x => string.Equals(x.Name, WellKnownServiceEndpointNames.SystemVssConnection, StringComparison.OrdinalIgnoreCase));
|
|
||||||
VssCredentials serverCredential = VssUtil.GetVssCredential(systemConnection);
|
|
||||||
|
|
||||||
var runnerServer = HostContext.GetService<IRunnerServer>();
|
|
||||||
await runnerServer.ConnectAsync(systemConnection.Url, serverCredential);
|
|
||||||
var serverPackages = await runnerServer.GetPackagesAsync("agent", BuildConstants.RunnerPackage.PackageName, 5, includeToken: false, cancellationToken: CancellationToken.None);
|
|
||||||
if (serverPackages.Count > 0)
|
|
||||||
{
|
|
||||||
serverPackages = serverPackages.OrderByDescending(x => x.Version).ToList();
|
|
||||||
Trace.Info($"Newer packages {StringUtil.ConvertToJson(serverPackages.Select(x => x.Version.ToString()))}");
|
|
||||||
|
|
||||||
var warnOnFailedJob = false; // any minor/patch version behind.
|
|
||||||
var warnOnOldRunnerVersion = false; // >= 2 minor version behind
|
|
||||||
if (serverPackages.Any(x => x.Version.CompareTo(currentVersion) > 0))
|
|
||||||
{
|
|
||||||
Trace.Info($"Current runner version {currentVersion} is behind the latest runner version {serverPackages[0].Version}.");
|
|
||||||
warnOnFailedJob = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (serverPackages.Where(x => x.Version.Major == currentVersion.Major && x.Version.Minor > currentVersion.Minor).Count() > 1)
|
|
||||||
{
|
|
||||||
Trace.Info($"Current runner version {currentVersion} is way behind the latest runner version {serverPackages[0].Version}.");
|
|
||||||
warnOnOldRunnerVersion = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result == TaskResult.Failed && warnOnFailedJob)
|
|
||||||
{
|
|
||||||
jobContext.Warning($"This job failure may be caused by using an out of date self-hosted runner. You are currently using runner version {currentVersion}. Please update to the latest version {serverPackages[0].Version}");
|
|
||||||
}
|
|
||||||
else if (warnOnOldRunnerVersion)
|
|
||||||
{
|
|
||||||
jobContext.Warning($"This self-hosted runner is currently using runner version {currentVersion}. This version is out of date. Please update to the latest version {serverPackages[0].Version}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
// Ignore any error since suggest runner update is best effort.
|
|
||||||
Trace.Error($"Caught exception during runner version check: {ex}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await ShutdownQueue(throwOnFailure: true);
|
await ShutdownQueue(throwOnFailure: true);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -103,6 +104,10 @@ namespace GitHub.Runner.Worker
|
|||||||
// Set GITHUB_ACTION
|
// Set GITHUB_ACTION
|
||||||
step.ExecutionContext.SetGitHubContext("action", actionStep.Action.Name);
|
step.ExecutionContext.SetGitHubContext("action", actionStep.Action.Name);
|
||||||
|
|
||||||
|
var stepSummaryFilePath = CreateStepSummaryFile(step);
|
||||||
|
step.ExecutionContext.SetGitHubContext("step_summary", stepSummaryFilePath);
|
||||||
|
envContext["GITHUB_STEP_SUMMARY"] = new StringContextData(stepSummaryFilePath);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Evaluate and merge step env
|
// Evaluate and merge step env
|
||||||
@@ -352,7 +357,52 @@ namespace GitHub.Runner.Worker
|
|||||||
{
|
{
|
||||||
var executionContext = step.ExecutionContext;
|
var executionContext = step.ExecutionContext;
|
||||||
|
|
||||||
|
CreateSummaryAttachment(step);
|
||||||
|
|
||||||
executionContext.Complete(result, resultCode: resultCode);
|
executionContext.Complete(result, resultCode: resultCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string CreateStepSummaryFile(IStep step)
|
||||||
|
{
|
||||||
|
var stepSummaryDirectory = HostContext.GetDirectory(WellKnownDirectory.StepSummary);
|
||||||
|
if (!Directory.Exists(stepSummaryDirectory))
|
||||||
|
{
|
||||||
|
Trace.Info($"Creating step summary directory: {stepSummaryDirectory}");
|
||||||
|
Directory.CreateDirectory(stepSummaryDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
var stepID = step.ExecutionContext.Id;
|
||||||
|
var stepSummaryFilePath = Path.Combine(stepSummaryDirectory, $"{stepID}.md");
|
||||||
|
|
||||||
|
Trace.Info($"Creating step summary file: {stepSummaryFilePath}");
|
||||||
|
File.Create(stepSummaryFilePath).Close();
|
||||||
|
return stepSummaryFilePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateSummaryAttachment(IStep step) {
|
||||||
|
var executionContext = step.ExecutionContext;
|
||||||
|
var parentContext = executionContext.Root;
|
||||||
|
var stepSummaryFilePath = executionContext.GetGitHubContext("step_summary");
|
||||||
|
var stepID = executionContext.Id;
|
||||||
|
|
||||||
|
Trace.Info($"Reading step summary data from {stepSummaryFilePath}");
|
||||||
|
|
||||||
|
var summaryExists = File.Exists(stepSummaryFilePath);
|
||||||
|
if (summaryExists)
|
||||||
|
{
|
||||||
|
Trace.Info($"File exists: {stepSummaryFilePath}");
|
||||||
|
|
||||||
|
var summaryFileIsEmpty = new FileInfo(stepSummaryFilePath).Length == 0;
|
||||||
|
if (summaryFileIsEmpty)
|
||||||
|
{
|
||||||
|
Trace.Info($"Summary file ({summaryFileIsEmpty}) is empty, skipping attachment upload");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Trace.Info($"Queueing file ({stepSummaryFilePath}) for attachment upload ({stepID})");
|
||||||
|
parentContext.QueueAttachFile(ChecksAttachmentType.StepSummary, stepID.ToString(), stepSummaryFilePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -38,20 +38,6 @@ namespace GitHub.DistributedTask.Logging
|
|||||||
return Base64StringEscapeShift(value, 2);
|
return Base64StringEscapeShift(value, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String BashComparand(String value)
|
|
||||||
{
|
|
||||||
var result = new StringBuilder();
|
|
||||||
foreach (var c in value)
|
|
||||||
{
|
|
||||||
if (!char.IsLowSurrogate(c))
|
|
||||||
{
|
|
||||||
result.Append('\\');
|
|
||||||
}
|
|
||||||
result.Append(c);
|
|
||||||
}
|
|
||||||
return result.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Used when we pass environment variables to docker to escape " with \"
|
// Used when we pass environment variables to docker to escape " with \"
|
||||||
public static String CommandLineArgumentEscape(String value)
|
public static String CommandLineArgumentEscape(String value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ namespace GitHub.DistributedTask.WebApi
|
|||||||
this.ProvisioningState = referenceToBeCloned.ProvisioningState;
|
this.ProvisioningState = referenceToBeCloned.ProvisioningState;
|
||||||
this.AccessPoint = referenceToBeCloned.AccessPoint;
|
this.AccessPoint = referenceToBeCloned.AccessPoint;
|
||||||
this.Ephemeral = referenceToBeCloned.Ephemeral;
|
this.Ephemeral = referenceToBeCloned.Ephemeral;
|
||||||
this.DisableUpdate = referenceToBeCloned.DisableUpdate;
|
|
||||||
|
|
||||||
if (referenceToBeCloned.m_links != null)
|
if (referenceToBeCloned.m_links != null)
|
||||||
{
|
{
|
||||||
@@ -93,16 +92,6 @@ namespace GitHub.DistributedTask.WebApi
|
|||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether or not this agent should auto-update to latest version.
|
|
||||||
/// </summary>
|
|
||||||
[DataMember(EmitDefaultValue = false)]
|
|
||||||
public bool? DisableUpdate
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether or not the agent is online.
|
/// Whether or not the agent is online.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -102,4 +102,10 @@ namespace GitHub.DistributedTask.WebApi
|
|||||||
public static readonly String FileAttachment = "DistributedTask.Core.FileAttachment";
|
public static readonly String FileAttachment = "DistributedTask.Core.FileAttachment";
|
||||||
public static readonly String DiagnosticLog = "DistributedTask.Core.DiagnosticLog";
|
public static readonly String DiagnosticLog = "DistributedTask.Core.DiagnosticLog";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[GenerateAllConstants]
|
||||||
|
public class ChecksAttachmentType
|
||||||
|
{
|
||||||
|
public static readonly String StepSummary = "Checks.Step.Summary";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ namespace GitHub.Runner.Common.Tests.Listener.Configuration
|
|||||||
_serviceControlManager = new Mock<ILinuxServiceControlManager>();
|
_serviceControlManager = new Mock<ILinuxServiceControlManager>();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
var expectedAgent = new TaskAgent(_expectedAgentName) { Id = 1, Ephemeral = true, DisableUpdate = true };
|
var expectedAgent = new TaskAgent(_expectedAgentName) { Id = 1 };
|
||||||
expectedAgent.Authorization = new TaskAgentAuthorization
|
expectedAgent.Authorization = new TaskAgentAuthorization
|
||||||
{
|
{
|
||||||
ClientId = Guid.NewGuid(),
|
ClientId = Guid.NewGuid(),
|
||||||
@@ -154,7 +154,7 @@ namespace GitHub.Runner.Common.Tests.Listener.Configuration
|
|||||||
tc,
|
tc,
|
||||||
new[]
|
new[]
|
||||||
{
|
{
|
||||||
"configure",
|
"configure",
|
||||||
"--url", _expectedServerUrl,
|
"--url", _expectedServerUrl,
|
||||||
"--name", _expectedAgentName,
|
"--name", _expectedAgentName,
|
||||||
"--runnergroup", _secondRunnerGroupName,
|
"--runnergroup", _secondRunnerGroupName,
|
||||||
@@ -163,8 +163,6 @@ namespace GitHub.Runner.Common.Tests.Listener.Configuration
|
|||||||
"--token", _expectedToken,
|
"--token", _expectedToken,
|
||||||
"--labels", userLabels,
|
"--labels", userLabels,
|
||||||
"--ephemeral",
|
"--ephemeral",
|
||||||
"--disableupdate",
|
|
||||||
"--unattended",
|
|
||||||
});
|
});
|
||||||
trace.Info("Constructed.");
|
trace.Info("Constructed.");
|
||||||
_store.Setup(x => x.IsConfigured()).Returns(false);
|
_store.Setup(x => x.IsConfigured()).Returns(false);
|
||||||
@@ -187,7 +185,7 @@ namespace GitHub.Runner.Common.Tests.Listener.Configuration
|
|||||||
// validate GetAgentPoolsAsync gets called twice with automation pool type
|
// validate GetAgentPoolsAsync gets called twice with automation pool type
|
||||||
_runnerServer.Verify(x => x.GetAgentPoolsAsync(It.IsAny<string>(), It.Is<TaskAgentPoolType>(p => p == TaskAgentPoolType.Automation)), Times.Exactly(2));
|
_runnerServer.Verify(x => x.GetAgentPoolsAsync(It.IsAny<string>(), It.Is<TaskAgentPoolType>(p => p == TaskAgentPoolType.Automation)), Times.Exactly(2));
|
||||||
|
|
||||||
var expectedLabels = new List<string>() { "self-hosted", VarUtil.OS, VarUtil.OSArchitecture };
|
var expectedLabels = new List<string>() { "self-hosted", VarUtil.OS, VarUtil.OSArchitecture};
|
||||||
expectedLabels.AddRange(userLabels.Split(",").ToList());
|
expectedLabels.AddRange(userLabels.Split(",").ToList());
|
||||||
|
|
||||||
_runnerServer.Verify(x => x.AddAgentAsync(It.IsAny<int>(), It.Is<TaskAgent>(a => a.Labels.Select(x => x.Name).ToHashSet().SetEquals(expectedLabels))), Times.Once);
|
_runnerServer.Verify(x => x.AddAgentAsync(It.IsAny<int>(), It.Is<TaskAgent>(a => a.Labels.Select(x => x.Name).ToHashSet().SetEquals(expectedLabels))), Times.Once);
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
2.286.0
|
2.286.2
|
||||||
|
|||||||
Reference in New Issue
Block a user