mirror of
https://github.com/actions/runner.git
synced 2025-12-11 04:46:58 +00:00
Compare commits
7 Commits
AddBuildIm
...
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
|
||||
|
||||
@@ -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;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,10 +15,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="3.2.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
|
||||
|
||||
12
src/dev.sh
12
src/dev.sh
@@ -194,10 +194,6 @@ function layout ()
|
||||
|
||||
function runtest ()
|
||||
{
|
||||
if [[ ! -d "$LAYOUT_DIR" ]]; then
|
||||
echo "$LAYOUT_DIR doesn't exist. Generating it now ..."
|
||||
layout
|
||||
fi
|
||||
heading "Testing ..."
|
||||
|
||||
if [[ ("$CURRENT_PLATFORM" == "linux") || ("$CURRENT_PLATFORM" == "darwin") ]]; then
|
||||
@@ -207,13 +203,6 @@ function runtest ()
|
||||
dotnet msbuild -t:test -p:PackageRuntime="${RUNTIME_ID}" -p:BUILDCONFIG="${BUILD_CONFIG}" -p:RunnerVersion="${RUNNER_VERSION}" ./dir.proj || failed "failed tests"
|
||||
}
|
||||
|
||||
function coverage ()
|
||||
{
|
||||
heading "Coverage ..."
|
||||
cd Test && dotnet test --collect:"XPlat Code Coverage;Format=json"
|
||||
# reportgenerator -reports:"/workspaces/runner/src/Test/TestResults/ecf2bd75-83e9-489a-9339-d61293abf98b/coverage.cobertura.xml" -targetdir:"coveragereport" -reporttypes:Html
|
||||
}
|
||||
|
||||
function format()
|
||||
{
|
||||
heading "Formatting..."
|
||||
@@ -380,7 +369,6 @@ case $DEV_CMD in
|
||||
"p") package;;
|
||||
"format") format;;
|
||||
"f") format;;
|
||||
"c") coverage;;
|
||||
*) echo "Invalid cmd. Use build(b), test(t), layout(l), package(p), or format(f)";;
|
||||
esac
|
||||
|
||||
|
||||
Reference in New Issue
Block a user