mirror of
https://github.com/actions/runner.git
synced 2025-12-10 12:36:23 +00:00
Compare commits
13 Commits
fhammerl/f
...
v2.288.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e95a2b840b | ||
|
|
d6af5b2955 | ||
|
|
bdf1e90503 | ||
|
|
100c99f263 | ||
|
|
e8ccafea63 | ||
|
|
02d2cb8fcd | ||
|
|
0cbf3351f4 | ||
|
|
6abef8199f | ||
|
|
ec9830836b | ||
|
|
460c32a337 | ||
|
|
934027da60 | ||
|
|
28f0027938 | ||
|
|
17153c9b29 |
14
.github/workflows/build.yml
vendored
14
.github/workflows/build.yml
vendored
@@ -50,13 +50,6 @@ jobs:
|
||||
${{ matrix.devScript }} layout Release ${{ matrix.runtime }}
|
||||
working-directory: src
|
||||
|
||||
# Run tests
|
||||
- name: L0
|
||||
run: |
|
||||
${{ matrix.devScript }} test
|
||||
working-directory: src
|
||||
if: matrix.runtime != 'linux-arm64' && matrix.runtime != 'linux-arm'
|
||||
|
||||
# Check runtime/externals hash
|
||||
- name: Compute/Compare runtime and externals Hash
|
||||
shell: bash
|
||||
@@ -80,6 +73,13 @@ jobs:
|
||||
DOTNET_RUNTIME_HASH: ${{hashFiles('**/_layout_trims/runtime/**/*')}}
|
||||
EXTERNALS_HASH: ${{hashFiles('**/_layout_trims/externals/**/*')}}
|
||||
|
||||
# Run tests
|
||||
- name: L0
|
||||
run: |
|
||||
${{ matrix.devScript }} test
|
||||
working-directory: src
|
||||
if: matrix.runtime != 'linux-arm64' && matrix.runtime != 'linux-arm'
|
||||
|
||||
# Create runner package tar.gz/zip
|
||||
- name: Package Release
|
||||
if: github.event_name != 'pull_request'
|
||||
|
||||
@@ -1,20 +1,32 @@
|
||||
## Features
|
||||
|
||||
- Add Runner Configuration option to disable auto update `--disableupdate` (#1558)
|
||||
- Introduce `GITHUB_ACTIONS_RUNNER_TLS_NO_VERIFY` env variable to skip SSL Cert Verification on the Runner (#1616)
|
||||
- Adds support for downloading trimmed versions of the runner when the entire package does not need to be upgraded (#1568)
|
||||
- Make run.sh|cmd handle update without quitting so containers using them as entrypoints don't exit on update (#1646, #1633, #1708)
|
||||
- Add support for Step Summary (#1642, #1667, #1712)
|
||||
- Pass jobId to the actionsDownloadInfo controller (#1639)
|
||||
- updated systemd svc.sh to accept custom service file (#1612)
|
||||
- Add ability to specify runner group when creating service (#1675)
|
||||
- Prefer node16 over node12 when running internal scripts (#1621)
|
||||
- Sending telemetry about actions usage. (#1688)
|
||||
- Bump node12 version to latest (#1651)
|
||||
- Add internal to node version function and use better env var name (#1715)
|
||||
- Force JS Actions Node version to 16 if FF is on unless user opted out (#1716)
|
||||
|
||||
## Bugs
|
||||
- Set Outcome/Conclusion for composite action steps (#1600)
|
||||
- Fix windows console runner update crash (#1670)
|
||||
- Retry policy for methods GetTenantCredential and GetJITRunnerTokenAsync (#1691)
|
||||
- Skip DeleteAgentSession when the acess token has been revoked. (#1692)
|
||||
- Repaired hashFiles call so if error was thrown, it was returned to process invoker (#1678)
|
||||
- Runner throws null ref exception when new line after EOF is missing (#1687)
|
||||
- Lets allow up to 150 characters for services on linux/mac (#1710)
|
||||
|
||||
## Misc
|
||||
|
||||
- Update `run.sh` to more gracefully handle updates (#1494)
|
||||
- Use 8Mb default chunking for File Container Uploads (#1626)
|
||||
- Performance improvements in handling large amounts of live logs (#1592)
|
||||
- Allow `./svc.sh stop` to exit as soon as runner process exits (#1580)
|
||||
- Add additional tracing to help troubleshoot job message corruption (#1587)
|
||||
|
||||
- Added examples and aligned language within docs/checks/actions.md (#1664)
|
||||
- Problem with debugging on macOS M1 (#1625)
|
||||
- Fix typo in hashFiles.ts. (#1672)
|
||||
- Allow mocked updates for E2E testing (#1654)
|
||||
- Move JobTelemetry and StepsTelemetry into GlobalContext. (#1680)
|
||||
- Fix inconsistency of outputs (both canceled and cancelled are used (#1624)
|
||||
|
||||
## 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.
|
||||
|
||||
@@ -1 +1 @@
|
||||
<Update to ./src/runnerversion when creating release>
|
||||
2.288.1
|
||||
|
||||
2
src/Misc/contentHash/externals/linux-arm
vendored
2
src/Misc/contentHash/externals/linux-arm
vendored
@@ -1 +1 @@
|
||||
6ca4a0e1c50b7079ead05321dcf5835c1c25f23dc632add8c1c4667d416d103e
|
||||
6ed30a2c1ee403a610d63e82bb230b9ba846a9c25cec9e4ea8672fb6ed4e1a51
|
||||
2
src/Misc/contentHash/externals/linux-arm64
vendored
2
src/Misc/contentHash/externals/linux-arm64
vendored
@@ -1 +1 @@
|
||||
b5951dc607d782d9c7571a7224e940eb0975bb23c54ff25c7afdbf959a417081
|
||||
711c30c51ec52c9b7a9a2eb399d6ab2ab5ee1dc72de11879f2f36f919f163d78
|
||||
2
src/Misc/contentHash/externals/linux-x64
vendored
2
src/Misc/contentHash/externals/linux-x64
vendored
@@ -1 +1 @@
|
||||
af819e92011cc9cbca90e8299f9f7651f2cf6bf45b42920f9a4ca22795486147
|
||||
a49479ca4b4988a06c097e8d22c51fd08a11c13f40807366236213d0e008cf6a
|
||||
2
src/Misc/contentHash/externals/osx-x64
vendored
2
src/Misc/contentHash/externals/osx-x64
vendored
@@ -1 +1 @@
|
||||
aa0e6bf4bfaabf48c962ea3b262dca042629ab332005f73d282faec908847036
|
||||
8e97df75230b843462a9b4c578ccec604ee4b4a1066120c85b04374317fa372b
|
||||
2
src/Misc/contentHash/externals/win-x64
vendored
2
src/Misc/contentHash/externals/win-x64
vendored
@@ -1 +1 @@
|
||||
40328cff2b8229f9b578f32739183bd8f6aab481c21dadc052b09f1c7e8e4665
|
||||
f75a671e5a188c76680739689aa75331a2c09d483dce9c80023518c48fd67a18
|
||||
@@ -53,3 +53,11 @@ async function run(): Promise<void> {
|
||||
}
|
||||
|
||||
run()
|
||||
.then(out => {
|
||||
console.log(out)
|
||||
process.exit(0)
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
@@ -3,7 +3,7 @@ PACKAGERUNTIME=$1
|
||||
PRECACHE=$2
|
||||
|
||||
NODE_URL=https://nodejs.org/dist
|
||||
NODE12_VERSION="12.13.1"
|
||||
NODE12_VERSION="12.22.7"
|
||||
NODE16_VERSION="16.13.0"
|
||||
|
||||
get_abs_path() {
|
||||
@@ -143,7 +143,7 @@ fi
|
||||
# Download the external tools for Linux PACKAGERUNTIMEs.
|
||||
if [[ "$PACKAGERUNTIME" == "linux-x64" ]]; then
|
||||
acquireExternalTool "$NODE_URL/v${NODE12_VERSION}/node-v${NODE12_VERSION}-linux-x64.tar.gz" node12 fix_nested_dir
|
||||
acquireExternalTool "https://vstsagenttools.blob.core.windows.net/tools/nodejs/${NODE12_VERSION}/alpine/x64/node-${NODE12_VERSION}-alpine-x64.tar.gz" node12_alpine
|
||||
acquireExternalTool "https://vstsagenttools.blob.core.windows.net/tools/nodejs/${NODE12_VERSION}/alpine/x64/node-v${NODE12_VERSION}-alpine-x64.tar.gz" node12_alpine
|
||||
acquireExternalTool "$NODE_URL/v${NODE16_VERSION}/node-v${NODE16_VERSION}-linux-x64.tar.gz" node16 fix_nested_dir
|
||||
acquireExternalTool "https://vstsagenttools.blob.core.windows.net/tools/nodejs/${NODE16_VERSION}/alpine/x64/node-v${NODE16_VERSION}-alpine-x64.tar.gz" node16_alpine
|
||||
fi
|
||||
|
||||
@@ -1621,7 +1621,15 @@ function run() {
|
||||
}
|
||||
});
|
||||
}
|
||||
run();
|
||||
run()
|
||||
.then(out => {
|
||||
console.log(out);
|
||||
process.exit(0);
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
@@ -45,17 +45,17 @@ elif [[ $returnCode == 1 ]]; then
|
||||
elif [[ $returnCode == 2 ]]; then
|
||||
echo "Runner listener exit with retryable error, re-launch runner in 5 seconds."
|
||||
safe_sleep
|
||||
exit 1
|
||||
exit 2
|
||||
elif [[ $returnCode == 3 ]]; then
|
||||
# Sleep 5 seconds to wait for the runner update process finish
|
||||
echo "Runner listener exit because of updating, re-launch runner in 5 seconds"
|
||||
safe_sleep
|
||||
exit 1
|
||||
exit 2
|
||||
elif [[ $returnCode == 4 ]]; then
|
||||
# Sleep 5 seconds to wait for the ephemeral runner update process finish
|
||||
echo "Runner listener exit because of updating, re-launch ephemeral runner in 5 seconds"
|
||||
safe_sleep
|
||||
exit 1
|
||||
exit 2
|
||||
else
|
||||
echo "Exiting with unknown error code: ${returnCode}"
|
||||
exit 0
|
||||
|
||||
@@ -15,7 +15,7 @@ while :;
|
||||
do
|
||||
"$DIR"/run-helper.sh $*
|
||||
returnCode=$?
|
||||
if [[ $returnCode == 1 ]]; then
|
||||
if [[ $returnCode -eq 2 ]]; then
|
||||
echo "Restarting runner..."
|
||||
else
|
||||
echo "Exiting runner..."
|
||||
|
||||
@@ -156,7 +156,8 @@ namespace GitHub.Runner.Common
|
||||
public static readonly string LowDiskSpace = "LOW_DISK_SPACE";
|
||||
public static readonly string UnsupportedCommand = "UNSUPPORTED_COMMAND";
|
||||
public static readonly string UnsupportedCommandMessageDisabled = "The `{0}` command is disabled. Please upgrade to using Environment Files or opt into unsecure command execution by setting the `ACTIONS_ALLOW_UNSECURE_COMMANDS` environment variable to `true`. For more information see: https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/";
|
||||
public static readonly string UnsupportedStopCommandTokenDisabled = "You cannot use a endToken that is an empty string, the string 'pause-logging', or another workflow command. For more information see: https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#example-stopping-and-starting-workflow-commands or opt into insecure command execution by setting the `ACTIONS_ALLOW_UNSECURE_STOPCOMMAND_TOKENS` environment variable to `true`.";
|
||||
public static readonly string UnsupportedStopCommandTokenDisabled = "You cannot use a endToken that is an empty string, the string 'pause-logging', or another workflow command. For more information see: https://docs.github.com/actions/learn-github-actions/workflow-commands-for-github-actions#example-stopping-and-starting-workflow-commands or opt into insecure command execution by setting the `ACTIONS_ALLOW_UNSECURE_STOPCOMMAND_TOKENS` environment variable to `true`.";
|
||||
public static readonly string UnsupportedSummarySize = "$GITHUB_STEP_SUMMARY upload aborted, supports content up to a size of {0}k, got {1}k. For more information see: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-markdown-summary";
|
||||
}
|
||||
|
||||
public static class RunnerEvent
|
||||
@@ -219,14 +220,15 @@ namespace GitHub.Runner.Common
|
||||
public static readonly string AllowUnsupportedStopCommandTokens = "ACTIONS_ALLOW_UNSECURE_STOPCOMMAND_TOKENS";
|
||||
public static readonly string RunnerDebug = "ACTIONS_RUNNER_DEBUG";
|
||||
public static readonly string StepDebug = "ACTIONS_STEP_DEBUG";
|
||||
public static readonly string AllowActionsUseUnsecureNodeVersion = "ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION";
|
||||
}
|
||||
|
||||
public static class Agent
|
||||
{
|
||||
public static readonly string ToolsDirectory = "agent.ToolsDirectory";
|
||||
|
||||
// Set this env var to force a node version for internal functions (e.g hashfiles). This does NOT affect the version of node actions.
|
||||
public static readonly string ForcedNodeVersion = "GITHUB_ACTIONS_RUNNER_FORCED_NODE_VERSION";
|
||||
// Set this env var to "node12" to downgrade the node version for internal functions (e.g hashfiles). This does NOT affect the version of node actions.
|
||||
public static readonly string ForcedInternalNodeVersion = "ACTIONS_RUNNER_FORCED_INTERNAL_NODE_VERSION";
|
||||
}
|
||||
|
||||
public static class System
|
||||
|
||||
@@ -216,6 +216,8 @@ namespace GitHub.Runner.Common
|
||||
_userAgents.Add(new ProductInfoHeaderValue("RunnerId", runnerSettings.AgentId.ToString(CultureInfo.InvariantCulture)));
|
||||
_userAgents.Add(new ProductInfoHeaderValue("GroupId", runnerSettings.PoolId.ToString(CultureInfo.InvariantCulture)));
|
||||
}
|
||||
|
||||
_userAgents.Add(new ProductInfoHeaderValue("CommitSHA", BuildConstants.Source.CommitHash));
|
||||
}
|
||||
|
||||
public string GetDirectory(WellKnownDirectory directory)
|
||||
|
||||
@@ -7,9 +7,9 @@ namespace GitHub.Runner.Common.Util
|
||||
{
|
||||
private const string _defaultNodeVersion = "node16";
|
||||
public static readonly ReadOnlyCollection<string> BuiltInNodeVersions = new(new[] {"node12", "node16"});
|
||||
public static string GetNodeVersion()
|
||||
public static string GetInternalNodeVersion()
|
||||
{
|
||||
var forcedNodeVersion = Environment.GetEnvironmentVariable(Constants.Variables.Agent.ForcedNodeVersion);
|
||||
var forcedNodeVersion = Environment.GetEnvironmentVariable(Constants.Variables.Agent.ForcedInternalNodeVersion);
|
||||
return !string.IsNullOrEmpty(forcedNodeVersion) && BuiltInNodeVersions.Contains(forcedNodeVersion) ? forcedNodeVersion : _defaultNodeVersion;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,7 +315,7 @@ namespace GitHub.Runner.Listener.Check
|
||||
});
|
||||
|
||||
var downloadCertScript = Path.Combine(hostContext.GetDirectory(WellKnownDirectory.Bin), "checkScripts", "downloadCert");
|
||||
var node = Path.Combine(hostContext.GetDirectory(WellKnownDirectory.Externals), NodeUtil.GetNodeVersion(), "bin", $"node{IOUtil.ExeExtension}");
|
||||
var node = Path.Combine(hostContext.GetDirectory(WellKnownDirectory.Externals), NodeUtil.GetInternalNodeVersion(), "bin", $"node{IOUtil.ExeExtension}");
|
||||
result.Logs.Add($"{DateTime.UtcNow.ToString("O")} Run '{node} \"{downloadCertScript}\"' ");
|
||||
result.Logs.Add($"{DateTime.UtcNow.ToString("O")} {StringUtil.ConvertToJson(env)}");
|
||||
await processInvoker.ExecuteAsync(
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace GitHub.Runner.Listener.Check
|
||||
});
|
||||
|
||||
var makeWebRequestScript = Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Bin), "checkScripts", "makeWebRequest.js");
|
||||
var node = Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Externals), NodeUtil.GetNodeVersion(), "bin", $"node{IOUtil.ExeExtension}");
|
||||
var node = Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Externals), NodeUtil.GetInternalNodeVersion(), "bin", $"node{IOUtil.ExeExtension}");
|
||||
result.Logs.Add($"{DateTime.UtcNow.ToString("O")} Run '{node} \"{makeWebRequestScript}\"' ");
|
||||
result.Logs.Add($"{DateTime.UtcNow.ToString("O")} {StringUtil.ConvertToJson(env)}");
|
||||
await processInvoker.ExecuteAsync(
|
||||
|
||||
@@ -48,13 +48,12 @@ namespace GitHub.Runner.Listener.Configuration
|
||||
string repoOrOrgName = regex.Replace(settings.RepoOrOrgName, "-");
|
||||
|
||||
serviceName = StringUtil.Format(serviceNamePattern, repoOrOrgName, settings.AgentName);
|
||||
|
||||
if (serviceName.Length > 80)
|
||||
if (serviceName.Length > MaxServiceNameLength)
|
||||
{
|
||||
Trace.Verbose($"Calculated service name is too long (> 80 chars). Trying again by calculating a shorter name.");
|
||||
|
||||
int exceededCharLength = serviceName.Length - 80;
|
||||
string repoOrOrgNameSubstring = StringUtil.SubstringPrefix(repoOrOrgName, 45);
|
||||
Trace.Verbose($"Calculated service name is too long (> {MaxServiceNameLength} chars). Trying again by calculating a shorter name.");
|
||||
// Add 5 to add -xxxx random number on the end
|
||||
int exceededCharLength = serviceName.Length - MaxServiceNameLength + 5;
|
||||
string repoOrOrgNameSubstring = StringUtil.SubstringPrefix(repoOrOrgName, MaxRepoOrgCharacters);
|
||||
|
||||
exceededCharLength -= repoOrOrgName.Length - repoOrOrgNameSubstring.Length;
|
||||
|
||||
@@ -66,6 +65,10 @@ namespace GitHub.Runner.Listener.Configuration
|
||||
runnerNameSubstring = StringUtil.SubstringPrefix(settings.AgentName, settings.AgentName.Length - exceededCharLength);
|
||||
}
|
||||
|
||||
// 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 num = random.Next(1000, 9999).ToString();
|
||||
runnerNameSubstring +=$"-{num}";
|
||||
serviceName = StringUtil.Format(serviceNamePattern, repoOrOrgNameSubstring, runnerNameSubstring);
|
||||
}
|
||||
|
||||
@@ -73,5 +76,12 @@ namespace GitHub.Runner.Listener.Configuration
|
||||
|
||||
Trace.Info($"Service name '{serviceName}' display name '{serviceDisplayName}' will be used for service configuration.");
|
||||
}
|
||||
#if (OS_LINUX || OS_OSX)
|
||||
const int MaxServiceNameLength = 150;
|
||||
const int MaxRepoOrgCharacters = 70;
|
||||
#elif OS_WINDOWS
|
||||
const int MaxServiceNameLength = 80;
|
||||
const int MaxRepoOrgCharacters = 45;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ namespace GitHub.Runner.Listener
|
||||
{
|
||||
// at this point, the job execution might encounter some dead lock and even not able to be cancelled.
|
||||
// no need to localize the exception string should never happen.
|
||||
throw new InvalidOperationException($"Job dispatch process for {jobDispatch.JobId} has encountered unexpected error, the dispatch task is not able to be canceled within 45 seconds.");
|
||||
throw new InvalidOperationException($"Job dispatch process for {jobDispatch.JobId} has encountered unexpected error, the dispatch task is not able to be cancelled within 45 seconds.");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -363,7 +363,7 @@ namespace GitHub.Runner.Listener
|
||||
Trace.Info($"Start renew job request {requestId} for job {message.JobId}.");
|
||||
Task renewJobRequest = RenewJobRequestAsync(_poolId, requestId, lockToken, orchestrationId, firstJobRequestRenewed, lockRenewalTokenSource.Token);
|
||||
|
||||
// wait till first renew succeed or job request is canceled
|
||||
// wait till first renew succeed or job request is cancelled
|
||||
// not even start worker if the first renew fail
|
||||
await Task.WhenAny(firstJobRequestRenewed.Task, renewJobRequest, Task.Delay(-1, jobRequestCancellationToken));
|
||||
|
||||
@@ -704,7 +704,7 @@ namespace GitHub.Runner.Listener
|
||||
{
|
||||
// OperationCanceledException may caused by http timeout or _lockRenewalTokenSource.Cance();
|
||||
// Stop renew only on cancellation token fired.
|
||||
Trace.Info($"job renew has been canceled, stop renew job request {requestId}.");
|
||||
Trace.Info($"job renew has been cancelled, stop renew job request {requestId}.");
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -762,7 +762,7 @@ namespace GitHub.Runner.Listener
|
||||
}
|
||||
catch (OperationCanceledException) when (token.IsCancellationRequested)
|
||||
{
|
||||
Trace.Info($"job renew has been canceled, stop renew job request {requestId}.");
|
||||
Trace.Info($"job renew has been cancelled, stop renew job request {requestId}.");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -504,7 +504,7 @@ namespace GitHub.Runner.Listener
|
||||
}
|
||||
catch (OperationCanceledException) when (token.IsCancellationRequested)
|
||||
{
|
||||
Trace.Info($"Runner download has been canceled.");
|
||||
Trace.Info($"Runner download has been cancelled.");
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -1070,7 +1070,7 @@ namespace GitHub.Runner.Listener
|
||||
|
||||
var stopWatch = Stopwatch.StartNew();
|
||||
string binDir = HostContext.GetDirectory(WellKnownDirectory.Bin);
|
||||
string node = Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Externals), NodeUtil.GetNodeVersion(), "bin", $"node{IOUtil.ExeExtension}");
|
||||
string node = Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Externals), NodeUtil.GetInternalNodeVersion(), "bin", $"node{IOUtil.ExeExtension}");
|
||||
string hashFilesScript = Path.Combine(binDir, "hashFiles");
|
||||
var hashResult = string.Empty;
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace GitHub.Runner.Plugins.Repository.v1_0
|
||||
}
|
||||
else
|
||||
{
|
||||
// delete the index.lock file left by previous canceled build or any operation cause git.exe crash last time.
|
||||
// delete the index.lock file left by previous cancelled build or any operation cause git.exe crash last time.
|
||||
string lockFile = Path.Combine(targetPath, ".git\\index.lock");
|
||||
if (File.Exists(lockFile))
|
||||
{
|
||||
@@ -181,7 +181,7 @@ namespace GitHub.Runner.Plugins.Repository.v1_0
|
||||
}
|
||||
}
|
||||
|
||||
// delete the shallow.lock file left by previous canceled build or any operation cause git.exe crash last time.
|
||||
// delete the shallow.lock file left by previous cancelled build or any operation cause git.exe crash last time.
|
||||
string shallowLockFile = Path.Combine(targetPath, ".git\\shallow.lock");
|
||||
if (File.Exists(shallowLockFile))
|
||||
{
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace GitHub.Runner.Plugins.Repository.v1_1
|
||||
}
|
||||
else
|
||||
{
|
||||
// delete the index.lock file left by previous canceled build or any operation cause git.exe crash last time.
|
||||
// delete the index.lock file left by previous cancelled build or any operation cause git.exe crash last time.
|
||||
string lockFile = Path.Combine(targetPath, ".git\\index.lock");
|
||||
if (File.Exists(lockFile))
|
||||
{
|
||||
@@ -165,7 +165,7 @@ namespace GitHub.Runner.Plugins.Repository.v1_1
|
||||
}
|
||||
}
|
||||
|
||||
// delete the shallow.lock file left by previous canceled build or any operation cause git.exe crash last time.
|
||||
// delete the shallow.lock file left by previous cancelled build or any operation cause git.exe crash last time.
|
||||
string shallowLockFile = Path.Combine(targetPath, ".git\\shallow.lock");
|
||||
if (File.Exists(shallowLockFile))
|
||||
{
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace GitHub.Runner.Sdk
|
||||
}
|
||||
|
||||
// Create a new token source for the parallel query. The parallel query should be
|
||||
// canceled after the first error is encountered. Otherwise the number of exceptions
|
||||
// cancelled after the first error is encountered. Otherwise the number of exceptions
|
||||
// could get out of control for a large directory with access denied on every file.
|
||||
using (var tokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken))
|
||||
{
|
||||
|
||||
@@ -654,7 +654,7 @@ namespace GitHub.Runner.Worker
|
||||
actionDownloadInfos = await jobServer.ResolveActionDownloadInfoAsync(executionContext.Global.Plan.ScopeIdentifier, executionContext.Global.Plan.PlanType, executionContext.Global.Plan.PlanId, executionContext.Root.Id, new WebApi.ActionReferenceList { Actions = actionReferences }, executionContext.CancellationToken);
|
||||
break;
|
||||
}
|
||||
catch (Exception ex) when (!executionContext.CancellationToken.IsCancellationRequested) // Do not retry if the run is canceled.
|
||||
catch (Exception ex) when (!executionContext.CancellationToken.IsCancellationRequested) // Do not retry if the run is cancelled.
|
||||
{
|
||||
// UnresolvableActionDownloadInfoException is a 422 client error, don't retry
|
||||
// Some possible cases are:
|
||||
|
||||
@@ -680,7 +680,7 @@ namespace GitHub.Runner.Worker
|
||||
|
||||
if (Global.Variables.GetBoolean("DistributedTask.ForceInternalNodeVersionOnRunnerTo12") ?? false)
|
||||
{
|
||||
Environment.SetEnvironmentVariable(Constants.Variables.Agent.ForcedNodeVersion, "node12");
|
||||
Environment.SetEnvironmentVariable(Constants.Variables.Agent.ForcedInternalNodeVersion, "node12");
|
||||
}
|
||||
|
||||
// Environment variables shared across all actions
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace GitHub.Runner.Worker.Expressions
|
||||
string binDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
||||
string runnerRoot = new DirectoryInfo(binDir).Parent.FullName;
|
||||
|
||||
string node = Path.Combine(runnerRoot, "externals", NodeUtil.GetNodeVersion(), "bin", $"node{IOUtil.ExeExtension}");
|
||||
string node = Path.Combine(runnerRoot, "externals", NodeUtil.GetInternalNodeVersion(), "bin", $"node{IOUtil.ExeExtension}");
|
||||
string hashFilesScript = Path.Combine(binDir, "hashFiles");
|
||||
var hashResult = string.Empty;
|
||||
var p = new ProcessInvoker(new HashFilesTrace(context.Trace));
|
||||
|
||||
@@ -181,6 +181,10 @@ namespace GitHub.Runner.Worker
|
||||
{
|
||||
throw new Exception($"Invalid environment variable value. Matching delimiter not found '{delimiter}'");
|
||||
}
|
||||
if (newline == null)
|
||||
{
|
||||
throw new Exception($"Invalid environment variable value. EOF marker missing new line.");
|
||||
}
|
||||
endIndex = index - newline.Length;
|
||||
tempLine = ReadLine(text, ref index, out newline);
|
||||
}
|
||||
@@ -294,7 +298,7 @@ namespace GitHub.Runner.Worker
|
||||
|
||||
if (fileSize > _attachmentSizeLimit)
|
||||
{
|
||||
context.Error($"$GITHUB_STEP_SUMMARY supports content up a size of {_attachmentSizeLimit / 1024}k got {fileSize / 1024}k");
|
||||
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");
|
||||
|
||||
return;
|
||||
|
||||
@@ -299,7 +299,7 @@ namespace GitHub.Runner.Worker.Handlers
|
||||
// Register job cancellation call back only if job cancellation token not been fire before each step run
|
||||
if (!ExecutionContext.Root.CancellationToken.IsCancellationRequested)
|
||||
{
|
||||
// Test the condition again. The job was canceled after the condition was originally evaluated.
|
||||
// Test the condition again. The job was cancelled after the condition was originally evaluated.
|
||||
jobCancelRegister = ExecutionContext.Root.CancellationToken.Register(() =>
|
||||
{
|
||||
// Mark job as cancelled
|
||||
@@ -399,7 +399,7 @@ namespace GitHub.Runner.Worker.Handlers
|
||||
jobCancelRegister = null;
|
||||
}
|
||||
}
|
||||
// Check failed or canceled
|
||||
// Check failed or cancelled
|
||||
if (step.ExecutionContext.Result == TaskResult.Failed || step.ExecutionContext.Result == TaskResult.Canceled)
|
||||
{
|
||||
Trace.Info($"Update job result with current composite step result '{step.ExecutionContext.Result}'.");
|
||||
|
||||
@@ -55,7 +55,23 @@ namespace GitHub.Runner.Worker.Handlers
|
||||
else if (data.ExecutionType == ActionExecutionType.NodeJS)
|
||||
{
|
||||
handler = HostContext.CreateService<INodeScriptActionHandler>();
|
||||
(handler as INodeScriptActionHandler).Data = data as NodeJSActionExecutionData;
|
||||
var nodeData = data as NodeJSActionExecutionData;
|
||||
|
||||
// With node12 EoL in 04/2022, we want to be able to uniformly upgrade all JS actions to node16 from the server
|
||||
if (string.Equals(nodeData.NodeVersion, "node12", StringComparison.InvariantCultureIgnoreCase) &&
|
||||
(executionContext.Global.Variables.GetBoolean("DistributedTask.ForceGithubJavascriptActionsToNode16") ?? false))
|
||||
{
|
||||
// The user can opt out of this behaviour by setting this variable to true, either setting 'env' in their workflow or as an environment variable on their machine
|
||||
executionContext.Global.EnvironmentVariables.TryGetValue(Constants.Variables.Actions.AllowActionsUseUnsecureNodeVersion, out var workflowOptOut);
|
||||
var isWorkflowOptOutSet = !string.IsNullOrEmpty(workflowOptOut);
|
||||
var isLocalOptOut = StringUtil.ConvertToBoolean(Environment.GetEnvironmentVariable(Constants.Variables.Actions.AllowActionsUseUnsecureNodeVersion));
|
||||
bool isOptOut = isWorkflowOptOutSet ? StringUtil.ConvertToBoolean(workflowOptOut) : isLocalOptOut;
|
||||
if (!isOptOut)
|
||||
{
|
||||
nodeData.NodeVersion = "node16";
|
||||
}
|
||||
}
|
||||
(handler as INodeScriptActionHandler).Data = nodeData;
|
||||
}
|
||||
else if (data.ExecutionType == ActionExecutionType.Script)
|
||||
{
|
||||
|
||||
@@ -6,7 +6,6 @@ using System.Threading.Tasks;
|
||||
using GitHub.DistributedTask.WebApi;
|
||||
using GitHub.Runner.Common;
|
||||
using GitHub.Runner.Sdk;
|
||||
using Pipelines = GitHub.DistributedTask.Pipelines;
|
||||
|
||||
namespace GitHub.Runner.Worker.Handlers
|
||||
{
|
||||
|
||||
@@ -266,7 +266,7 @@ namespace GitHub.Runner.Worker.Handlers
|
||||
if (Environment.ContainsKey("DYLD_INSERT_LIBRARIES")) // We don't check `isContainerStepHost` because we don't support container on macOS
|
||||
{
|
||||
// launch `node macOSRunInvoker.js shell args` instead of `shell args` to avoid macOS SIP remove `DYLD_INSERT_LIBRARIES` when launch process
|
||||
string node = Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Externals), NodeUtil.GetNodeVersion(), "bin", $"node{IOUtil.ExeExtension}");
|
||||
string node = Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Externals), NodeUtil.GetInternalNodeVersion(), "bin", $"node{IOUtil.ExeExtension}");
|
||||
string macOSRunInvoker = Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Bin), "macos-run-invoker.js");
|
||||
arguments = $"\"{macOSRunInvoker.Replace("\"", "\\\"")}\" \"{fileName.Replace("\"", "\\\"")}\" {arguments}";
|
||||
fileName = node;
|
||||
|
||||
@@ -131,9 +131,9 @@ namespace GitHub.Runner.Worker
|
||||
}
|
||||
catch (OperationCanceledException ex) when (jobContext.CancellationToken.IsCancellationRequested)
|
||||
{
|
||||
// set the job to canceled
|
||||
// set the job to cancelled
|
||||
// don't log error issue to job ExecutionContext, since server owns the job level issue
|
||||
Trace.Error($"Job is canceled during initialize.");
|
||||
Trace.Error($"Job is cancelled during initialize.");
|
||||
Trace.Error($"Caught exception: {ex}");
|
||||
return await CompleteJobAsync(jobServer, jobContext, message, TaskResult.Canceled);
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace GitHub.Runner.Worker
|
||||
// Register job cancellation call back only if job cancellation token not been fire before each step run
|
||||
if (!jobContext.CancellationToken.IsCancellationRequested)
|
||||
{
|
||||
// Test the condition again. The job was canceled after the condition was originally evaluated.
|
||||
// Test the condition again. The job was cancelled after the condition was originally evaluated.
|
||||
jobCancelRegister = jobContext.CancellationToken.Register(() =>
|
||||
{
|
||||
// Mark job as cancelled
|
||||
|
||||
@@ -774,7 +774,14 @@ namespace GitHub.Runner.Common.Tests.Listener
|
||||
|
||||
var traceFile = Path.GetTempFileName();
|
||||
File.Copy(hc.TraceFileName, traceFile, true);
|
||||
Assert.Contains("Something wrong with the trimmed runner package, failback to use the full package for runner updates", File.ReadAllText(traceFile));
|
||||
if (File.ReadAllText(traceFile).Contains("Use trimmed (runtime+externals) package"))
|
||||
{
|
||||
Assert.Contains("Something wrong with the trimmed runner package, failback to use the full package for runner updates", File.ReadAllText(traceFile));
|
||||
}
|
||||
else
|
||||
{
|
||||
hc.GetTrace().Warning("Skipping the 'TestSelfUpdateAsync_FallbackToFullPackage' test, as the `externals` or `runtime` hashes have been updated");
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using GitHub.Runner.Common;
|
||||
using GitHub.Runner.Listener.Configuration;
|
||||
using Xunit;
|
||||
@@ -15,7 +16,7 @@ namespace GitHub.Runner.Common.Tests
|
||||
{
|
||||
RunnerSettings settings = new RunnerSettings();
|
||||
|
||||
settings.AgentName = "thisiskindofalongrunnername1";
|
||||
settings.AgentName = "thisiskindofalongrunnerabcde";
|
||||
settings.ServerUrl = "https://example.githubusercontent.com/12345678901234567890123456789012345678901234567890";
|
||||
settings.GitHubUrl = "https://github.com/myorganizationexample/myrepoexample";
|
||||
|
||||
@@ -43,7 +44,7 @@ namespace GitHub.Runner.Common.Tests
|
||||
Assert.Equal("actions", serviceNameParts[0]);
|
||||
Assert.Equal("runner", serviceNameParts[1]);
|
||||
Assert.Equal("myorganizationexample-myrepoexample", serviceNameParts[2]); // '/' has been replaced with '-'
|
||||
Assert.Equal("thisiskindofalongrunnername1", serviceNameParts[3]);
|
||||
Assert.Equal("thisiskindofalongrunnerabcde", serviceNameParts[3]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +55,7 @@ namespace GitHub.Runner.Common.Tests
|
||||
{
|
||||
RunnerSettings settings = new RunnerSettings();
|
||||
|
||||
settings.AgentName = "thisiskindofalongrunnername12";
|
||||
settings.AgentName = "thisiskindofalongrunnernabcde";
|
||||
settings.ServerUrl = "https://example.githubusercontent.com/12345678901234567890123456789012345678901234567890";
|
||||
settings.GitHubUrl = "https://github.com/myorganizationexample/myrepoexample";
|
||||
|
||||
@@ -82,88 +83,129 @@ namespace GitHub.Runner.Common.Tests
|
||||
Assert.Equal("actions", serviceNameParts[0]);
|
||||
Assert.Equal("runner", serviceNameParts[1]);
|
||||
Assert.Equal("myorganizationexample-myrepoexample", serviceNameParts[2]); // '/' has been replaced with '-'
|
||||
Assert.Equal("thisiskindofalongrunnername12", serviceNameParts[3]);
|
||||
Assert.Equal("thisiskindofalongrunnernabcde", serviceNameParts[3]); // should not have random numbers unless we exceed 80
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Level", "L0")]
|
||||
[Trait("Category", "Service")]
|
||||
public void CalculateServiceNameLimitsServiceNameTo80Chars()
|
||||
{
|
||||
RunnerSettings settings = new RunnerSettings();
|
||||
|
||||
settings.AgentName = "thisisareallyreallylongbutstillvalidagentname";
|
||||
settings.ServerUrl = "https://example.githubusercontent.com/12345678901234567890123456789012345678901234567890";
|
||||
settings.GitHubUrl = "https://github.com/myreallylongorganizationexample/myreallylongrepoexample";
|
||||
|
||||
string serviceNamePattern = "actions.runner.{0}.{1}";
|
||||
string serviceDisplayNamePattern = "GitHub Actions Runner ({0}.{1})";
|
||||
|
||||
using (TestHostContext hc = CreateTestContext())
|
||||
#if OS_WINDOWS
|
||||
[Fact]
|
||||
[Trait("Level", "L0")]
|
||||
[Trait("Category", "Service")]
|
||||
public void CalculateServiceNameLimitsServiceNameTo80Chars()
|
||||
{
|
||||
ServiceControlManager scm = new ServiceControlManager();
|
||||
RunnerSettings settings = new RunnerSettings();
|
||||
|
||||
scm.Initialize(hc);
|
||||
scm.CalculateServiceName(
|
||||
settings,
|
||||
serviceNamePattern,
|
||||
serviceDisplayNamePattern,
|
||||
out string serviceName,
|
||||
out string serviceDisplayName);
|
||||
settings.AgentName = "thisisareallyreallylongbutstillvalidagentname";
|
||||
settings.ServerUrl = "https://example.githubusercontent.com/12345678901234567890123456789012345678901234567890";
|
||||
settings.GitHubUrl = "https://github.com/myreallylongorganizationexample/myreallylongrepoexample";
|
||||
|
||||
// Verify name has been shortened to 80 characters
|
||||
Assert.Equal(80, serviceName.Length);
|
||||
string serviceNamePattern = "actions.runner.{0}.{1}";
|
||||
string serviceDisplayNamePattern = "GitHub Actions Runner ({0}.{1})";
|
||||
|
||||
var serviceNameParts = serviceName.Split('.');
|
||||
using (TestHostContext hc = CreateTestContext())
|
||||
{
|
||||
ServiceControlManager scm = new ServiceControlManager();
|
||||
|
||||
// Verify that each component has been shortened to a sensible length
|
||||
Assert.Equal("actions", serviceNameParts[0]); // Never shortened
|
||||
Assert.Equal("runner", serviceNameParts[1]); // Never shortened
|
||||
Assert.Equal("myreallylongorganizationexample-myreallylongr", serviceNameParts[2]); // First 45 chars, '/' has been replaced with '-'
|
||||
Assert.Equal("thisisareallyreally", serviceNameParts[3]); // Remainder of unused chars
|
||||
scm.Initialize(hc);
|
||||
scm.CalculateServiceName(
|
||||
settings,
|
||||
serviceNamePattern,
|
||||
serviceDisplayNamePattern,
|
||||
out string serviceName,
|
||||
out string serviceDisplayName);
|
||||
|
||||
// Verify name has been shortened to 80 characters
|
||||
Assert.Equal(80, serviceName.Length);
|
||||
|
||||
var serviceNameParts = serviceName.Split('.');
|
||||
|
||||
// Verify that each component has been shortened to a sensible length
|
||||
Assert.Equal("actions", serviceNameParts[0]); // Never shortened
|
||||
Assert.Equal("runner", serviceNameParts[1]); // Never shortened
|
||||
Assert.Equal("myreallylongorganizationexample-myreallylongr", serviceNameParts[2]); // First 45 chars, '/' has been replaced with '-'
|
||||
Assert.Matches(@"^(thisisareallyr-[0-9]{4})$", serviceNameParts[3]); // Remainder of unused chars, 4 random numbers added at the end
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Special 'defensive' test that verifies we can gracefully handle creating service names
|
||||
// in case GitHub.com changes its org/repo naming convention in the future,
|
||||
// and some of these characters may be invalid for service names
|
||||
// Not meant to test character set exhaustively -- it's just here to exercise the sanitizing logic
|
||||
[Fact]
|
||||
[Trait("Level", "L0")]
|
||||
[Trait("Category", "Service")]
|
||||
public void CalculateServiceNameSanitizeOutOfRangeChars()
|
||||
{
|
||||
RunnerSettings settings = new RunnerSettings();
|
||||
|
||||
settings.AgentName = "name";
|
||||
settings.ServerUrl = "https://example.githubusercontent.com/12345678901234567890123456789012345678901234567890";
|
||||
settings.GitHubUrl = "https://github.com/org!@$*+[]()/repo!@$*+[]()";
|
||||
|
||||
string serviceNamePattern = "actions.runner.{0}.{1}";
|
||||
string serviceDisplayNamePattern = "GitHub Actions Runner ({0}.{1})";
|
||||
|
||||
using (TestHostContext hc = CreateTestContext())
|
||||
// Special 'defensive' test that verifies we can gracefully handle creating service names
|
||||
// in case GitHub.com changes its org/repo naming convention in the future,
|
||||
// and some of these characters may be invalid for service names
|
||||
// Not meant to test character set exhaustively -- it's just here to exercise the sanitizing logic
|
||||
[Fact]
|
||||
[Trait("Level", "L0")]
|
||||
[Trait("Category", "Service")]
|
||||
public void CalculateServiceNameSanitizeOutOfRangeChars()
|
||||
{
|
||||
ServiceControlManager scm = new ServiceControlManager();
|
||||
RunnerSettings settings = new RunnerSettings();
|
||||
|
||||
scm.Initialize(hc);
|
||||
scm.CalculateServiceName(
|
||||
settings,
|
||||
serviceNamePattern,
|
||||
serviceDisplayNamePattern,
|
||||
out string serviceName,
|
||||
out string serviceDisplayName);
|
||||
settings.AgentName = "name";
|
||||
settings.ServerUrl = "https://example.githubusercontent.com/12345678901234567890123456789012345678901234567890";
|
||||
settings.GitHubUrl = "https://github.com/org!@$*+[]()/repo!@$*+[]()";
|
||||
|
||||
var serviceNameParts = serviceName.Split('.');
|
||||
string serviceNamePattern = "actions.runner.{0}.{1}";
|
||||
string serviceDisplayNamePattern = "GitHub Actions Runner ({0}.{1})";
|
||||
|
||||
// Verify service name parts are sanitized correctly
|
||||
Assert.Equal("actions", serviceNameParts[0]);
|
||||
Assert.Equal("runner", serviceNameParts[1]);
|
||||
Assert.Equal("org----------repo---------", serviceNameParts[2]); // Chars replaced with '-'
|
||||
Assert.Equal("name", serviceNameParts[3]);
|
||||
using (TestHostContext hc = CreateTestContext())
|
||||
{
|
||||
ServiceControlManager scm = new ServiceControlManager();
|
||||
|
||||
scm.Initialize(hc);
|
||||
scm.CalculateServiceName(
|
||||
settings,
|
||||
serviceNamePattern,
|
||||
serviceDisplayNamePattern,
|
||||
out string serviceName,
|
||||
out string serviceDisplayName);
|
||||
|
||||
var serviceNameParts = serviceName.Split('.');
|
||||
|
||||
// Verify service name parts are sanitized correctly
|
||||
Assert.Equal("actions", serviceNameParts[0]);
|
||||
Assert.Equal("runner", serviceNameParts[1]);
|
||||
Assert.Equal("org----------repo---------", serviceNameParts[2]); // Chars replaced with '-'
|
||||
Assert.Equal("name", serviceNameParts[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
[Fact]
|
||||
[Trait("Level", "L0")]
|
||||
[Trait("Category", "Service")]
|
||||
public void CalculateServiceNameLimitsServiceNameTo150Chars()
|
||||
{
|
||||
RunnerSettings settings = new RunnerSettings();
|
||||
|
||||
settings.AgentName = "thisisareallyreallylongbutstillvalidagentnameiamusingforthisexampletotestverylongnamelimits";
|
||||
settings.ServerUrl = "https://example.githubusercontent.com/12345678901234567890123456789012345678901234567890";
|
||||
settings.GitHubUrl = "https://github.com/myreallylongorganizationexampleonlinux/myreallylongrepoexampleonlinux1234";
|
||||
|
||||
string serviceNamePattern = "actions.runner.{0}.{1}";
|
||||
string serviceDisplayNamePattern = "GitHub Actions Runner ({0}.{1})";
|
||||
|
||||
using (TestHostContext hc = CreateTestContext())
|
||||
{
|
||||
ServiceControlManager scm = new ServiceControlManager();
|
||||
|
||||
scm.Initialize(hc);
|
||||
scm.CalculateServiceName(
|
||||
settings,
|
||||
serviceNamePattern,
|
||||
serviceDisplayNamePattern,
|
||||
out string serviceName,
|
||||
out string serviceDisplayName);
|
||||
|
||||
// Verify name has been shortened to 150
|
||||
Assert.Equal(150, serviceName.Length);
|
||||
|
||||
var serviceNameParts = serviceName.Split('.');
|
||||
|
||||
// Verify that each component has been shortened to a sensible length
|
||||
Assert.Equal("actions", serviceNameParts[0]); // Never shortened
|
||||
Assert.Equal("runner", serviceNameParts[1]); // Never shortened
|
||||
Assert.Equal("myreallylongorganizationexampleonlinux-myreallylongrepoexampleonlinux1", serviceNameParts[2]); // First 70 chars, '/' has been replaced with '-'
|
||||
Assert.Matches(@"^(thisisareallyreallylongbutstillvalidagentnameiamusingforthi-[0-9]{4})$", serviceNameParts[3]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private TestHostContext CreateTestContext([CallerMemberName] string testName = "")
|
||||
{
|
||||
|
||||
100
src/Test/L0/Worker/HandlerFactoryL0.cs
Normal file
100
src/Test/L0/Worker/HandlerFactoryL0.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
using GitHub.Runner.Worker;
|
||||
using GitHub.Runner.Worker.Handlers;
|
||||
using GitHub.DistributedTask.Pipelines;
|
||||
using GitHub.DistributedTask.WebApi;
|
||||
|
||||
namespace GitHub.Runner.Common.Tests.Worker
|
||||
{
|
||||
public sealed class HandlerFactoryL0
|
||||
{
|
||||
private Mock<IExecutionContext> _ec;
|
||||
private TestHostContext CreateTestContext([CallerMemberName] string testName = "")
|
||||
{
|
||||
var hostContext = new TestHostContext(this, testName);
|
||||
_ec = new Mock<IExecutionContext>();
|
||||
_ec.SetupAllProperties();
|
||||
_ec.Object.Initialize(hostContext);
|
||||
var handler = new Mock<INodeScriptActionHandler>();
|
||||
handler.SetupAllProperties();
|
||||
hostContext.EnqueueInstance(handler.Object);
|
||||
//hostContext.EnqueueInstance(new ActionCommandManager() as IActionCommandManager);
|
||||
|
||||
return hostContext;
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[Trait("Level", "L0")]
|
||||
[Trait("Category", "Worker")]
|
||||
[InlineData("node12", "", "", "", "node12")]
|
||||
[InlineData("node12", "true", "", "", "node16")]
|
||||
[InlineData("node12", "true", "", "true", "node12")]
|
||||
[InlineData("node12", "true", "true", "", "node12")]
|
||||
[InlineData("node12", "true", "true", "true", "node12")]
|
||||
[InlineData("node12", "true", "false", "true", "node16")] // workflow overrides env
|
||||
[InlineData("node16", "", "", "", "node16")]
|
||||
[InlineData("node16", "true", "", "", "node16")]
|
||||
[InlineData("node16", "true", "", "true", "node16")]
|
||||
[InlineData("node16", "true", "true", "", "node16")]
|
||||
[InlineData("node16", "true", "true", "true", "node16")]
|
||||
[InlineData("node16", "true", "false", "true", "node16")]
|
||||
public void IsNodeVersionUpgraded(string inputVersion, string serverFeatureFlag, string workflowOptOut, string machineOptOut, string expectedVersion)
|
||||
{
|
||||
using (TestHostContext hc = CreateTestContext())
|
||||
{
|
||||
// Arrange.
|
||||
var hf = new HandlerFactory();
|
||||
hf.Initialize(hc);
|
||||
|
||||
// Server Feature Flag
|
||||
var variables = new Dictionary<string, VariableValue>();
|
||||
if (!string.IsNullOrEmpty(serverFeatureFlag))
|
||||
{
|
||||
variables["DistributedTask.ForceGithubJavascriptActionsToNode16"] = serverFeatureFlag;
|
||||
}
|
||||
Variables serverVariables = new Variables(hc, variables);
|
||||
|
||||
// Workflow opt-out
|
||||
var workflowVariables = new Dictionary<string, string>();
|
||||
if (!string.IsNullOrEmpty(workflowOptOut))
|
||||
{
|
||||
workflowVariables[Constants.Variables.Actions.AllowActionsUseUnsecureNodeVersion] = workflowOptOut;
|
||||
}
|
||||
|
||||
// Machine opt-out
|
||||
if (!string.IsNullOrEmpty(machineOptOut))
|
||||
{
|
||||
Environment.SetEnvironmentVariable(Constants.Variables.Actions.AllowActionsUseUnsecureNodeVersion, machineOptOut);
|
||||
}
|
||||
|
||||
_ec.Setup(x => x.Global).Returns(new GlobalContext()
|
||||
{
|
||||
Variables = serverVariables,
|
||||
EnvironmentVariables = workflowVariables
|
||||
});
|
||||
|
||||
|
||||
// Act.
|
||||
var data = new NodeJSActionExecutionData();
|
||||
data.NodeVersion = inputVersion;
|
||||
var handler = hf.Create(
|
||||
_ec.Object,
|
||||
new ScriptReference(),
|
||||
new Mock<IStepHost>().Object,
|
||||
data,
|
||||
new Dictionary<string, string>(),
|
||||
new Dictionary<string, string>(),
|
||||
new Variables(hc, new Dictionary<string, VariableValue>()), "", new List<JobExtensionRunner>()
|
||||
) as INodeScriptActionHandler;
|
||||
|
||||
// Assert.
|
||||
Assert.Equal(expectedVersion, handler.Data.NodeVersion);
|
||||
Environment.SetEnvironmentVariable(Constants.Variables.Actions.AllowActionsUseUnsecureNodeVersion, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -302,6 +302,50 @@ namespace GitHub.Runner.Common.Tests.Worker
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Level", "L0")]
|
||||
[Trait("Category", "Worker")]
|
||||
public void SetEnvFileCommand_Heredoc_MissingNewLine()
|
||||
{
|
||||
using (var hostContext = Setup())
|
||||
{
|
||||
var envFile = Path.Combine(_rootDirectory, "heredoc");
|
||||
var content = new List<string>
|
||||
{
|
||||
"MY_ENV<<EOF",
|
||||
"line one",
|
||||
"line two",
|
||||
"line three",
|
||||
"EOF",
|
||||
};
|
||||
WriteContent(envFile, content, " ");
|
||||
var ex = Assert.Throws<Exception>(() => _setEnvFileCommand.ProcessCommand(_executionContext.Object, envFile, null));
|
||||
Assert.Contains("Matching delimiter not found", ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Level", "L0")]
|
||||
[Trait("Category", "Worker")]
|
||||
public void SetEnvFileCommand_Heredoc_MissingNewLineMultipleLinesEnv()
|
||||
{
|
||||
using (var hostContext = Setup())
|
||||
{
|
||||
var envFile = Path.Combine(_rootDirectory, "heredoc");
|
||||
var content = new List<string>
|
||||
{
|
||||
"MY_ENV<<EOF",
|
||||
@"line one
|
||||
line two
|
||||
line three",
|
||||
"EOF",
|
||||
};
|
||||
WriteContent(envFile, content, " ");
|
||||
var ex = Assert.Throws<Exception>(() => _setEnvFileCommand.ProcessCommand(_executionContext.Object, envFile, null));
|
||||
Assert.Contains("EOF marker missing new line", ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
#if OS_WINDOWS
|
||||
[Fact]
|
||||
[Trait("Level", "L0")]
|
||||
|
||||
@@ -1 +1 @@
|
||||
2.287.1
|
||||
2.288.1
|
||||
|
||||
Reference in New Issue
Block a user