mirror of
https://github.com/actions/runner.git
synced 2025-12-13 10:05:23 +00:00
Compare commits
3 Commits
brcrista/m
...
v2.283.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6baf0d275 | ||
|
|
e7ad4652b6 | ||
|
|
b03ca604ff |
@@ -1,11 +1,14 @@
|
|||||||
## Features
|
## Features
|
||||||
|
|
||||||
## Bugs
|
- Collect more telemetry
|
||||||
|
- Make `runner.name` available as a runner context variable
|
||||||
- Fixed an issue where ephemeral runners did not restart after upgrading (#1396)
|
- Add attempt number (`run_attempt`) to GitHub context
|
||||||
|
- When using the `--ephemeral` flag, ensure that the runner cleans up local `.runner` and `.credentials` files after completion (#1337)
|
||||||
|
|
||||||
## Misc
|
## Misc
|
||||||
|
|
||||||
|
- Improved network troubleshooting docs
|
||||||
|
|
||||||
## 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.
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
<Update to ./src/runnerversion when creating release>
|
2.283.1
|
||||||
|
|||||||
@@ -25,7 +25,5 @@
|
|||||||
</dict>
|
</dict>
|
||||||
<key>ProcessType</key>
|
<key>ProcessType</key>
|
||||||
<string>Interactive</string>
|
<string>Interactive</string>
|
||||||
<key>SessionCreate</key>
|
|
||||||
<true/>
|
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ downloadrunnerversion=_DOWNLOAD_RUNNER_VERSION_
|
|||||||
logfile="_UPDATE_LOG_"
|
logfile="_UPDATE_LOG_"
|
||||||
restartinteractiverunner=_RESTART_INTERACTIVE_RUNNER_
|
restartinteractiverunner=_RESTART_INTERACTIVE_RUNNER_
|
||||||
|
|
||||||
telemetryfile="$rootfolder/_diag/.telemetry"
|
|
||||||
|
|
||||||
# log user who run the script
|
# log user who run the script
|
||||||
date "+[%F %T-%4N] --------whoami--------" >> "$logfile" 2>&1
|
date "+[%F %T-%4N] --------whoami--------" >> "$logfile" 2>&1
|
||||||
whoami >> "$logfile" 2>&1
|
whoami >> "$logfile" 2>&1
|
||||||
@@ -120,101 +118,40 @@ then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# fix upgrade issue with macOS when running as a service
|
# fix upgrade issue with macOS
|
||||||
attemptedtargetedfix=0
|
|
||||||
currentplatform=$(uname | awk '{print tolower($0)}')
|
currentplatform=$(uname | awk '{print tolower($0)}')
|
||||||
if [[ "$currentplatform" == 'darwin' && restartinteractiverunner -eq 0 ]]; then
|
if [[ "$currentplatform" == 'darwin' ]]; then
|
||||||
# We needed a fix for https://github.com/actions/runner/issues/743
|
# need a short-term fix for https://github.com/actions/runner/issues/743
|
||||||
# We will recreate the ./externals/node12/bin/node of the past runner version that launched the runnerlistener service
|
# we will recreate all the ./externals/node12/bin/node of the past 5 versions
|
||||||
# Otherwise mac gatekeeper kills the processes we spawn on creation as we are running a process with no backing file
|
# v2.280.3 v2.280.2 v2.280.1 v2.279.0 v2.278.0
|
||||||
|
if [[ ! -e "$rootfolder/externals.2.280.3/node12/bin/node" ]]
|
||||||
# We need the pid for the nodejs loop, get that here, its the parent of the runner C# pid
|
|
||||||
# assumption here is only one process is invoking rootfolder/runsvc.sh
|
|
||||||
procgroup=$(ps x -o pgid,command | grep "$rootfolder/runsvc.sh" | grep -v grep | awk '{print $1}')
|
|
||||||
if [[ $? -eq 0 && -n "$procgroup" ]]
|
|
||||||
then
|
then
|
||||||
# inspect the open file handles to find the node process
|
mkdir -p "$rootfolder/externals.2.280.3/node12/bin"
|
||||||
# we can't actually inspect the process using ps because it uses relative paths and doesn't follow symlinks
|
cp "$rootfolder/externals/node12/bin/node" "$rootfolder/externals.2.280.3/node12/bin/node"
|
||||||
path=$(lsof -a -g "$procgroup" -F n | grep node12/bin/node | grep externals | tail -1 | cut -c2-)
|
|
||||||
if [[ $? -eq 0 && -n "$path" ]]
|
|
||||||
then
|
|
||||||
# trim the last 5 characters of the path '/node'
|
|
||||||
trimmedpath=$(dirname "$path")
|
|
||||||
if [[ $? -eq 0 && -n "$trimmedpath" ]]
|
|
||||||
then
|
|
||||||
attemptedtargetedfix=1
|
|
||||||
# Create the path if it does not exist
|
|
||||||
if [[ ! -e "$path" ]]
|
|
||||||
then
|
|
||||||
date "+[%F %T-%4N] Creating fallback node at path $path" >> "$logfile" 2>&1
|
|
||||||
mkdir -p "$trimmedpath"
|
|
||||||
cp "$rootfolder/externals/node12/bin/node" "$path"
|
|
||||||
else
|
|
||||||
date "+[%F %T-%4N] Path for fallback node exists, skipping creating $path" >> "$logfile" 2>&1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
date "+[%F %T-%4N] DarwinRunnerUpgrade: Failed to trim runner path. TrimmedPath: $trimmedpath, path: $path, pgid: $procgroup, root: $rootfolder" >> "$logfile" 2>&1
|
|
||||||
date "+[%F %T-%4N] DarwinRunnerUpgrade: Failed to trim runner path. TrimmedPath: $trimmedpath, path: $path, pgid: $procgroup, root: $rootfolder" >> "$telemetryfile" 2>&1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
date "+[%F %T-%4N] DarwinRunnerUpgrade: Failed to find runner path. Path: $path, pgid: $procgroup, root: $rootfolder" >> "$logfile" 2>&1
|
|
||||||
date "+[%F %T-%4N] DarwinRunnerUpgrade: Failed to find runner path. Path: $path, pgid: $procgroup, root: $rootfolder" >> "$telemetryfile" 2>&1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
date "+[%F %T-%4N] DarwinRunnerUpgrade: Failed to find runner pgid. pgid: $procgroup, root: $rootfolder" >> "$logfile" 2>&1
|
|
||||||
date "+[%F %T-%4N] DarwinRunnerUpgrade: Failed to find runner pgid. pgid: $procgroup, root: $rootfolder" >> "$telemetryfile" 2>&1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $attemptedtargetedfix -eq 0 ]
|
if [[ ! -e "$rootfolder/externals.2.280.2/node12/bin/node" ]]
|
||||||
then
|
then
|
||||||
|
mkdir -p "$rootfolder/externals.2.280.2/node12/bin"
|
||||||
|
cp "$rootfolder/externals/node12/bin/node" "$rootfolder/externals.2.280.2/node12/bin/node"
|
||||||
|
fi
|
||||||
|
|
||||||
date "+[%F %T-%4N] DarwinRunnerUpgrade: Defaulting to old macOS service fix" >> "$logfile" 2>&1
|
if [[ ! -e "$rootfolder/externals.2.280.1/node12/bin/node" ]]
|
||||||
date "+[%F %T-%4N] DarwinRunnerUpgrade: Defaulting to old macOS service fix" >> "$telemetryfile" 2>&1
|
then
|
||||||
if [[ ! -e "$rootfolder/externals.2.280.3/node12/bin/node" ]]
|
mkdir -p "$rootfolder/externals.2.280.1/node12/bin"
|
||||||
then
|
cp "$rootfolder/externals/node12/bin/node" "$rootfolder/externals.2.280.1/node12/bin/node"
|
||||||
mkdir -p "$rootfolder/externals.2.280.3/node12/bin"
|
fi
|
||||||
cp "$rootfolder/externals/node12/bin/node" "$rootfolder/externals.2.280.3/node12/bin/node"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ! -e "$rootfolder/externals.2.280.2/node12/bin/node" ]]
|
if [[ ! -e "$rootfolder/externals.2.279.0/node12/bin/node" ]]
|
||||||
then
|
then
|
||||||
mkdir -p "$rootfolder/externals.2.280.2/node12/bin"
|
mkdir -p "$rootfolder/externals.2.279.0/node12/bin"
|
||||||
cp "$rootfolder/externals/node12/bin/node" "$rootfolder/externals.2.280.2/node12/bin/node"
|
cp "$rootfolder/externals/node12/bin/node" "$rootfolder/externals.2.279.0/node12/bin/node"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -e "$rootfolder/externals.2.280.1/node12/bin/node" ]]
|
if [[ ! -e "$rootfolder/externals.2.278.0/node12/bin/node" ]]
|
||||||
then
|
then
|
||||||
mkdir -p "$rootfolder/externals.2.280.1/node12/bin"
|
mkdir -p "$rootfolder/externals.2.278.0/node12/bin"
|
||||||
cp "$rootfolder/externals/node12/bin/node" "$rootfolder/externals.2.280.1/node12/bin/node"
|
cp "$rootfolder/externals/node12/bin/node" "$rootfolder/externals.2.278.0/node12/bin/node"
|
||||||
fi
|
|
||||||
|
|
||||||
# GHES 3.2
|
|
||||||
if [[ ! -e "$rootfolder/externals.2.279.0/node12/bin/node" ]]
|
|
||||||
then
|
|
||||||
mkdir -p "$rootfolder/externals.2.279.0/node12/bin"
|
|
||||||
cp "$rootfolder/externals/node12/bin/node" "$rootfolder/externals.2.279.0/node12/bin/node"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# GHES 3.1.2 or later
|
|
||||||
if [[ ! -e "$rootfolder/externals.2.278.0/node12/bin/node" ]]
|
|
||||||
then
|
|
||||||
mkdir -p "$rootfolder/externals.2.278.0/node12/bin"
|
|
||||||
cp "$rootfolder/externals/node12/bin/node" "$rootfolder/externals.2.278.0/node12/bin/node"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# GHES 3.1.0
|
|
||||||
if [[ ! -e "$rootfolder/externals.2.276.1/node12/bin/node" ]]
|
|
||||||
then
|
|
||||||
mkdir -p "$rootfolder/externals.2.276.1/node12/bin"
|
|
||||||
cp "$rootfolder/externals/node12/bin/node" "$rootfolder/externals.2.276.1/node12/bin/node"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# GHES 3.0
|
|
||||||
if [[ ! -e "$rootfolder/externals.2.273.5/node12/bin/node" ]]
|
|
||||||
then
|
|
||||||
mkdir -p "$rootfolder/externals.2.273.5/node12/bin"
|
|
||||||
cp "$rootfolder/externals/node12/bin/node" "$rootfolder/externals.2.273.5/node12/bin/node"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -43,21 +43,6 @@ else
|
|||||||
else
|
else
|
||||||
sleep 5
|
sleep 5
|
||||||
fi
|
fi
|
||||||
elif [[ $returnCode == 4 ]]; then
|
|
||||||
if [ ! -x "$(command -v sleep)" ]; then
|
|
||||||
if [ ! -x "$(command -v ping)" ]; then
|
|
||||||
COUNT="0"
|
|
||||||
while [[ $COUNT != 5000 ]]; do
|
|
||||||
echo "SLEEP" > /dev/null
|
|
||||||
COUNT=$[$COUNT+1]
|
|
||||||
done
|
|
||||||
else
|
|
||||||
ping -c 5 127.0.0.1 > /dev/null
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
sleep 5
|
|
||||||
fi
|
|
||||||
"$DIR"/bin/Runner.Listener run $*
|
|
||||||
else
|
else
|
||||||
exit $returnCode
|
exit $returnCode
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ namespace GitHub.Runner.Common
|
|||||||
Certificates,
|
Certificates,
|
||||||
Options,
|
Options,
|
||||||
SetupInfo,
|
SetupInfo,
|
||||||
Telemetry
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Constants
|
public static class Constants
|
||||||
@@ -129,7 +128,7 @@ namespace GitHub.Runner.Common
|
|||||||
public static readonly string Ephemeral = "ephemeral";
|
public static readonly string Ephemeral = "ephemeral";
|
||||||
public static readonly string Help = "help";
|
public static readonly string Help = "help";
|
||||||
public static readonly string Replace = "replace";
|
public static readonly string Replace = "replace";
|
||||||
public static readonly string Once = "once"; // Keep this around since customers still relies on it
|
public static readonly string Once = "once"; // TODO: Remove in 10/2021
|
||||||
public static readonly string RunAsService = "runasservice";
|
public static readonly string RunAsService = "runasservice";
|
||||||
public static readonly string Unattended = "unattended";
|
public static readonly string Unattended = "unattended";
|
||||||
public static readonly string Version = "version";
|
public static readonly string Version = "version";
|
||||||
@@ -155,7 +154,6 @@ namespace GitHub.Runner.Common
|
|||||||
public static readonly string LowDiskSpace = "LOW_DISK_SPACE";
|
public static readonly string LowDiskSpace = "LOW_DISK_SPACE";
|
||||||
public static readonly string UnsupportedCommand = "UNSUPPORTED_COMMAND";
|
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 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 class RunnerEvent
|
public static class RunnerEvent
|
||||||
@@ -215,7 +213,6 @@ namespace GitHub.Runner.Common
|
|||||||
// Keep alphabetical
|
// Keep alphabetical
|
||||||
//
|
//
|
||||||
public static readonly string AllowUnsupportedCommands = "ACTIONS_ALLOW_UNSECURE_COMMANDS";
|
public static readonly string AllowUnsupportedCommands = "ACTIONS_ALLOW_UNSECURE_COMMANDS";
|
||||||
public static readonly string AllowUnsupportedStopCommandTokens = "ACTIONS_ALLOW_UNSECURE_STOPCOMMAND_TOKENS";
|
|
||||||
public static readonly string RunnerDebug = "ACTIONS_RUNNER_DEBUG";
|
public static readonly string RunnerDebug = "ACTIONS_RUNNER_DEBUG";
|
||||||
public static readonly string StepDebug = "ACTIONS_STEP_DEBUG";
|
public static readonly string StepDebug = "ACTIONS_STEP_DEBUG";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -342,12 +342,6 @@ namespace GitHub.Runner.Common
|
|||||||
GetDirectory(WellKnownDirectory.Root),
|
GetDirectory(WellKnownDirectory.Root),
|
||||||
".setup_info");
|
".setup_info");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WellKnownConfigFile.Telemetry:
|
|
||||||
path = Path.Combine(
|
|
||||||
GetDirectory(WellKnownDirectory.Diag),
|
|
||||||
".telemetry");
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new NotSupportedException($"Unexpected well known config file: '{configFile}'");
|
throw new NotSupportedException($"Unexpected well known config file: '{configFile}'");
|
||||||
|
|||||||
@@ -2,11 +2,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net.Http;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using GitHub.Runner.Sdk;
|
|
||||||
using GitHub.Services.Common;
|
|
||||||
using GitHub.Services.WebApi;
|
using GitHub.Services.WebApi;
|
||||||
|
|
||||||
namespace GitHub.Runner.Common
|
namespace GitHub.Runner.Common
|
||||||
@@ -39,9 +36,6 @@ namespace GitHub.Runner.Common
|
|||||||
{
|
{
|
||||||
_connection = jobConnection;
|
_connection = jobConnection;
|
||||||
int attemptCount = 5;
|
int attemptCount = 5;
|
||||||
var configurationStore = HostContext.GetService<IConfigurationStore>();
|
|
||||||
var runnerSettings = configurationStore.GetSettings();
|
|
||||||
|
|
||||||
while (!_connection.HasAuthenticated && attemptCount-- > 0)
|
while (!_connection.HasAuthenticated && attemptCount-- > 0)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -51,13 +45,8 @@ namespace GitHub.Runner.Common
|
|||||||
}
|
}
|
||||||
catch (Exception ex) when (attemptCount > 0)
|
catch (Exception ex) when (attemptCount > 0)
|
||||||
{
|
{
|
||||||
Trace.Info($"Catch exception during connect. {attemptCount} attempts left.");
|
Trace.Info($"Catch exception during connect. {attemptCount} attemp left.");
|
||||||
Trace.Error(ex);
|
Trace.Error(ex);
|
||||||
|
|
||||||
if (runnerSettings.IsHostedServer)
|
|
||||||
{
|
|
||||||
await CheckNetworkEndpointsAsync();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await Task.Delay(100);
|
await Task.Delay(100);
|
||||||
@@ -67,52 +56,6 @@ namespace GitHub.Runner.Common
|
|||||||
_hasConnection = true;
|
_hasConnection = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task CheckNetworkEndpointsAsync()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Trace.Info("Requesting Actions Service health endpoint status");
|
|
||||||
using (var httpClientHandler = HostContext.CreateHttpClientHandler())
|
|
||||||
using (var actionsClient = new HttpClient(httpClientHandler))
|
|
||||||
{
|
|
||||||
var baseUri = new Uri(_connection.Uri.GetLeftPart(UriPartial.Authority));
|
|
||||||
|
|
||||||
actionsClient.DefaultRequestHeaders.UserAgent.AddRange(HostContext.UserAgents);
|
|
||||||
|
|
||||||
// Call the _apis/health endpoint
|
|
||||||
var response = await actionsClient.GetAsync(new Uri(baseUri, "_apis/health"));
|
|
||||||
Trace.Info($"Actions health status code: {response.StatusCode}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
// Log error, but continue as this call is best-effort
|
|
||||||
Trace.Info($"Actions Service health endpoint failed due to {ex.GetType().Name}");
|
|
||||||
Trace.Error(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Trace.Info("Requesting Github API endpoint status");
|
|
||||||
// This is a dotcom public API... just call it directly
|
|
||||||
using (var httpClientHandler = HostContext.CreateHttpClientHandler())
|
|
||||||
using (var gitHubClient = new HttpClient(httpClientHandler))
|
|
||||||
{
|
|
||||||
gitHubClient.DefaultRequestHeaders.UserAgent.AddRange(HostContext.UserAgents);
|
|
||||||
|
|
||||||
// Call the api.github.com endpoint
|
|
||||||
var response = await gitHubClient.GetAsync("https://api.github.com");
|
|
||||||
Trace.Info($"api.github.com status code: {response.StatusCode}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
// Log error, but continue as this call is best-effort
|
|
||||||
Trace.Info($"Github API endpoint failed due to {ex.GetType().Name}");
|
|
||||||
Trace.Error(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CheckConnection()
|
private void CheckConnection()
|
||||||
{
|
{
|
||||||
if (!_hasConnection)
|
if (!_hasConnection)
|
||||||
|
|||||||
@@ -29,10 +29,8 @@ namespace GitHub.Runner.Common
|
|||||||
// Configuration
|
// Configuration
|
||||||
Task<TaskAgent> AddAgentAsync(Int32 agentPoolId, TaskAgent agent);
|
Task<TaskAgent> AddAgentAsync(Int32 agentPoolId, TaskAgent agent);
|
||||||
Task DeleteAgentAsync(int agentPoolId, int agentId);
|
Task DeleteAgentAsync(int agentPoolId, int agentId);
|
||||||
Task DeleteAgentAsync(int agentId);
|
|
||||||
Task<List<TaskAgentPool>> GetAgentPoolsAsync(string agentPoolName = null, TaskAgentPoolType poolType = TaskAgentPoolType.Automation);
|
Task<List<TaskAgentPool>> GetAgentPoolsAsync(string agentPoolName = null, TaskAgentPoolType poolType = TaskAgentPoolType.Automation);
|
||||||
Task<List<TaskAgent>> GetAgentsAsync(int agentPoolId, string agentName = null);
|
Task<List<TaskAgent>> GetAgentsAsync(int agentPoolId, string agentName = null);
|
||||||
Task<List<TaskAgent>> GetAgentsAsync(string agentName);
|
|
||||||
Task<TaskAgent> ReplaceAgentAsync(int agentPoolId, TaskAgent agent);
|
Task<TaskAgent> ReplaceAgentAsync(int agentPoolId, TaskAgent agent);
|
||||||
|
|
||||||
// messagequeue
|
// messagequeue
|
||||||
@@ -254,11 +252,6 @@ namespace GitHub.Runner.Common
|
|||||||
return _genericTaskAgentClient.GetAgentsAsync(agentPoolId, agentName, false);
|
return _genericTaskAgentClient.GetAgentsAsync(agentPoolId, agentName, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<List<TaskAgent>> GetAgentsAsync(string agentName)
|
|
||||||
{
|
|
||||||
return GetAgentsAsync(0, agentName); // search in all all agentPools
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<TaskAgent> ReplaceAgentAsync(int agentPoolId, TaskAgent agent)
|
public Task<TaskAgent> ReplaceAgentAsync(int agentPoolId, TaskAgent agent)
|
||||||
{
|
{
|
||||||
CheckConnection(RunnerConnectionType.Generic);
|
CheckConnection(RunnerConnectionType.Generic);
|
||||||
@@ -271,11 +264,6 @@ namespace GitHub.Runner.Common
|
|||||||
return _genericTaskAgentClient.DeleteAgentAsync(agentPoolId, agentId);
|
return _genericTaskAgentClient.DeleteAgentAsync(agentPoolId, agentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task DeleteAgentAsync(int agentId)
|
|
||||||
{
|
|
||||||
return DeleteAgentAsync(0, agentId); // agentPool is ignored server side
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------
|
//-----------------------------------------------------------------
|
||||||
// MessageQueue
|
// MessageQueue
|
||||||
//-----------------------------------------------------------------
|
//-----------------------------------------------------------------
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ namespace GitHub.Runner.Listener
|
|||||||
Constants.Runner.CommandLine.Flags.Commit,
|
Constants.Runner.CommandLine.Flags.Commit,
|
||||||
Constants.Runner.CommandLine.Flags.Ephemeral,
|
Constants.Runner.CommandLine.Flags.Ephemeral,
|
||||||
Constants.Runner.CommandLine.Flags.Help,
|
Constants.Runner.CommandLine.Flags.Help,
|
||||||
Constants.Runner.CommandLine.Flags.Once,
|
|
||||||
Constants.Runner.CommandLine.Flags.Replace,
|
Constants.Runner.CommandLine.Flags.Replace,
|
||||||
Constants.Runner.CommandLine.Flags.RunAsService,
|
Constants.Runner.CommandLine.Flags.RunAsService,
|
||||||
Constants.Runner.CommandLine.Flags.Unattended,
|
Constants.Runner.CommandLine.Flags.Unattended,
|
||||||
@@ -69,7 +68,7 @@ namespace GitHub.Runner.Listener
|
|||||||
public bool Version => TestFlag(Constants.Runner.CommandLine.Flags.Version);
|
public bool Version => TestFlag(Constants.Runner.CommandLine.Flags.Version);
|
||||||
public bool Ephemeral => TestFlag(Constants.Runner.CommandLine.Flags.Ephemeral);
|
public bool Ephemeral => TestFlag(Constants.Runner.CommandLine.Flags.Ephemeral);
|
||||||
|
|
||||||
// Keep this around since customers still relies on it
|
// TODO: Remove in 10/2021
|
||||||
public bool RunOnce => TestFlag(Constants.Runner.CommandLine.Flags.Once);
|
public bool RunOnce => TestFlag(Constants.Runner.CommandLine.Flags.Once);
|
||||||
|
|
||||||
// Constructor.
|
// Constructor.
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ namespace GitHub.Runner.Listener.Configuration
|
|||||||
// Determine the service deployment type based on connection data. (Hosted/OnPremises)
|
// Determine the service deployment type based on connection data. (Hosted/OnPremises)
|
||||||
await _runnerServer.ConnectAsync(new Uri(settings.ServerUrl), creds);
|
await _runnerServer.ConnectAsync(new Uri(settings.ServerUrl), creds);
|
||||||
|
|
||||||
var agents = await _runnerServer.GetAgentsAsync(settings.AgentName);
|
var agents = await _runnerServer.GetAgentsAsync(settings.PoolId, settings.AgentName);
|
||||||
Trace.Verbose("Returns {0} agents", agents.Count);
|
Trace.Verbose("Returns {0} agents", agents.Count);
|
||||||
TaskAgent agent = agents.FirstOrDefault();
|
TaskAgent agent = agents.FirstOrDefault();
|
||||||
if (agent == null)
|
if (agent == null)
|
||||||
@@ -424,7 +424,7 @@ namespace GitHub.Runner.Listener.Configuration
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await _runnerServer.DeleteAgentAsync(settings.AgentId);
|
await _runnerServer.DeleteAgentAsync(settings.PoolId, settings.AgentId);
|
||||||
|
|
||||||
_term.WriteLine();
|
_term.WriteLine();
|
||||||
_term.WriteSuccessMessage("Runner removed successfully");
|
_term.WriteSuccessMessage("Runner removed successfully");
|
||||||
|
|||||||
@@ -233,14 +233,8 @@ namespace GitHub.Runner.Listener
|
|||||||
Trace.Info($"Set runner startup type - {startType}");
|
Trace.Info($"Set runner startup type - {startType}");
|
||||||
HostContext.StartupType = startType;
|
HostContext.StartupType = startType;
|
||||||
|
|
||||||
if (command.RunOnce)
|
|
||||||
{
|
|
||||||
_term.WriteLine("Warning: '--once' is going to be deprecated in the future, please consider using '--ephemeral' during runner registration.", ConsoleColor.Yellow);
|
|
||||||
_term.WriteLine("https://docs.github.com/en/actions/hosting-your-own-runners/autoscaling-with-self-hosted-runners#using-ephemeral-runners-for-autoscaling", ConsoleColor.Yellow);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run the runner interactively or as service
|
// Run the runner interactively or as service
|
||||||
return await RunAsync(settings, command.RunOnce || settings.Ephemeral);
|
return await RunAsync(settings, command.RunOnce || settings.Ephemeral); // TODO: Remove RunOnce later.
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -316,9 +310,6 @@ namespace GitHub.Runner.Listener
|
|||||||
|
|
||||||
IJobDispatcher jobDispatcher = null;
|
IJobDispatcher jobDispatcher = null;
|
||||||
CancellationTokenSource messageQueueLoopTokenSource = CancellationTokenSource.CreateLinkedTokenSource(HostContext.RunnerShutdownToken);
|
CancellationTokenSource messageQueueLoopTokenSource = CancellationTokenSource.CreateLinkedTokenSource(HostContext.RunnerShutdownToken);
|
||||||
|
|
||||||
// Should we try to cleanup ephemeral runners
|
|
||||||
bool runOnceJobCompleted = false;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var notification = HostContext.GetService<IJobNotification>();
|
var notification = HostContext.GetService<IJobNotification>();
|
||||||
@@ -380,7 +371,6 @@ namespace GitHub.Runner.Listener
|
|||||||
Task completeTask = await Task.WhenAny(getNextMessage, jobDispatcher.RunOnceJobCompleted.Task);
|
Task completeTask = await Task.WhenAny(getNextMessage, jobDispatcher.RunOnceJobCompleted.Task);
|
||||||
if (completeTask == jobDispatcher.RunOnceJobCompleted.Task)
|
if (completeTask == jobDispatcher.RunOnceJobCompleted.Task)
|
||||||
{
|
{
|
||||||
runOnceJobCompleted = true;
|
|
||||||
Trace.Info("Job has finished at backend, the runner will exit since it is running under onetime use mode.");
|
Trace.Info("Job has finished at backend, the runner will exit since it is running under onetime use mode.");
|
||||||
Trace.Info("Stop message queue looping.");
|
Trace.Info("Stop message queue looping.");
|
||||||
messageQueueLoopTokenSource.Cancel();
|
messageQueueLoopTokenSource.Cancel();
|
||||||
@@ -489,7 +479,7 @@ namespace GitHub.Runner.Listener
|
|||||||
|
|
||||||
messageQueueLoopTokenSource.Dispose();
|
messageQueueLoopTokenSource.Dispose();
|
||||||
|
|
||||||
if (settings.Ephemeral && runOnceJobCompleted)
|
if (settings.Ephemeral)
|
||||||
{
|
{
|
||||||
var configManager = HostContext.GetService<IConfigurationManager>();
|
var configManager = HostContext.GetService<IConfigurationManager>();
|
||||||
configManager.DeleteLocalRunnerConfig();
|
configManager.DeleteLocalRunnerConfig();
|
||||||
|
|||||||
@@ -108,18 +108,22 @@ namespace GitHub.Runner.Worker
|
|||||||
// Stop command
|
// Stop command
|
||||||
if (string.Equals(actionCommand.Command, _stopCommand, StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(actionCommand.Command, _stopCommand, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
ValidateStopToken(context, actionCommand.Data);
|
context.Output(input);
|
||||||
|
context.Debug("Paused processing commands until '##[{actionCommand.Data}]' is received");
|
||||||
_stopToken = actionCommand.Data;
|
_stopToken = actionCommand.Data;
|
||||||
|
if (_registeredCommands.Contains(actionCommand.Data)
|
||||||
|
|| string.IsNullOrEmpty(actionCommand.Data)
|
||||||
|
|| string.Equals(actionCommand.Data, "pause-logging", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
var telemetry = new JobTelemetry
|
||||||
|
{
|
||||||
|
Message = $"Invoked ::stopCommand:: with token: [{actionCommand.Data}]",
|
||||||
|
Type = JobTelemetryType.ActionCommand
|
||||||
|
};
|
||||||
|
context.JobTelemetry.Add(telemetry);
|
||||||
|
}
|
||||||
_stopProcessCommand = true;
|
_stopProcessCommand = true;
|
||||||
_registeredCommands.Add(_stopToken);
|
_registeredCommands.Add(_stopToken);
|
||||||
if (_stopToken.Length > 6)
|
|
||||||
{
|
|
||||||
HostContext.SecretMasker.AddValue(_stopToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
context.Output(input);
|
|
||||||
context.Debug("Paused processing commands until the token you called ::stopCommands:: with is received");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Found command
|
// Found command
|
||||||
@@ -153,40 +157,6 @@ namespace GitHub.Runner.Worker
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ValidateStopToken(IExecutionContext context, string stopToken)
|
|
||||||
{
|
|
||||||
#if OS_WINDOWS
|
|
||||||
var envContext = context.ExpressionValues["env"] as DictionaryContextData;
|
|
||||||
#else
|
|
||||||
var envContext = context.ExpressionValues["env"] as CaseSensitiveDictionaryContextData;
|
|
||||||
#endif
|
|
||||||
var allowUnsecureStopCommandTokens = false;
|
|
||||||
allowUnsecureStopCommandTokens = StringUtil.ConvertToBoolean(Environment.GetEnvironmentVariable(Constants.Variables.Actions.AllowUnsupportedStopCommandTokens));
|
|
||||||
if (!allowUnsecureStopCommandTokens && envContext.ContainsKey(Constants.Variables.Actions.AllowUnsupportedStopCommandTokens))
|
|
||||||
{
|
|
||||||
allowUnsecureStopCommandTokens = StringUtil.ConvertToBoolean(envContext[Constants.Variables.Actions.AllowUnsupportedStopCommandTokens].ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isTokenInvalid = _registeredCommands.Contains(stopToken)
|
|
||||||
|| string.IsNullOrEmpty(stopToken)
|
|
||||||
|| string.Equals(stopToken, "pause-logging", StringComparison.OrdinalIgnoreCase);
|
|
||||||
|
|
||||||
if (isTokenInvalid)
|
|
||||||
{
|
|
||||||
var telemetry = new JobTelemetry
|
|
||||||
{
|
|
||||||
Message = $"Invoked ::stopCommand:: with token: [{stopToken}]",
|
|
||||||
Type = JobTelemetryType.ActionCommand
|
|
||||||
};
|
|
||||||
context.JobTelemetry.Add(telemetry);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isTokenInvalid && !allowUnsecureStopCommandTokens)
|
|
||||||
{
|
|
||||||
throw new Exception(Constants.Runner.UnsupportedStopCommandTokenDisabled);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static bool EnhancedAnnotationsEnabled(IExecutionContext context)
|
internal static bool EnhancedAnnotationsEnabled(IExecutionContext context)
|
||||||
{
|
{
|
||||||
return context.Global.Variables.GetBoolean("DistributedTask.EnhancedAnnotations") ?? false;
|
return context.Global.Variables.GetBoolean("DistributedTask.EnhancedAnnotations") ?? false;
|
||||||
|
|||||||
@@ -633,12 +633,7 @@ namespace GitHub.Runner.Worker
|
|||||||
}
|
}
|
||||||
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 canceled.
|
||||||
{
|
{
|
||||||
// UnresolvableActionDownloadInfoException is a 422 client error, don't retry
|
if (attempt < 3)
|
||||||
// Some possible cases are:
|
|
||||||
// * Repo is rate limited
|
|
||||||
// * Repo or tag doesn't exist, or isn't public
|
|
||||||
// * Policy validation failed
|
|
||||||
if (attempt < 3 && !(ex is WebApi.UnresolvableActionDownloadInfoException))
|
|
||||||
{
|
{
|
||||||
executionContext.Output($"Failed to resolve action download info. Error: {ex.Message}");
|
executionContext.Output($"Failed to resolve action download info. Error: {ex.Message}");
|
||||||
executionContext.Debug(ex.ToString());
|
executionContext.Debug(ex.ToString());
|
||||||
@@ -654,7 +649,6 @@ namespace GitHub.Runner.Worker
|
|||||||
// Some possible cases are:
|
// Some possible cases are:
|
||||||
// * Repo is rate limited
|
// * Repo is rate limited
|
||||||
// * Repo or tag doesn't exist, or isn't public
|
// * Repo or tag doesn't exist, or isn't public
|
||||||
// * Policy validation failed
|
|
||||||
if (ex is WebApi.UnresolvableActionDownloadInfoException)
|
if (ex is WebApi.UnresolvableActionDownloadInfoException)
|
||||||
{
|
{
|
||||||
throw;
|
throw;
|
||||||
|
|||||||
@@ -262,16 +262,6 @@ namespace GitHub.Runner.Worker
|
|||||||
environment[$"STATE_{state.Key}"] = state.Value ?? string.Empty;
|
environment[$"STATE_{state.Key}"] = state.Value ?? string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACK
|
|
||||||
if (Action.DisplayName != null && Action.DisplayName.StartsWith("make dependency"))
|
|
||||||
{
|
|
||||||
var target = Action.DisplayName.Split()[2];
|
|
||||||
inputs = new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
["script"] = $"make {target}"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the handler.
|
// Create the handler.
|
||||||
IHandler handler = handlerFactory.Create(
|
IHandler handler = handlerFactory.Create(
|
||||||
ExecutionContext,
|
ExecutionContext,
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
|
|
||||||
Inputs.TryGetValue("script", out string contents);
|
Inputs.TryGetValue("script", out string contents);
|
||||||
contents = contents ?? string.Empty;
|
contents = contents ?? string.Empty;
|
||||||
// if (Action.Type == Pipelines.ActionSourceType.Script)
|
if (Action.Type == Pipelines.ActionSourceType.Script)
|
||||||
// {
|
{
|
||||||
var firstLine = contents.TrimStart(' ', '\t', '\r', '\n');
|
var firstLine = contents.TrimStart(' ', '\t', '\r', '\n');
|
||||||
var firstNewLine = firstLine.IndexOfAny(new[] { '\r', '\n' });
|
var firstNewLine = firstLine.IndexOfAny(new[] { '\r', '\n' });
|
||||||
if (firstNewLine >= 0)
|
if (firstNewLine >= 0)
|
||||||
@@ -41,11 +41,11 @@ namespace GitHub.Runner.Worker.Handlers
|
|||||||
}
|
}
|
||||||
|
|
||||||
ExecutionContext.Output($"##[group]Run {firstLine}");
|
ExecutionContext.Output($"##[group]Run {firstLine}");
|
||||||
// }
|
}
|
||||||
// else
|
else
|
||||||
// {
|
{
|
||||||
// throw new InvalidOperationException($"Invalid action type {Action.Type} for {nameof(ScriptHandler)}");
|
throw new InvalidOperationException($"Invalid action type {Action.Type} for {nameof(ScriptHandler)}");
|
||||||
// }
|
}
|
||||||
|
|
||||||
var multiLines = contents.Replace("\r\n", "\n").TrimEnd('\n').Split('\n');
|
var multiLines = contents.Replace("\r\n", "\n").TrimEnd('\n').Split('\n');
|
||||||
foreach (var line in multiLines)
|
foreach (var line in multiLines)
|
||||||
|
|||||||
@@ -265,91 +265,29 @@ namespace GitHub.Runner.Worker
|
|||||||
if (step.Type == Pipelines.StepType.Action)
|
if (step.Type == Pipelines.StepType.Action)
|
||||||
{
|
{
|
||||||
var action = step as Pipelines.ActionStep;
|
var action = step as Pipelines.ActionStep;
|
||||||
|
Trace.Info($"Adding {action.DisplayName}.");
|
||||||
void EmitStep(Pipelines.ActionStep action)
|
var actionRunner = HostContext.CreateService<IActionRunner>();
|
||||||
|
actionRunner.Action = action;
|
||||||
|
actionRunner.Stage = ActionRunStage.Main;
|
||||||
|
actionRunner.Condition = step.Condition;
|
||||||
|
var contextData = new Pipelines.ContextData.DictionaryContextData();
|
||||||
|
if (message.ContextData?.Count > 0)
|
||||||
{
|
{
|
||||||
Trace.Info($"Adding {action.DisplayName}.");
|
foreach (var pair in message.ContextData)
|
||||||
var actionRunner = HostContext.CreateService<IActionRunner>();
|
|
||||||
actionRunner.Action = action;
|
|
||||||
actionRunner.Stage = ActionRunStage.Main;
|
|
||||||
actionRunner.Condition = step.Condition;
|
|
||||||
var contextData = new Pipelines.ContextData.DictionaryContextData();
|
|
||||||
if (message.ContextData?.Count > 0)
|
|
||||||
{
|
{
|
||||||
foreach (var pair in message.ContextData)
|
contextData[pair.Key] = pair.Value;
|
||||||
{
|
|
||||||
contextData[pair.Key] = pair.Value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
actionRunner.TryEvaluateDisplayName(contextData, context);
|
|
||||||
jobSteps.Add(actionRunner);
|
|
||||||
|
|
||||||
if (prepareResult.PreStepTracker.TryGetValue(step.Id, out var preStep))
|
|
||||||
{
|
|
||||||
Trace.Info($"Adding pre-{action.DisplayName}.");
|
|
||||||
preStep.TryEvaluateDisplayName(contextData, context);
|
|
||||||
preStep.DisplayName = $"Pre {preStep.DisplayName}";
|
|
||||||
preJobSteps.Add(preStep);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACK: if the step is "run: make," parse the Makefile and emit $"make dependency {target}"
|
actionRunner.TryEvaluateDisplayName(contextData, context);
|
||||||
// Only works for the default target right now.
|
jobSteps.Add(actionRunner);
|
||||||
bool isRunMake = false;
|
|
||||||
if (action.Reference?.Type == Pipelines.ActionSourceType.Script)
|
|
||||||
{
|
|
||||||
var inputs = action.Inputs.AssertMapping(null);
|
|
||||||
foreach (var pair in inputs)
|
|
||||||
{
|
|
||||||
var propertyName = pair.Key.AssertString($"{PipelineTemplateConstants.Steps}");
|
|
||||||
if (string.Equals(propertyName.Value, "script", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
var tokenToParse = pair.Value.AssertScalar($"{PipelineTemplateConstants.Steps} item {PipelineTemplateConstants.Run}");
|
|
||||||
if (tokenToParse.ToString() == "make")
|
|
||||||
{
|
|
||||||
isRunMake = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isRunMake)
|
if (prepareResult.PreStepTracker.TryGetValue(step.Id, out var preStep))
|
||||||
{
|
{
|
||||||
// Get the path of the Makefile in the repository root.
|
Trace.Info($"Adding pre-{action.DisplayName}.");
|
||||||
var githubContext = jobContext.ExpressionValues["github"] as GitHubContext;
|
preStep.TryEvaluateDisplayName(contextData, context);
|
||||||
var workspaceDir = githubContext["workspace"] as StringContextData;
|
preStep.DisplayName = $"Pre {preStep.DisplayName}";
|
||||||
var makefile = Path.Combine(workspaceDir, "Makefile");
|
preJobSteps.Add(preStep);
|
||||||
if (!File.Exists(makefile))
|
|
||||||
{
|
|
||||||
// Forget about trying to be smart. Just do the normal thing.
|
|
||||||
EmitStep(action);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Assume the default target is named `all`.
|
|
||||||
var targetDependencies = MakefileReader.ReadTargetDependencies(jobContext, makefile, target: "all");
|
|
||||||
if (targetDependencies.Count == 0)
|
|
||||||
{
|
|
||||||
// Forget about trying to be smart. Just do the normal thing.
|
|
||||||
EmitStep(action);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
foreach (var target in targetDependencies)
|
|
||||||
{
|
|
||||||
action = (Pipelines.ActionStep)action.Clone();
|
|
||||||
action.Id = Guid.NewGuid();
|
|
||||||
action.DisplayName = $"make dependency {target}";
|
|
||||||
EmitStep(action);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EmitStep(action);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
@@ -229,9 +228,6 @@ namespace GitHub.Runner.Worker
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load any upgrade telemetry
|
|
||||||
LoadFromTelemetryFile(jobContext.JobTelemetry);
|
|
||||||
|
|
||||||
// Make sure we don't submit secrets as telemetry
|
// Make sure we don't submit secrets as telemetry
|
||||||
MaskTelemetrySecrets(jobContext.JobTelemetry);
|
MaskTelemetrySecrets(jobContext.JobTelemetry);
|
||||||
|
|
||||||
@@ -289,30 +285,6 @@ namespace GitHub.Runner.Worker
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadFromTelemetryFile(List<JobTelemetry> jobTelemetry)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var telemetryFilePath = HostContext.GetConfigFile(WellKnownConfigFile.Telemetry);
|
|
||||||
if (File.Exists(telemetryFilePath))
|
|
||||||
{
|
|
||||||
var telemetryData = File.ReadAllText(telemetryFilePath, Encoding.UTF8);
|
|
||||||
var telemetry = new JobTelemetry
|
|
||||||
{
|
|
||||||
Message = $"Runner File Telemetry:\n{telemetryData}",
|
|
||||||
Type = JobTelemetryType.General
|
|
||||||
};
|
|
||||||
jobTelemetry.Add(telemetry);
|
|
||||||
IOUtil.DeleteFile(telemetryFilePath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Trace.Error("Error when trying to load telemetry from telemetry file");
|
|
||||||
Trace.Error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task ShutdownQueue(bool throwOnFailure)
|
private async Task ShutdownQueue(bool throwOnFailure)
|
||||||
{
|
{
|
||||||
if (_jobServerQueue != null)
|
if (_jobServerQueue != null)
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace GitHub.Runner.Worker
|
|
||||||
{
|
|
||||||
public static class MakefileReader
|
|
||||||
{
|
|
||||||
// Get the dependencies for a target from a Makefile.
|
|
||||||
// Does not recurse into the dependencies of those dependencies.
|
|
||||||
public static List<string> ReadTargetDependencies(IExecutionContext executionContext, string makefile, string target)
|
|
||||||
{
|
|
||||||
var targetToFind = target + ":";
|
|
||||||
var lines = File.ReadLines(makefile);
|
|
||||||
string targetLine = lines.FirstOrDefault(line => line.TrimStart().StartsWith(targetToFind));
|
|
||||||
if (targetLine is null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return targetLine.Split().Skip(1).ToList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using GitHub.DistributedTask.Pipelines.ContextData;
|
|
||||||
using GitHub.DistributedTask.WebApi;
|
using GitHub.DistributedTask.WebApi;
|
||||||
using GitHub.Runner.Worker;
|
using GitHub.Runner.Worker;
|
||||||
using GitHub.Runner.Worker.Container;
|
using GitHub.Runner.Worker.Container;
|
||||||
@@ -84,7 +83,6 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
{
|
{
|
||||||
using (TestHostContext hc = CreateTestContext())
|
using (TestHostContext hc = CreateTestContext())
|
||||||
{
|
{
|
||||||
_ec.Setup(x => x.ExpressionValues).Returns(GetExpressionValues());
|
|
||||||
_ec.Setup(x => x.Write(It.IsAny<string>(), It.IsAny<string>()))
|
_ec.Setup(x => x.Write(It.IsAny<string>(), It.IsAny<string>()))
|
||||||
.Returns((string tag, string line) =>
|
.Returns((string tag, string line) =>
|
||||||
{
|
{
|
||||||
@@ -107,88 +105,6 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
|
||||||
[InlineData("stop-commands", "1")]
|
|
||||||
[InlineData("", "1")]
|
|
||||||
[InlineData("set-env", "1")]
|
|
||||||
[InlineData("stop-commands", "true")]
|
|
||||||
[InlineData("", "true")]
|
|
||||||
[InlineData("set-env", "true")]
|
|
||||||
[Trait("Level", "L0")]
|
|
||||||
[Trait("Category", "Worker")]
|
|
||||||
public void StopProcessCommand__AllowsInvalidStopTokens__IfEnvVarIsSet(string invalidToken, string allowUnsupportedStopCommandTokens)
|
|
||||||
{
|
|
||||||
using (TestHostContext hc = CreateTestContext())
|
|
||||||
{
|
|
||||||
_ec.Object.Global.EnvironmentVariables = new Dictionary<string, string>();
|
|
||||||
var expressionValues = new DictionaryContextData
|
|
||||||
{
|
|
||||||
["env"] =
|
|
||||||
#if OS_WINDOWS
|
|
||||||
new DictionaryContextData{ { Constants.Variables.Actions.AllowUnsupportedStopCommandTokens, new StringContextData(allowUnsupportedStopCommandTokens) }}
|
|
||||||
#else
|
|
||||||
new CaseSensitiveDictionaryContextData{ { Constants.Variables.Actions.AllowUnsupportedStopCommandTokens, new StringContextData(allowUnsupportedStopCommandTokens) }}
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
_ec.Setup(x => x.ExpressionValues).Returns(expressionValues);
|
|
||||||
_ec.Setup(x => x.JobTelemetry).Returns(new List<JobTelemetry>());
|
|
||||||
|
|
||||||
Assert.True(_commandManager.TryProcessCommand(_ec.Object, $"::stop-commands::{invalidToken}", null));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Theory]
|
|
||||||
[InlineData("stop-commands")]
|
|
||||||
[InlineData("")]
|
|
||||||
[InlineData("set-env")]
|
|
||||||
[Trait("Level", "L0")]
|
|
||||||
[Trait("Category", "Worker")]
|
|
||||||
public void StopProcessCommand__FailOnInvalidStopTokens(string invalidToken)
|
|
||||||
{
|
|
||||||
using (TestHostContext hc = CreateTestContext())
|
|
||||||
{
|
|
||||||
_ec.Object.Global.EnvironmentVariables = new Dictionary<string, string>();
|
|
||||||
_ec.Setup(x => x.ExpressionValues).Returns(GetExpressionValues());
|
|
||||||
_ec.Setup(x => x.JobTelemetry).Returns(new List<JobTelemetry>());
|
|
||||||
Assert.Throws<Exception>(() => _commandManager.TryProcessCommand(_ec.Object, $"::stop-commands::{invalidToken}", null));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
[Trait("Level", "L0")]
|
|
||||||
[Trait("Category", "Worker")]
|
|
||||||
public void StopProcessCommandAcceptsValidToken()
|
|
||||||
{
|
|
||||||
var validToken = "randomToken";
|
|
||||||
using (TestHostContext hc = CreateTestContext())
|
|
||||||
{
|
|
||||||
_ec.Setup(x => x.ExpressionValues).Returns(GetExpressionValues());
|
|
||||||
Assert.True(_commandManager.TryProcessCommand(_ec.Object, $"::stop-commands::{validToken}", null));
|
|
||||||
Assert.False(_commandManager.TryProcessCommand(_ec.Object, "##[set-env name=foo]bar", null));
|
|
||||||
Assert.True(_commandManager.TryProcessCommand(_ec.Object, $"::{validToken}::", null));
|
|
||||||
Assert.True(_commandManager.TryProcessCommand(_ec.Object, "##[set-env name=foo]bar", null));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
[Trait("Level", "L0")]
|
|
||||||
[Trait("Category", "Worker")]
|
|
||||||
public void StopProcessCommandMasksValidTokenForEntireRun()
|
|
||||||
{
|
|
||||||
var validToken = "randomToken";
|
|
||||||
using (TestHostContext hc = CreateTestContext())
|
|
||||||
{
|
|
||||||
_ec.Setup(x => x.ExpressionValues).Returns(GetExpressionValues());
|
|
||||||
Assert.True(_commandManager.TryProcessCommand(_ec.Object, $"::stop-commands::{validToken}", null));
|
|
||||||
Assert.False(_commandManager.TryProcessCommand(_ec.Object, "##[set-env name=foo]bar", null));
|
|
||||||
Assert.Equal("***", hc.SecretMasker.MaskSecrets(validToken));
|
|
||||||
|
|
||||||
Assert.True(_commandManager.TryProcessCommand(_ec.Object, $"::{validToken}::", null));
|
|
||||||
Assert.True(_commandManager.TryProcessCommand(_ec.Object, "##[set-env name=foo]bar", null));
|
|
||||||
Assert.Equal("***", hc.SecretMasker.MaskSecrets(validToken));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[Trait("Level", "L0")]
|
[Trait("Level", "L0")]
|
||||||
[Trait("Category", "Worker")]
|
[Trait("Category", "Worker")]
|
||||||
@@ -286,15 +202,15 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
return 1;
|
return 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
var registeredCommands = new HashSet<string>(new string[1] { "warning" });
|
var registeredCommands = new HashSet<string>(new string[1]{ "warning" });
|
||||||
ActionCommand command;
|
ActionCommand command;
|
||||||
|
|
||||||
// Columns when lines are different
|
// Columns when lines are different
|
||||||
ActionCommand.TryParseV2("::warning line=1,endLine=2,col=1,endColumn=2::this is a warning", registeredCommands, out command);
|
ActionCommand.TryParseV2("::warning line=1,endLine=2,col=1,endColumn=2::this is a warning", registeredCommands, out command);
|
||||||
Assert.Equal("1", command.Properties["col"]);
|
Assert.Equal("1", command.Properties["col"]);
|
||||||
IssueCommandExtension.ValidateLinesAndColumns(command, _ec.Object);
|
IssueCommandExtension.ValidateLinesAndColumns(command, _ec.Object);
|
||||||
Assert.False(command.Properties.ContainsKey("col"));
|
Assert.False(command.Properties.ContainsKey("col"));
|
||||||
|
|
||||||
// No lines with columns
|
// No lines with columns
|
||||||
ActionCommand.TryParseV2("::warning col=1,endColumn=2::this is a warning", registeredCommands, out command);
|
ActionCommand.TryParseV2("::warning col=1,endColumn=2::this is a warning", registeredCommands, out command);
|
||||||
Assert.Equal("1", command.Properties["col"]);
|
Assert.Equal("1", command.Properties["col"]);
|
||||||
@@ -459,19 +375,5 @@ namespace GitHub.Runner.Common.Tests.Worker
|
|||||||
|
|
||||||
return hostContext;
|
return hostContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DictionaryContextData GetExpressionValues()
|
|
||||||
{
|
|
||||||
return new DictionaryContextData
|
|
||||||
{
|
|
||||||
["env"] =
|
|
||||||
#if OS_WINDOWS
|
|
||||||
new DictionaryContextData()
|
|
||||||
#else
|
|
||||||
new CaseSensitiveDictionaryContextData()
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
2.283.3
|
2.283.1
|
||||||
|
|||||||
Reference in New Issue
Block a user