mirror of
https://github.com/actions/runner.git
synced 2025-12-10 12:36:23 +00:00
Compare commits
7 Commits
DontAddTem
...
CodeCleanu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a02cacf35a | ||
|
|
50b3edff3c | ||
|
|
58f7a379a1 | ||
|
|
e13627df81 | ||
|
|
48cbee08f9 | ||
|
|
21b49c542c | ||
|
|
8db8bbe13a |
@@ -2,7 +2,7 @@ FROM mcr.microsoft.com/dotnet/runtime-deps:6.0 as build
|
||||
|
||||
ARG RUNNER_VERSION
|
||||
ARG RUNNER_ARCH="x64"
|
||||
ARG RUNNER_CONTAINER_HOOKS_VERSION=0.3.1
|
||||
ARG RUNNER_CONTAINER_HOOKS_VERSION=0.3.2
|
||||
ARG DOCKER_VERSION=20.10.23
|
||||
|
||||
RUN apt update -y && apt install curl unzip -y
|
||||
|
||||
@@ -818,6 +818,7 @@ namespace GitHub.Runner.Common
|
||||
|
||||
return mergedRecords;
|
||||
}
|
||||
|
||||
private async Task UploadFile(UploadFileInfo file)
|
||||
{
|
||||
bool uploadSucceed = false;
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace GitHub.Runner.Listener.Configuration
|
||||
GitHubAuthResult authResult = await GetTenantCredential(inputUrl, registerToken, Constants.RunnerEvent.Register);
|
||||
runnerSettings.ServerUrl = authResult.TenantUrl;
|
||||
runnerSettings.UseV2Flow = authResult.UseV2Flow;
|
||||
_term.WriteLine($"Using V2 flow: {runnerSettings.UseV2Flow}");
|
||||
Trace.Info($"Using V2 flow: {runnerSettings.UseV2Flow}");
|
||||
creds = authResult.ToVssCredentials();
|
||||
Trace.Info("cred retrieved via GitHub auth");
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace GitHub.Runner.Worker.Container.ContainerHooks
|
||||
public HookContainer(ContainerInfo container)
|
||||
{
|
||||
Image = container.ContainerImage;
|
||||
EntryPointArgs = container.ContainerEntryPointArgs?.Split(' ').Select(arg => arg.Trim()) ?? new List<string>();
|
||||
EntryPointArgs = container.ContainerEntryPointArgs?.Split(' ').Select(arg => arg.Trim()).Where(arg => !string.IsNullOrEmpty(arg)) ?? new List<string>();
|
||||
EntryPoint = container.ContainerEntryPoint;
|
||||
WorkingDirectory = container.ContainerWorkDirectory;
|
||||
CreateOptions = container.ContainerCreateOptions;
|
||||
|
||||
@@ -150,6 +150,11 @@ namespace GitHub.Runner.Worker
|
||||
_runnerSettings = HostContext.GetService<IConfigurationStore>().GetSettings();
|
||||
jobContext.SetRunnerContext("name", _runnerSettings.AgentName);
|
||||
|
||||
if (jobContext.Global.Variables.TryGetValue(WellKnownDistributedTaskVariables.RunnerEnvironment, out var runnerEnvironment))
|
||||
{
|
||||
jobContext.SetRunnerContext("environment", runnerEnvironment);
|
||||
}
|
||||
|
||||
string toolsDirectory = HostContext.GetDirectory(WellKnownDirectory.Tools);
|
||||
Directory.CreateDirectory(toolsDirectory);
|
||||
jobContext.SetRunnerContext("tool_cache", toolsDirectory);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
@@ -163,6 +163,7 @@ namespace GitHub.DistributedTask.ObjectTemplating
|
||||
message = $"{prefix} {message}";
|
||||
}
|
||||
|
||||
Errors.Add(message);
|
||||
TraceWriter.Error(message);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace GitHub.DistributedTask.WebApi
|
||||
{
|
||||
@@ -6,5 +6,6 @@ namespace GitHub.DistributedTask.WebApi
|
||||
{
|
||||
public static readonly String JobId = "system.jobId";
|
||||
public static readonly String RunnerLowDiskspaceThreshold = "system.runner.lowdiskspacethreshold";
|
||||
public static readonly String RunnerEnvironment = "system.runnerEnvironment";
|
||||
}
|
||||
}
|
||||
|
||||
57
src/Test/L0/Sdk/DTObjectTemplating/TemplateContextL0.cs
Normal file
57
src/Test/L0/Sdk/DTObjectTemplating/TemplateContextL0.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GitHub.DistributedTask.ObjectTemplating.Tokens;
|
||||
using Xunit;
|
||||
|
||||
namespace GitHub.DistributedTask.ObjectTemplating.Tests
|
||||
{
|
||||
public sealed class TemplateContextL0
|
||||
{
|
||||
[Fact]
|
||||
[Trait("Level", "L0")]
|
||||
[Trait("Category", "Common")]
|
||||
public void VerifyError()
|
||||
{
|
||||
TemplateContext context = buildContext();
|
||||
TemplateToken value = new StringToken(1, 1, 1, "some-token");
|
||||
System.Exception ex = new System.Exception();
|
||||
|
||||
List<TemplateValidationError> expectedErrors = new();
|
||||
expectedErrors.Add(new TemplateValidationError("(Line: 1, Col: 1): Exception of type 'System.Exception' was thrown."));
|
||||
|
||||
context.Error(value, ex);
|
||||
|
||||
|
||||
Assert.True(expectedErrors.SequenceEqual(toList(context.Errors.GetEnumerator())));
|
||||
|
||||
|
||||
Assert.True(true);
|
||||
}
|
||||
|
||||
private TemplateContext buildContext()
|
||||
{
|
||||
return new TemplateContext
|
||||
{
|
||||
// CancellationToken = CancellationToken.None,
|
||||
Errors = new TemplateValidationErrors(10, int.MaxValue), // Don't truncate error messages otherwise we might not scrub secrets correctly
|
||||
Memory = new TemplateMemory(
|
||||
maxDepth: 100,
|
||||
maxEvents: 1000000,
|
||||
maxBytes: 10 * 1024 * 1024),
|
||||
Schema = null,
|
||||
TraceWriter = new EmptyTraceWriter(),
|
||||
};
|
||||
}
|
||||
|
||||
private List<TemplateValidationError> toList(IEnumerator<TemplateValidationError> enumerator)
|
||||
{
|
||||
List<TemplateValidationError> result = new();
|
||||
while (enumerator.MoveNext())
|
||||
{
|
||||
TemplateValidationError err = enumerator.Current;
|
||||
result.Add(err);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user