Compare commits

..

9 Commits

Author SHA1 Message Date
Bassem Dghaidi
1c48dad21d Switch to ubuntu-22.04 base image 2023-06-08 09:45:39 -04:00
JoannaaKL
efffbaeabc Add utf8 with bom (#2641)
* Change default file encoding
2023-06-02 21:47:59 +02:00
Nikola Jokic
3a1376f90e Fix uses: docker://image:tag steps when container hook is used (#2626)
* Fix `uses: docker://image:tag` steps when container hook is used

* Update src/Runner.Worker/ActionManager.cs

---------

Co-authored-by: Ferenc Hammerl <31069338+fhammerl@users.noreply.github.com>
2023-06-02 11:01:59 +00:00
JoannaaKL
50b3edff3c Revert "Dont log error twice in ExecutionContext on template error (#2634)"
This reverts commit 48cbee08f9.
2023-06-01 06:46:10 +00:00
Nikola Jokic
58f7a379a1 Filter out empty arguments in container hooks (#2633) 2023-05-31 16:58:48 +02:00
Luke Tomlinson
e13627df81 Move Using V2 Flow log to Trace (#2635) 2023-05-31 10:40:34 -04:00
JoannaaKL
48cbee08f9 Dont log error twice in ExecutionContext on template error (#2634) 2023-05-31 16:33:36 +02:00
Philip Harrison
21b49c542c Set runner environment in context and env (#2518)
* Set runner environment in runner context and env

Extract runner_environment from the global context and expose in the
`github.runner` context and env as `RUNNER_ENVIRONMENT`.

Signed-off-by: Philip Harrison <philip@mailharrison.com>

* encoding.

---------

Signed-off-by: Philip Harrison <philip@mailharrison.com>
Co-authored-by: Tingluo Huang <tingluohuang@github.com>
2023-05-26 13:08:41 -04:00
Bassem Dghaidi
8db8bbe13a Update container-hooks to 0.3.2 (#2618) 2023-05-23 09:35:30 -04:00
269 changed files with 513 additions and 558 deletions

View File

@@ -1,9 +0,0 @@
# https://editorconfig.org/
[*]
charset = utf-8 # Set default charset to utf-8
insert_final_newline = true # ensure all files end with a single newline
trim_trailing_whitespace = true # attempt to remove trailing whitespace on save
[*.md]
trim_trailing_whitespace = false # in markdown, "two trailing spaces" is unfortunately meaningful; it means `<br>`

View File

@@ -1,14 +1,15 @@
FROM mcr.microsoft.com/dotnet/runtime-deps:6.0 as build # Source: https://github.com/dotnet/dotnet-docker
FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-jammy as build
ARG RUNNER_VERSION ARG RUNNER_VERSION
ARG RUNNER_ARCH="x64" 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 ARG DOCKER_VERSION=20.10.23
RUN apt update -y && apt install curl unzip -y RUN apt update -y && apt install curl unzip -y
WORKDIR /actions-runner WORKDIR /actions-runner
RUN curl -f -L -o runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${RUNNER_ARCH}-${RUNNER_VERSION}.tar.gz \ RUN curl -f -L -o runner.tar.gz https://github.com/nebuchadnezzar-corp/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${RUNNER_ARCH}-${RUNNER_VERSION}.tar.gz \
&& tar xzf ./runner.tar.gz \ && tar xzf ./runner.tar.gz \
&& rm runner.tar.gz && rm runner.tar.gz
@@ -22,7 +23,7 @@ RUN export DOCKER_ARCH=x86_64 \
&& tar zxvf docker.tgz \ && tar zxvf docker.tgz \
&& rm -rf docker.tgz && rm -rf docker.tgz
FROM mcr.microsoft.com/dotnet/runtime-deps:6.0 FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-jammy
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
ENV RUNNER_MANUALLY_TRAP_SIG=1 ENV RUNNER_MANUALLY_TRAP_SIG=1
@@ -31,6 +32,7 @@ ENV ACTIONS_RUNNER_PRINT_LOG_TO_STDOUT=1
RUN apt-get update -y \ RUN apt-get update -y \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
sudo \ sudo \
lsb-release \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
RUN adduser --disabled-password --gecos "" --uid 1001 runner \ RUN adduser --disabled-password --gecos "" --uid 1001 runner \

View File

@@ -1,5 +1,5 @@
[*.cs] [*.cs]
charset = utf-8 charset = utf-8-bom
insert_final_newline = true insert_final_newline = true
csharp_new_line_before_else = true csharp_new_line_before_else = true

View File

@@ -1,4 +1,4 @@
using GitHub.Runner.Sdk; using GitHub.Runner.Sdk;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@@ -1,4 +1,4 @@
namespace GitHub.Runner.Common namespace GitHub.Runner.Common
{ {
public enum ActionResult public enum ActionResult
{ {
@@ -10,4 +10,4 @@ namespace GitHub.Runner.Common
Skipped = 3 Skipped = 3
} }
} }

View File

@@ -1,11 +1,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using GitHub.Actions.RunService.WebApi; using GitHub.Actions.RunService.WebApi;
using GitHub.DistributedTask.Pipelines; using GitHub.DistributedTask.Pipelines;
using GitHub.DistributedTask.WebApi; using GitHub.DistributedTask.WebApi;
using GitHub.Runner.Common.Util;
using GitHub.Runner.Sdk; using GitHub.Runner.Sdk;
using GitHub.Services.Common; using GitHub.Services.Common;
using Sdk.RSWebApi.Contracts; using Sdk.RSWebApi.Contracts;
@@ -19,7 +18,6 @@ namespace GitHub.Runner.Common
Task ConnectAsync(Uri serverUrl, VssCredentials credentials); Task ConnectAsync(Uri serverUrl, VssCredentials credentials);
Task<TaskAgentMessage> GetRunnerMessageAsync(CancellationToken token, TaskAgentStatus status, string version); Task<TaskAgentMessage> GetRunnerMessageAsync(CancellationToken token, TaskAgentStatus status, string version);
Task<bool> DeleteRunnerMessageAsync(string messageID, CancellationToken token);
} }
public sealed class BrokerServer : RunnerService, IBrokerServer public sealed class BrokerServer : RunnerService, IBrokerServer
@@ -50,20 +48,9 @@ namespace GitHub.Runner.Common
{ {
CheckConnection(); CheckConnection();
var jobMessage = RetryRequest<TaskAgentMessage>( var jobMessage = RetryRequest<TaskAgentMessage>(
async () => await _brokerHttpClient.GetRunnerMessageAsync(version, status, cancellationToken), cancellationToken async () => await _brokerHttpClient.GetRunnerMessageAsync(version, status, cancellationToken), cancellationToken);
);
return jobMessage; return jobMessage;
} }
public Task<bool> DeleteRunnerMessageAsync(string messageID, CancellationToken cancellationToken)
{
CheckConnection();
return RetryRequest(
async () => await _brokerHttpClient.DeleteRunnerMessageAsync(messageID, cancellationToken),
cancellationToken
);
}
} }
} }

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using GitHub.DistributedTask.Logging; using GitHub.DistributedTask.Logging;
using GitHub.Runner.Sdk; using GitHub.Runner.Sdk;

