Compare commits

...

6 Commits

Author SHA1 Message Date
Ferenc Hammerl
dac4363206 Update releaseVersion 2022-04-29 13:53:22 +02:00
Ferenc Hammerl
7ba4f8587e 2.291.0 Release Notes (#1854)
* Update releaseNote.md

* Update runnerversion

* Update releaseNote.md

Co-authored-by: Thomas Boop <52323235+thboop@users.noreply.github.com>

Co-authored-by: Thomas Boop <52323235+thboop@users.noreply.github.com>
2022-04-29 12:53:36 +02:00
ruvceskistefan
88f7c56757 Issue 1528: use OS specific path separator (#1617)
* Issue 1528: use OS specific path separator

* Using Path.Combine instead of OS specific c_defaultPathSeparator
2022-04-27 22:16:03 -04:00
Nikola Jokic
20b7e86e47 Added ability to run Dockerfile.SUFFIX ContainerAction (#1738)
* Added ability to run Dockerfile.SUFFIX ContainerAction

* Extracted IsDockerFile method

* reformatted, moved from index to Last()

* extracted IsDockerfile to DockerUtil with L0

* added check for IsDockerfile to account for docker://

* updated test to clearly show path/dockerfile:tag

* fail if Data.Image is not Dockerfile or docker://[image]
2022-04-27 21:23:12 -04:00
Tingluo Huang
bd5f275830 Update runnerversion to match latest release. 2022-04-26 09:54:42 -04:00
Yang Cao
a7aadf5615 Update Actions Summary limit to 1MiB (#1839)
* Update Actions Summary limit to 1MiB

* Making limit a public const so other part of the codebase is aware of the limit too
2022-04-20 17:08:50 -04:00
10 changed files with 76 additions and 26 deletions

View File

@@ -1,18 +1,12 @@
## Features ## Features
- Continue-on-error is now possible for the composite action steps (#1763) - Relaxed naming requirements for dockerfiles (e.g. `Dockerfile.test` can now be built) (#1738)
- Now it's possible to use context evaluation in the `shell` of composite action run steps (#1767)
## Bugs ## Bugs
- Fix a bug where job would be marked as 'cancelled' after self-hosted runner going offline (#1792) - Fixed a bug where windows path separators were used in generated folders (#1617)
- Translate paths in `github` and `runner` contexts when running on a container (#1762) - Fixed an issue where runner's invoked via `run.sh` or `run.cmd` did not properly restart after update (#1812). This fix applies to all future updates after installing this version
- Warn about invalid flags when configuring or running the runner (#1781)
- Fix a bug where job hooks would use job level working directory (#1809)
## Misc ## Misc
- Allow warnings about actions using Node v12 (#1735) - Relaxed Actions Summary size limit to 1MiB (#1839)
- Better exception handling when runner is configured with invalid Url or token (#1741)
- Set user agent for websocket requests (#1791)
- Gracefully handle websocket failures (#1789)
## Windows x64 ## Windows x64
We recommend configuring the runner in a root folder of the Windows drive (e.g. "C:\actions-runner"). This will help avoid issues related to service identity folder permissions and long file path restrictions on Windows. We recommend configuring the runner in a root folder of the Windows drive (e.g. "C:\actions-runner"). This will help avoid issues related to service identity folder permissions and long file path restrictions on Windows.

View File

@@ -1 +1 @@
<Update to ./src/runnerversion when creating release> 2.291.0

View File

@@ -1004,7 +1004,7 @@ namespace GitHub.Runner.Worker
if (actionDefinitionData.Execution.ExecutionType == ActionExecutionType.Container) if (actionDefinitionData.Execution.ExecutionType == ActionExecutionType.Container)
{ {
var containerAction = actionDefinitionData.Execution as ContainerActionExecutionData; var containerAction = actionDefinitionData.Execution as ContainerActionExecutionData;
if (containerAction.Image.EndsWith("Dockerfile") || containerAction.Image.EndsWith("dockerfile")) if (DockerUtil.IsDockerfile(containerAction.Image))
{ {
var dockerFileFullPath = Path.Combine(actionEntryDirectory, containerAction.Image); var dockerFileFullPath = Path.Combine(actionEntryDirectory, containerAction.Image);
executionContext.Debug($"Dockerfile for action: '{dockerFileFullPath}'."); executionContext.Debug($"Dockerfile for action: '{dockerFileFullPath}'.");

View File

@@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace GitHub.Runner.Worker.Container namespace GitHub.Runner.Worker.Container
@@ -17,7 +18,7 @@ namespace GitHub.Runner.Worker.Container
string pattern = $"^(?<{targetPort}>\\d+)/(?<{proto}>\\w+) -> (?<{host}>.+):(?<{hostPort}>\\d+)$"; string pattern = $"^(?<{targetPort}>\\d+)/(?<{proto}>\\w+) -> (?<{host}>.+):(?<{hostPort}>\\d+)$";
List<PortMapping> portMappings = new List<PortMapping>(); List<PortMapping> portMappings = new List<PortMapping>();
foreach(var line in portMappingLines) foreach (var line in portMappingLines)
{ {
Match m = Regex.Match(line, pattern, RegexOptions.None, TimeSpan.FromSeconds(1)); Match m = Regex.Match(line, pattern, RegexOptions.None, TimeSpan.FromSeconds(1));
if (m.Success) if (m.Success)
@@ -61,5 +62,15 @@ namespace GitHub.Runner.Worker.Container
} }
return ""; return "";
} }
public static bool IsDockerfile(string image)
{
if (image.StartsWith("docker://", StringComparison.OrdinalIgnoreCase))
{
return false;
}
var imageWithoutPath = image.Split('/').Last();
return imageWithoutPath.StartsWith("Dockerfile.") || imageWithoutPath.StartsWith("dockerfile.") || imageWithoutPath.EndsWith("Dockerfile") || imageWithoutPath.EndsWith("dockerfile");
}
} }
} }

View File

@@ -266,7 +266,7 @@ namespace GitHub.Runner.Worker
public sealed class CreateStepSummaryCommand : RunnerService, IFileCommandExtension public sealed class CreateStepSummaryCommand : RunnerService, IFileCommandExtension
{ {
private const int _attachmentSizeLimit = 128 * 1024; public const int AttachmentSizeLimit = 1024 * 1024;
public string ContextName => "step_summary"; public string ContextName => "step_summary";
public string FilePrefix => "step_summary_"; public string FilePrefix => "step_summary_";
@@ -296,9 +296,9 @@ namespace GitHub.Runner.Worker
return; return;
} }
if (fileSize > _attachmentSizeLimit) if (fileSize > AttachmentSizeLimit)
{ {
context.Error(String.Format(Constants.Runner.UnsupportedSummarySize, _attachmentSizeLimit / 1024, fileSize / 1024)); context.Error(String.Format(Constants.Runner.UnsupportedSummarySize, AttachmentSizeLimit / 1024, fileSize / 1024));
Trace.Info($"Step Summary file ({filePath}) is too large ({fileSize} bytes); skipping attachment upload"); Trace.Info($"Step Summary file ({filePath}) is too large ({fileSize} bytes); skipping attachment upload");
return; return;

View File

@@ -44,9 +44,8 @@ namespace GitHub.Runner.Worker.Handlers
{ {
Data.Image = Data.Image.Substring("docker://".Length); Data.Image = Data.Image.Substring("docker://".Length);
} }
else if (Data.Image.EndsWith("Dockerfile") || Data.Image.EndsWith("dockerfile")) else if (DockerUtil.IsDockerfile(Data.Image))
{ {
// ensure docker file exist
var dockerFile = Path.Combine(ActionDirectory, Data.Image); var dockerFile = Path.Combine(ActionDirectory, Data.Image);
ArgUtil.File(dockerFile, nameof(Data.Image)); ArgUtil.File(dockerFile, nameof(Data.Image));
@@ -68,6 +67,10 @@ namespace GitHub.Runner.Worker.Handlers
Data.Image = imageName; Data.Image = imageName;
} }
else
{
throw new InvalidOperationException($"'{Data.Image}' should be either '[path]/Dockerfile' or 'docker://image[:tag]'.");
}
string type = Action.Type == Pipelines.ActionSourceType.Repository ? "Dockerfile" : "DockerHub"; string type = Action.Type == Pipelines.ActionSourceType.Repository ? "Dockerfile" : "DockerHub";
// Set extra telemetry base on the current context. // Set extra telemetry base on the current context.

View File

@@ -23,7 +23,6 @@ namespace GitHub.Services.Common.ClientStorage
private readonly string m_filePath; private readonly string m_filePath;
private readonly VssFileStorageReader m_reader; private readonly VssFileStorageReader m_reader;
private readonly IVssClientStorageWriter m_writer; private readonly IVssClientStorageWriter m_writer;
private const char c_defaultPathSeparator = '\\'; private const char c_defaultPathSeparator = '\\';
private const bool c_defaultIgnoreCaseInPaths = false; private const bool c_defaultIgnoreCaseInPaths = false;
@@ -192,7 +191,7 @@ namespace GitHub.Services.Common.ClientStorage
// Windows Impersonation is being used. // Windows Impersonation is being used.
// Check to see if we can find the user's local application data directory. // Check to see if we can find the user's local application data directory.
string subDir = "GitHub\\ActionsService"; string subDir = Path.Combine("GitHub", "ActionsService");
string path = Environment.GetEnvironmentVariable("localappdata"); string path = Environment.GetEnvironmentVariable("localappdata");
SafeGetFolderPath(Environment.SpecialFolder.LocalApplicationData); SafeGetFolderPath(Environment.SpecialFolder.LocalApplicationData);
if (string.IsNullOrEmpty(path)) if (string.IsNullOrEmpty(path))

View File

@@ -144,5 +144,48 @@ namespace GitHub.Runner.Common.Tests.Worker.Container
var actual = DockerUtil.ParseRegistryHostnameFromImageName(input); var actual = DockerUtil.ParseRegistryHostnameFromImageName(input);
Assert.Equal(expected, actual); Assert.Equal(expected, actual);
} }
[Theory]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]
[InlineData("dockerhub/repo", false)]
[InlineData("debian:latest", false)]
[InlineData("something/dockerfileimage", false)]
[InlineData("ghcr.io/docker/dockerfile", true)] // should be false but might break the current workflows
[InlineData("Dockerfile", true)]
[InlineData("Dockerfile.", true)]
[InlineData(".Dockerfile", true)]
[InlineData(".Dockerfile.", false)]
[InlineData("dockerfile", true)]
[InlineData("dockerfile.", true)]
[InlineData(".dockerfile", true)]
[InlineData(".dockerfile.", false)]
[InlineData("Dockerfile.test", true)]
[InlineData("test.Dockerfile", true)]
[InlineData("docker/dockerfile:latest", false)]
[InlineData("/some/path/dockerfile:latest", false)]
[InlineData("dockerfile:latest", false)]
[InlineData("Dockerfile:latest", false)]
[InlineData("dockerfile-latest", false)]
[InlineData("Dockerfile-latest", false)]
[InlineData("dockerfile.latest", true)]
[InlineData("Dockerfile.latest", true)]
[InlineData("../dockerfile/dockerfileone", false)]
[InlineData("../Dockerfile/dockerfileone", false)]
[InlineData("../dockerfile.test", true)]
[InlineData("../Dockerfile.test", true)]
[InlineData("./dockerfile/image", false)]
[InlineData("./Dockerfile/image", false)]
[InlineData("example/Dockerfile.test", true)]
[InlineData("./example/Dockerfile.test", true)]
[InlineData("example/test.dockerfile", true)]
[InlineData("./example/test.dockerfile", true)]
[InlineData("docker://Dockerfile", false)]
[InlineData("docker://ubuntu:latest", false)]
public void IsDockerfile(string input, bool expected)
{
var actual = DockerUtil.IsDockerfile(input);
Assert.Equal(expected, actual);
}
} }
} }

View File

@@ -117,7 +117,7 @@ namespace GitHub.Runner.Common.Tests.Worker
using (var hostContext = Setup()) using (var hostContext = Setup())
{ {
var stepSummaryFile = Path.Combine(_rootDirectory, "empty-file"); var stepSummaryFile = Path.Combine(_rootDirectory, "empty-file");
File.WriteAllBytes(stepSummaryFile, new byte[128 * 1024 + 1]); File.WriteAllBytes(stepSummaryFile, new byte[CreateStepSummaryCommand.AttachmentSizeLimit + 1]);
_createStepCommand.ProcessCommand(_executionContext.Object, stepSummaryFile, null); _createStepCommand.ProcessCommand(_executionContext.Object, stepSummaryFile, null);
_jobExecutionContext.Complete(); _jobExecutionContext.Complete();

View File

@@ -1 +1 @@
2.290.0 2.291.0