mirror of
https://github.com/actions/runner.git
synced 2025-12-13 19:03:44 +00:00
First pass (#221)
This commit is contained in:
@@ -276,9 +276,7 @@ namespace GitHub.Runner.Worker.Container
|
|||||||
return await ExecuteDockerCommandAsync(context, "exec", $"{options} {containerId} {command}", context.CancellationToken);
|
return await ExecuteDockerCommandAsync(context, "exec", $"{options} {containerId} {command}", context.CancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously (method has async logic on only certain platforms)
|
|
||||||
public async Task<int> DockerExec(IExecutionContext context, string containerId, string options, string command, List<string> output)
|
public async Task<int> DockerExec(IExecutionContext context, string containerId, string options, string command, List<string> output)
|
||||||
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
|
|
||||||
{
|
{
|
||||||
ArgUtil.NotNull(output, nameof(output));
|
ArgUtil.NotNull(output, nameof(output));
|
||||||
|
|
||||||
@@ -309,9 +307,10 @@ namespace GitHub.Runner.Worker.Container
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#if OS_WINDOWS || OS_OSX
|
if (!Constants.Runner.Platform.Equals(Constants.OSPlatform.Linux))
|
||||||
throw new NotSupportedException($"Container operation is only supported on Linux");
|
{
|
||||||
#else
|
throw new NotSupportedException("Container operations are only supported on Linux runners");
|
||||||
|
}
|
||||||
return await processInvoker.ExecuteAsync(
|
return await processInvoker.ExecuteAsync(
|
||||||
workingDirectory: HostContext.GetDirectory(WellKnownDirectory.Work),
|
workingDirectory: HostContext.GetDirectory(WellKnownDirectory.Work),
|
||||||
fileName: DockerPath,
|
fileName: DockerPath,
|
||||||
@@ -320,7 +319,6 @@ namespace GitHub.Runner.Worker.Container
|
|||||||
requireExitCodeZero: false,
|
requireExitCodeZero: false,
|
||||||
outputEncoding: null,
|
outputEncoding: null,
|
||||||
cancellationToken: CancellationToken.None);
|
cancellationToken: CancellationToken.None);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<string>> DockerInspect(IExecutionContext context, string dockerObject, string options)
|
public async Task<List<string>> DockerInspect(IExecutionContext context, string dockerObject, string options)
|
||||||
@@ -339,9 +337,7 @@ namespace GitHub.Runner.Worker.Container
|
|||||||
return ExecuteDockerCommandAsync(context, command, options, null, cancellationToken);
|
return ExecuteDockerCommandAsync(context, command, options, null, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously (method has async logic on only certain platforms)
|
|
||||||
private async Task<int> ExecuteDockerCommandAsync(IExecutionContext context, string command, string options, IDictionary<string, string> environment, EventHandler<ProcessDataReceivedEventArgs> stdoutDataReceived, EventHandler<ProcessDataReceivedEventArgs> stderrDataReceived, CancellationToken cancellationToken = default(CancellationToken))
|
private async Task<int> ExecuteDockerCommandAsync(IExecutionContext context, string command, string options, IDictionary<string, string> environment, EventHandler<ProcessDataReceivedEventArgs> stdoutDataReceived, EventHandler<ProcessDataReceivedEventArgs> stderrDataReceived, CancellationToken cancellationToken = default(CancellationToken))
|
||||||
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
|
|
||||||
{
|
{
|
||||||
string arg = $"{command} {options}".Trim();
|
string arg = $"{command} {options}".Trim();
|
||||||
context.Command($"{DockerPath} {arg}");
|
context.Command($"{DockerPath} {arg}");
|
||||||
@@ -351,9 +347,10 @@ namespace GitHub.Runner.Worker.Container
|
|||||||
processInvoker.ErrorDataReceived += stderrDataReceived;
|
processInvoker.ErrorDataReceived += stderrDataReceived;
|
||||||
|
|
||||||
|
|
||||||
#if OS_WINDOWS || OS_OSX
|
if (!Constants.Runner.Platform.Equals(Constants.OSPlatform.Linux))
|
||||||
throw new NotSupportedException($"Container operation is only supported on Linux");
|
{
|
||||||
#else
|
throw new NotSupportedException("Container operations are only supported on Linux runners");
|
||||||
|
}
|
||||||
return await processInvoker.ExecuteAsync(
|
return await processInvoker.ExecuteAsync(
|
||||||
workingDirectory: context.GetGitHubContext("workspace"),
|
workingDirectory: context.GetGitHubContext("workspace"),
|
||||||
fileName: DockerPath,
|
fileName: DockerPath,
|
||||||
@@ -363,12 +360,9 @@ namespace GitHub.Runner.Worker.Container
|
|||||||
outputEncoding: null,
|
outputEncoding: null,
|
||||||
killProcessOnCancel: false,
|
killProcessOnCancel: false,
|
||||||
cancellationToken: cancellationToken);
|
cancellationToken: cancellationToken);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously (method has async logic on only certain platforms)
|
|
||||||
private async Task<int> ExecuteDockerCommandAsync(IExecutionContext context, string command, string options, string workingDirectory, CancellationToken cancellationToken = default(CancellationToken))
|
private async Task<int> ExecuteDockerCommandAsync(IExecutionContext context, string command, string options, string workingDirectory, CancellationToken cancellationToken = default(CancellationToken))
|
||||||
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
|
|
||||||
{
|
{
|
||||||
string arg = $"{command} {options}".Trim();
|
string arg = $"{command} {options}".Trim();
|
||||||
context.Command($"{DockerPath} {arg}");
|
context.Command($"{DockerPath} {arg}");
|
||||||
@@ -384,9 +378,10 @@ namespace GitHub.Runner.Worker.Container
|
|||||||
context.Output(message.Data);
|
context.Output(message.Data);
|
||||||
};
|
};
|
||||||
|
|
||||||
#if OS_WINDOWS || OS_OSX
|
if (!Constants.Runner.Platform.Equals(Constants.OSPlatform.Linux))
|
||||||
throw new NotSupportedException($"Container operation is only supported on Linux");
|
{
|
||||||
#else
|
throw new NotSupportedException("Container operations are only supported on Linux runners");
|
||||||
|
}
|
||||||
return await processInvoker.ExecuteAsync(
|
return await processInvoker.ExecuteAsync(
|
||||||
workingDirectory: workingDirectory ?? context.GetGitHubContext("workspace"),
|
workingDirectory: workingDirectory ?? context.GetGitHubContext("workspace"),
|
||||||
fileName: DockerPath,
|
fileName: DockerPath,
|
||||||
@@ -397,7 +392,6 @@ namespace GitHub.Runner.Worker.Container
|
|||||||
killProcessOnCancel: false,
|
killProcessOnCancel: false,
|
||||||
redirectStandardIn: null,
|
redirectStandardIn: null,
|
||||||
cancellationToken: cancellationToken);
|
cancellationToken: cancellationToken);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<List<string>> ExecuteDockerCommandAsync(IExecutionContext context, string command, string options)
|
private async Task<List<string>> ExecuteDockerCommandAsync(IExecutionContext context, string command, string options)
|
||||||
|
|||||||
@@ -35,6 +35,10 @@ namespace GitHub.Runner.Worker
|
|||||||
public async Task StartContainersAsync(IExecutionContext executionContext, object data)
|
public async Task StartContainersAsync(IExecutionContext executionContext, object data)
|
||||||
{
|
{
|
||||||
Trace.Entering();
|
Trace.Entering();
|
||||||
|
if (!Constants.Runner.Platform.Equals(Constants.OSPlatform.Linux))
|
||||||
|
{
|
||||||
|
throw new NotSupportedException("Container operations are only supported on Linux runners");
|
||||||
|
}
|
||||||
ArgUtil.NotNull(executionContext, nameof(executionContext));
|
ArgUtil.NotNull(executionContext, nameof(executionContext));
|
||||||
List<ContainerInfo> containers = data as List<ContainerInfo>;
|
List<ContainerInfo> containers = data as List<ContainerInfo>;
|
||||||
ArgUtil.NotNull(containers, nameof(containers));
|
ArgUtil.NotNull(containers, nameof(containers));
|
||||||
|
|||||||
@@ -141,6 +141,13 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
executionContext.Debug(line);
|
executionContext.Debug(line);
|
||||||
if (line.ToLower().Contains("alpine"))
|
if (line.ToLower().Contains("alpine"))
|
||||||
{
|
{
|
||||||
|
if (!Constants.Runner.PlatformArchitecture.Equals(Constants.Architecture.X64))
|
||||||
|
{
|
||||||
|
var os = Constants.Runner.Platform.ToString();
|
||||||
|
var arch = Constants.Runner.PlatformArchitecture.ToString();
|
||||||
|
var msg = $"JavaScript Actions in Alpine containers are only supported on x64 Linux runners. Detected {os} {arch}";
|
||||||
|
throw new NotSupportedException(msg);
|
||||||
|
}
|
||||||
nodeExternal = "node12_alpine";
|
nodeExternal = "node12_alpine";
|
||||||
executionContext.Output($"Container distribution is alpine. Running JavaScript Action with external tool: {nodeExternal}");
|
executionContext.Output($"Container distribution is alpine. Running JavaScript Action with external tool: {nodeExternal}");
|
||||||
return nodeExternal;
|
return nodeExternal;
|
||||||
|
|||||||
Reference in New Issue
Block a user