View File

@@ -1,4 +1,4 @@
using GitHub.Runner.Sdk; using GitHub.Runner.Sdk;
using System; using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;

View File

@@ -1,4 +1,4 @@
using System; using System;
namespace GitHub.Runner.Common namespace GitHub.Runner.Common
{ {

View File

@@ -1,4 +1,4 @@
using GitHub.Runner.Sdk; using GitHub.Runner.Sdk;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;

View File

@@ -1,4 +1,4 @@
using GitHub.Runner.Sdk; using GitHub.Runner.Sdk;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Net.Http; using System.Net.Http;
using GitHub.Runner.Sdk; using GitHub.Runner.Sdk;
@@ -24,4 +24,4 @@ namespace GitHub.Runner.Common
return client; return client;
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using System.Text; using System.Text;
@@ -37,10 +37,10 @@ namespace GitHub.Runner.Common
{ {
ConnectMonitor(monitorSocketAddress); ConnectMonitor(monitorSocketAddress);
} }
private void StartMonitor(Guid jobId, string accessToken, Uri serverUri) private void StartMonitor(Guid jobId, string accessToken, Uri serverUri)
{ {
if(String.IsNullOrEmpty(accessToken)) if (String.IsNullOrEmpty(accessToken))
{ {
Trace.Info("No access token could be retrieved to start the monitor."); Trace.Info("No access token could be retrieved to start the monitor.");
return; return;
@@ -82,7 +82,7 @@ namespace GitHub.Runner.Common
_monitorSocket.Send(Encoding.UTF8.GetBytes(message)); _monitorSocket.Send(Encoding.UTF8.GetBytes(message));
Trace.Info("Finished EndMonitor writing to socket"); Trace.Info("Finished EndMonitor writing to socket");
await Task.Delay(TimeSpan.FromSeconds(2)); await Task.Delay(TimeSpan.FromSeconds(2));
} }
} }
catch (SocketException e) catch (SocketException e)

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;

View File

@@ -1,4 +1,4 @@
using System; using System;
using GitHub.DistributedTask.WebApi; using GitHub.DistributedTask.WebApi;
namespace GitHub.Runner.Common namespace GitHub.Runner.Common

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.IO; using System.IO;
namespace GitHub.Runner.Common namespace GitHub.Runner.Common

View File

@@ -1,4 +1,4 @@
using GitHub.Runner.Common.Util; using GitHub.Runner.Common.Util;
using GitHub.Runner.Sdk; using GitHub.Runner.Sdk;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net.Http.Headers; using System.Net.Http.Headers;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;

View File

@@ -1,4 +1,4 @@
using GitHub.DistributedTask.WebApi; using GitHub.DistributedTask.WebApi;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;

View File

@@ -1,4 +1,4 @@
using GitHub.DistributedTask.WebApi; using GitHub.DistributedTask.WebApi;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using GitHub.Runner.Sdk; using GitHub.Runner.Sdk;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
@@ -93,4 +93,4 @@ namespace GitHub.Runner.Common
IndentLevel--; IndentLevel--;
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net.Http; using System.Net.Http;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Diagnostics; using System.Diagnostics;
using GitHub.DistributedTask.Logging; using GitHub.DistributedTask.Logging;

View File

@@ -1,4 +1,4 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;

View File

@@ -1,8 +1,8 @@
// Represents absence of value. // Represents absence of value.
namespace GitHub.Runner.Common namespace GitHub.Runner.Common
{ {
public readonly struct Unit public readonly struct Unit
{ {
public static readonly Unit Value = default; public static readonly Unit Value = default;
} }
} }

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using GitHub.Runner.Sdk; using GitHub.Runner.Sdk;

View File

@@ -4,7 +4,7 @@
public static class EnumUtil public static class EnumUtil
{ {
public static T? TryParse<T>(string value) where T: struct public static T? TryParse<T>(string value) where T : struct
{ {
T val; T val;
if (Enum.TryParse(value ?? string.Empty, ignoreCase: true, result: out val)) if (Enum.TryParse(value ?? string.Empty, ignoreCase: true, result: out val))

View File

@@ -1,4 +1,4 @@
namespace GitHub.Runner.Common.Util namespace GitHub.Runner.Common.Util
{ {
using System; using System;
using GitHub.DistributedTask.WebApi; using GitHub.DistributedTask.WebApi;

View File

@@ -1,4 +1,4 @@
using System; using System;
namespace GitHub.Runner.Common.Util namespace GitHub.Runner.Common.Util
{ {

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
@@ -170,17 +170,7 @@ namespace GitHub.Runner.Listener
public async Task DeleteMessageAsync(TaskAgentMessage message) public async Task DeleteMessageAsync(TaskAgentMessage message)
{ {
Trace.Entering(); await Task.CompletedTask;
if (MessageUtil.IsRunServiceJob(message.MessageType))
{
var messageRef = StringUtil.ConvertFromJson<RunnerJobRequestRef>(message.Body);
using (var cs = new CancellationTokenSource(TimeSpan.FromSeconds(30)))
{
await _brokerServer.DeleteRunnerMessageAsync(messageRef.RunnerRequestId, cs.Token);
}
}
} }
private bool IsGetNextMessageExceptionRetriable(Exception ex) private bool IsGetNextMessageExceptionRetriable(Exception ex)

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -90,4 +90,4 @@ namespace GitHub.Runner.Listener.Check
return result; return result;
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Tracing; using System.Diagnostics.Tracing;
using System.IO; using System.IO;
@@ -415,4 +415,4 @@ namespace GitHub.Runner.Listener.Check
} }
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using GitHub.Runner.Common; using GitHub.Runner.Common;
@@ -27,4 +27,4 @@ namespace GitHub.Runner.Listener.Check
public List<string> Logs { get; set; } public List<string> Logs { get; set; }
} }
} }

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -56,4 +56,4 @@ namespace GitHub.Runner.Listener.Check
return result; return result;
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;

View File

@@ -1,4 +1,4 @@
using GitHub.Runner.Listener.Configuration; using GitHub.Runner.Listener.Configuration;
using GitHub.Runner.Common.Util; using GitHub.Runner.Common.Util;
using System; using System;
using System.Collections; using System.Collections;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net.Http; using System.Net.Http;
@@ -137,7 +137,7 @@ namespace GitHub.Runner.Listener.Configuration
GitHubAuthResult authResult = await GetTenantCredential(inputUrl, registerToken, Constants.RunnerEvent.Register); GitHubAuthResult authResult = await GetTenantCredential(inputUrl, registerToken, Constants.RunnerEvent.Register);
runnerSettings.ServerUrl = authResult.TenantUrl; runnerSettings.ServerUrl = authResult.TenantUrl;
runnerSettings.UseV2Flow = authResult.UseV2Flow; runnerSettings.UseV2Flow = authResult.UseV2Flow;
_term.WriteLine($"Using V2 flow: {runnerSettings.UseV2Flow}"); Trace.Info($"Using V2 flow: {runnerSettings.UseV2Flow}");
creds = authResult.ToVssCredentials(); creds = authResult.ToVssCredentials();
Trace.Info("cred retrieved via GitHub auth"); Trace.Info("cred retrieved via GitHub auth");
} }

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using GitHub.Runner.Common; using GitHub.Runner.Common;

View File

@@ -1,4 +1,4 @@
#if OS_WINDOWS #if OS_WINDOWS
#pragma warning disable CA1416 #pragma warning disable CA1416
using System; using System;
using System.Collections; using System.Collections;

View File

@@ -1,4 +1,4 @@
using GitHub.Runner.Common; using GitHub.Runner.Common;
using GitHub.Runner.Sdk; using GitHub.Runner.Sdk;
using System; using System;

View File

@@ -1,4 +1,4 @@
#if OS_WINDOWS #if OS_WINDOWS
using System.IO; using System.IO;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;

View File

@@ -1,4 +1,4 @@
#if OS_LINUX || OS_OSX #if OS_LINUX || OS_OSX
using System; using System;
using System.IO; using System.IO;
using System.Security.Cryptography; using System.Security.Cryptography;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using GitHub.Runner.Common; using GitHub.Runner.Common;
@@ -68,7 +68,7 @@ namespace GitHub.Runner.Listener.Configuration
// Lets add a suffix with a random number to reduce the chance of collisions between runner names once we truncate // Lets add a suffix with a random number to reduce the chance of collisions between runner names once we truncate
var random = new Random(); var random = new Random();
var num = random.Next(1000, 9999).ToString(); var num = random.Next(1000, 9999).ToString();
runnerNameSubstring +=$"-{num}"; runnerNameSubstring += $"-{num}";
serviceName = StringUtil.Format(serviceNamePattern, repoOrOrgNameSubstring, runnerNameSubstring); serviceName = StringUtil.Format(serviceNamePattern, repoOrOrgNameSubstring, runnerNameSubstring);
} }
@@ -76,12 +76,12 @@ namespace GitHub.Runner.Listener.Configuration
Trace.Info($"Service name '{serviceName}' display name '{serviceDisplayName}' will be used for service configuration."); Trace.Info($"Service name '{serviceName}' display name '{serviceDisplayName}' will be used for service configuration.");
} }
#if (OS_LINUX || OS_OSX) #if (OS_LINUX || OS_OSX)
const int MaxServiceNameLength = 150; const int MaxServiceNameLength = 150;
const int MaxRepoOrgCharacters = 70; const int MaxRepoOrgCharacters = 70;
#elif OS_WINDOWS #elif OS_WINDOWS
const int MaxServiceNameLength = 80; const int MaxServiceNameLength = 80;
const int MaxRepoOrgCharacters = 45; const int MaxRepoOrgCharacters = 45;
#endif #endif
} }
} }

View File

@@ -1,4 +1,4 @@
#if OS_LINUX #if OS_LINUX
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;

View File

@@ -1,4 +1,4 @@
using GitHub.Runner.Common.Util; using GitHub.Runner.Common.Util;
using GitHub.Runner.Sdk; using GitHub.Runner.Sdk;
using System; using System;
using System.Linq; using System.Linq;

View File

@@ -1,4 +1,4 @@
#if OS_WINDOWS #if OS_WINDOWS
#pragma warning disable CA1416 #pragma warning disable CA1416
using System; using System;
using System.IO; using System.IO;

View File

@@ -1,3 +1,3 @@
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Test")] [assembly: InternalsVisibleTo("Test")]

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;

View File

@@ -1,4 +1,4 @@
using GitHub.Runner.Common; using GitHub.Runner.Common;
using GitHub.Runner.Sdk; using GitHub.Runner.Sdk;
using System; using System;
using System.Globalization; using System.Globalization;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@@ -392,7 +392,6 @@ namespace GitHub.Runner.Listener
{ {
TaskAgentMessage message = null; TaskAgentMessage message = null;
bool skipMessageDeletion = false; bool skipMessageDeletion = false;
bool useBrokerDeletion = false;
try try
{ {
Task<TaskAgentMessage> getNextMessage = _listener.GetNextMessageAsync(messageQueueLoopTokenSource.Token); Task<TaskAgentMessage> getNextMessage = _listener.GetNextMessageAsync(messageQueueLoopTokenSource.Token);
@@ -601,15 +600,7 @@ namespace GitHub.Runner.Listener
{ {
try try
{ {
if (useBrokerDeletion) await _listener.DeleteMessageAsync(message);
{
// await _listener.DeleteMessageAsync(brokerDeletionParamsMessageID, brokerDeletionParamsToken);
await _listener.DeleteMessageAsync(message);
}
else
{
await _listener.DeleteMessageAsync(message);
}
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@@ -1,4 +1,4 @@
using System.Runtime.Serialization; using System.Runtime.Serialization;
namespace GitHub.Runner.Listener namespace GitHub.Runner.Listener
{ {

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;

View File

@@ -682,4 +682,4 @@ namespace GitHub.Runner.Plugins.Artifact
: base(message, inner) : base(message, inner)
{ } { }
} }
} }

View File

@@ -1,4 +1,4 @@
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using GitHub.Actions.Pipelines.WebApi; using GitHub.Actions.Pipelines.WebApi;
using GitHub.Services.WebApi; using GitHub.Services.WebApi;
@@ -36,7 +36,7 @@ namespace GitHub.Runner.Plugins.Artifact
return await _pipelinesHttpClient.CreateArtifactAsync( return await _pipelinesHttpClient.CreateArtifactAsync(
parameters, parameters,
pipelineId, pipelineId,
runId, runId,
cancellationToken: cancellationToken) as Pipelines.ActionsStorageArtifact; cancellationToken: cancellationToken) as Pipelines.ActionsStorageArtifact;
} }

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@@ -97,8 +97,8 @@ namespace GitHub.Runner.Plugins.Artifact
size, size,
token); token);
context.Output($"Associated artifact {artifactName} ({artifact.ContainerId}) with run #{buildId}"); context.Output($"Associated artifact {artifactName} ({artifact.ContainerId}) with run #{buildId}");
} }
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;

View File

@@ -1,4 +1,4 @@
using Pipelines = GitHub.DistributedTask.Pipelines; using Pipelines = GitHub.DistributedTask.Pipelines;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using GitHub.Runner.Sdk; using GitHub.Runner.Sdk;

View File

@@ -1,4 +1,4 @@
using Pipelines = GitHub.DistributedTask.Pipelines; using Pipelines = GitHub.DistributedTask.Pipelines;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using GitHub.Runner.Sdk; using GitHub.Runner.Sdk;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net.Http.Headers; using System.Net.Http.Headers;
@@ -220,20 +220,12 @@ namespace GitHub.Runner.Sdk
return input; return input;
} }
private Dictionary<string, string> _commandEscapeMappings = new(StringComparer.OrdinalIgnoreCase) private Dictionary<string, string> _commandEscapeMappings = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{ {
{ { ";", "%3B" },
";", "%3B" { "\r", "%0D" },
}, { "\n", "%0A" },
{ { "]", "%5D" },
"\r", "%0D"
},
{
"\n", "%0A"
},
{
"]", "%5D"
},
}; };
} }
} }

View File

@@ -1,4 +1,4 @@
namespace GitHub.Runner.Sdk namespace GitHub.Runner.Sdk
{ {
/*** /***
* WARNING: This file is automatically regenerated on layout so the runner can provide version/commit info (do not manually edit it). * WARNING: This file is automatically regenerated on layout so the runner can provide version/commit info (do not manually edit it).

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net; using System.Net;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.IO; using System.IO;
namespace GitHub.Runner.Sdk namespace GitHub.Runner.Sdk

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;

View File

@@ -1,4 +1,4 @@
using System.IO; using System.IO;
namespace GitHub.Runner.Sdk namespace GitHub.Runner.Sdk
{ {

View File

@@ -1,4 +1,4 @@
using GitHub.Services.WebApi; using GitHub.Services.WebApi;
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Globalization; using System.Globalization;

View File

@@ -1,4 +1,4 @@
using System; using System;
namespace GitHub.Runner.Sdk namespace GitHub.Runner.Sdk
{ {

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@@ -134,7 +134,7 @@ namespace GitHub.Runner.Sdk
{ {
var fileInfo = new FileInfo(path); var fileInfo = new FileInfo(path);
var linkTargetFullPath = fileInfo.Directory?.FullName + Path.DirectorySeparatorChar + fileInfo.LinkTarget; var linkTargetFullPath = fileInfo.Directory?.FullName + Path.DirectorySeparatorChar + fileInfo.LinkTarget;
if(fileInfo.LinkTarget == null || File.Exists(linkTargetFullPath) || File.Exists(fileInfo.LinkTarget)) return true; if (fileInfo.LinkTarget == null || File.Exists(linkTargetFullPath) || File.Exists(fileInfo.LinkTarget)) return true;
trace?.Info($"the target '{fileInfo.LinkTarget}' of the symbolic link '{path}', does not exist"); trace?.Info($"the target '{fileInfo.LinkTarget}' of the symbolic link '{path}', does not exist");
return false; return false;
} }

View File

@@ -36,7 +36,7 @@ namespace RunnerService
catch (Win32Exception ex) catch (Win32Exception ex)
{ {
Console.WriteLine("[ERROR] Unable to create '{0}' event source under 'Application' event log.", RunnerService.EventSourceName); Console.WriteLine("[ERROR] Unable to create '{0}' event source under 'Application' event log.", RunnerService.EventSourceName);
Console.WriteLine("[ERROR] {0}",ex.Message); Console.WriteLine("[ERROR] {0}", ex.Message);
Console.WriteLine("[ERROR] Error Code: {0}", ex.ErrorCode); Console.WriteLine("[ERROR] Error Code: {0}", ex.ErrorCode);
return 1; return 1;
} }

View File

@@ -1,4 +1,4 @@
using GitHub.DistributedTask.Pipelines.ContextData; using GitHub.DistributedTask.Pipelines.ContextData;
using GitHub.DistributedTask.WebApi; using GitHub.DistributedTask.WebApi;
using GitHub.Runner.Worker.Container; using GitHub.Runner.Worker.Container;
using System; using System;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
@@ -317,15 +317,28 @@ namespace GitHub.Runner.Worker
if (action.Reference.Type == Pipelines.ActionSourceType.ContainerRegistry) if (action.Reference.Type == Pipelines.ActionSourceType.ContainerRegistry)
{ {
Trace.Info("Load action that reference container from registry."); if (FeatureManager.IsContainerHooksEnabled(executionContext.Global.Variables))
CachedActionContainers.TryGetValue(action.Id, out var container);
ArgUtil.NotNull(container, nameof(container));
definition.Data.Execution = new ContainerActionExecutionData()
{ {
Image = container.ContainerImage Trace.Info("Load action that will run container through container hooks.");
}; var containerAction = action.Reference as Pipelines.ContainerRegistryReference;
definition.Data.Execution = new ContainerActionExecutionData()
{
Image = containerAction.Image,
};
Trace.Info($"Using action container image: {containerAction.Image}.");
}
else
{
Trace.Info("Load action that reference container from registry.");
CachedActionContainers.TryGetValue(action.Id, out var container);
ArgUtil.NotNull(container, nameof(container));
definition.Data.Execution = new ContainerActionExecutionData()
{
Image = container.ContainerImage
};
Trace.Info($"Using action container image: {container.ContainerImage}."); Trace.Info($"Using action container image: {container.ContainerImage}.");
}
} }
else if (action.Reference.Type == Pipelines.ActionSourceType.Repository) else if (action.Reference.Type == Pipelines.ActionSourceType.Repository)
{ {

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
@@ -448,7 +448,7 @@ namespace GitHub.Runner.Worker
}; };
} }
} }
else if (string.Equals(usingToken.Value, "node12", StringComparison.OrdinalIgnoreCase)|| else if (string.Equals(usingToken.Value, "node12", StringComparison.OrdinalIgnoreCase) ||
string.Equals(usingToken.Value, "node16", StringComparison.OrdinalIgnoreCase)) string.Equals(usingToken.Value, "node16", StringComparison.OrdinalIgnoreCase))
{ {
if (string.IsNullOrEmpty(mainToken?.Value)) if (string.IsNullOrEmpty(mainToken?.Value))

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Runtime.Serialization; using System.Runtime.Serialization;
namespace GitHub.Runner.Worker namespace GitHub.Runner.Worker
@@ -30,4 +30,4 @@ namespace GitHub.Runner.Worker
return $"An action could not be found at the URI '{actionUri}'"; return $"An action could not be found at the URI '{actionUri}'";
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using GitHub.DistributedTask.ObjectTemplating; using GitHub.DistributedTask.ObjectTemplating;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Text; using System.Text;
using GitHub.Runner.Common; using GitHub.Runner.Common;
using GitHub.Runner.Sdk; using GitHub.Runner.Sdk;

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Converters; using Newtonsoft.Json.Converters;
@@ -83,7 +83,7 @@ namespace GitHub.Runner.Worker.Container.ContainerHooks
public HookContainer(ContainerInfo container) public HookContainer(ContainerInfo container)
{ {
Image = container.ContainerImage; 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; EntryPoint = container.ContainerEntryPoint;
WorkingDirectory = container.ContainerWorkDirectory; WorkingDirectory = container.ContainerWorkDirectory;
CreateOptions = container.ContainerCreateOptions; CreateOptions = container.ContainerCreateOptions;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;

View File

@@ -96,7 +96,7 @@ namespace GitHub.Runner.Worker.Container
// https://docs.microsoft.com/en-us/dotnet/api/system.environment.getcommandlineargs?redirectedfrom=MSDN&view=net-6.0#remarks // https://docs.microsoft.com/en-us/dotnet/api/system.environment.getcommandlineargs?redirectedfrom=MSDN&view=net-6.0#remarks
// First, find any \ followed by a " and double the number of \ + 1. // First, find any \ followed by a " and double the number of \ + 1.
value = QuoteEscape.Replace(value, @"$1$1\" + "\""); value = QuoteEscape.Replace(value, @"$1$1\" + "\"");
// Next, what if it ends in `\`, it would escape the end quote. So, we need to detect that at the end of the string and perform the same escape // Next, what if it ends in `\`, it would escape the end quote. So, we need to detect that at the end of the string and perform the same escape
// Luckily, we can just use the $ character with detects the end of string in regex // Luckily, we can just use the $ character with detects the end of string in regex
value = EndOfStringEscape.Replace(value, @"$1$1"); value = EndOfStringEscape.Replace(value, @"$1$1");

View File

@@ -32,7 +32,7 @@ namespace GitHub.Runner.Worker
{ {
private static string DateTimeFormat = "yyyyMMdd-HHmmss"; private static string DateTimeFormat = "yyyyMMdd-HHmmss";
public void UploadDiagnosticLogs(IExecutionContext executionContext, public void UploadDiagnosticLogs(IExecutionContext executionContext,
IExecutionContext parentContext, IExecutionContext parentContext,
Pipelines.AgentJobRequestMessage message, Pipelines.AgentJobRequestMessage message,
DateTime jobStartTimeUtc) DateTime jobStartTimeUtc)
{ {

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.IO; using System.IO;
using GitHub.DistributedTask.Expressions2.Sdk; using GitHub.DistributedTask.Expressions2.Sdk;
using GitHub.DistributedTask.Pipelines.ContextData; using GitHub.DistributedTask.Pipelines.ContextData;
@@ -136,4 +136,4 @@ namespace GitHub.Runner.Worker.Expressions
} }
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using GitHub.DistributedTask.WebApi; using GitHub.DistributedTask.WebApi;
using GitHub.Runner.Worker.Container; using GitHub.Runner.Worker.Container;
using GitHub.Runner.Common; using GitHub.Runner.Common;
using System; using System;
@@ -281,7 +281,7 @@ namespace GitHub.Runner.Worker
} }
} }
public sealed class EnvFileKeyValuePairs: IEnumerable<KeyValuePair<string, string>> public sealed class EnvFileKeyValuePairs : IEnumerable<KeyValuePair<string, string>>
{ {
private IExecutionContext _context; private IExecutionContext _context;
private string _filePath; private string _filePath;

View File

@@ -1,4 +1,4 @@
using GitHub.DistributedTask.Pipelines.ContextData; using GitHub.DistributedTask.Pipelines.ContextData;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using GitHub.Actions.RunService.WebApi; using GitHub.Actions.RunService.WebApi;
using GitHub.DistributedTask.WebApi; using GitHub.DistributedTask.WebApi;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@@ -36,7 +36,7 @@ namespace GitHub.Runner.Worker.Handlers
protected IActionCommandManager ActionCommandManager { get; private set; } protected IActionCommandManager ActionCommandManager { get; private set; }
public Pipelines.ActionStepDefinitionReference Action { get; set; } public Pipelines.ActionStepDefinitionReference Action { get; set; }
public bool IsActionStep => Action != null; public bool IsActionStep => Action != null;
public Dictionary<string, string> Environment { get; set; } public Dictionary<string, string> Environment { get; set; }
public Variables RuntimeVariables { get; set; } public Variables RuntimeVariables { get; set; }
public IExecutionContext ExecutionContext { get; set; } public IExecutionContext ExecutionContext { get; set; }

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;

View File

@@ -1,4 +1,4 @@

using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
public interface IEnvironmentContextData public interface IEnvironmentContextData
{ {

Some files were not shown because too many files have changed in this diff Show More