mirror of
https://github.com/actions/runner.git
synced 2025-12-10 12:36:23 +00:00
Compare commits
18 Commits
v2.283.2
...
brcrista/m
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8a53aa04a | ||
|
|
9fe65b872a | ||
|
|
ec420bab24 | ||
|
|
07cda747b2 | ||
|
|
9ca132380c | ||
|
|
a5a0f8df47 | ||
|
|
ccf53338be | ||
|
|
400b2d879c | ||
|
|
c4b6d288d4 | ||
|
|
0699597876 | ||
|
|
a592b14ae3 | ||
|
|
04269f7b1b | ||
|
|
e89d2e84bd | ||
|
|
afe7066e39 | ||
|
|
da79ef4acb | ||
|
|
5afb52b272 | ||
|
|
cf87c55557 | ||
|
|
43fa351980 |
@@ -2,15 +2,10 @@
|
||||
|
||||
## Bugs
|
||||
|
||||
- Fixed an issue where ephemeral runners deregistered themselves when jobs were not successful (#1384)
|
||||
- Fixed an issue where you were not able to un-configure a runner that changed groups (#1359)
|
||||
- Disable `stop-commands` command using well known keywords as a token (#1371)
|
||||
- Fixed an issue where ephemeral runners did not restart after upgrading (#1396)
|
||||
|
||||
## Misc
|
||||
|
||||
- Don't retry 422 error codes when downloading actions (#1352)
|
||||
- Handle upgrade more smoothly on OSX (#1381)
|
||||
|
||||
## 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 @@
|
||||
2.283.2
|
||||
<Update to ./src/runnerversion when creating release>
|
||||
|
||||
@@ -25,5 +25,7 @@
|
||||
</dict>
|
||||
<key>ProcessType</key>
|
||||
<string>Interactive</string>
|
||||
<key>SessionCreate</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -43,6 +43,21 @@ else
|
||||
else
|
||||
sleep 5
|
||||
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
|
||||
exit $returnCode
|
||||
fi
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using GitHub.Runner.Sdk;
|
||||
using GitHub.Services.Common;
|
||||
using GitHub.Services.WebApi;
|
||||
|
||||
namespace GitHub.Runner.Common
|
||||
@@ -36,6 +39,9 @@ namespace GitHub.Runner.Common
|
||||
{
|
||||
_connection = jobConnection;
|
||||
int attemptCount = 5;
|
||||
var configurationStore = HostContext.GetService<IConfigurationStore>();
|
||||
var runnerSettings = configurationStore.GetSettings();
|
||||
|
||||
while (!_connection.HasAuthenticated && attemptCount-- > 0)
|
||||
{
|
||||
try
|
||||
@@ -45,8 +51,13 @@ namespace GitHub.Runner.Common
|
||||
}
|
||||
catch (Exception ex) when (attemptCount > 0)
|
||||
{
|
||||
Trace.Info($"Catch exception during connect. {attemptCount} attemp left.");
|
||||
Trace.Info($"Catch exception during connect. {attemptCount} attempts left.");
|
||||
Trace.Error(ex);
|
||||
|
||||
if (runnerSettings.IsHostedServer)
|
||||
{
|
||||
await CheckNetworkEndpointsAsync();
|
||||
}
|
||||
}
|
||||
|
||||
await Task.Delay(100);
|
||||
@@ -56,6 +67,52 @@ namespace GitHub.Runner.Common
|
||||
_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()
|
||||
{
|
||||
if (!_hasConnection)
|
||||
|
||||
@@ -262,6 +262,16 @@ namespace GitHub.Runner.Worker
|
||||
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.
|
||||
IHandler handler = handlerFactory.Create(
|
||||
ExecutionContext,
|
||||
|
||||
@@ -31,8 +31,8 @@ namespace GitHub.Runner.Worker.Handlers
|
||||
|
||||
Inputs.TryGetValue("script", out string contents);
|
||||
contents = contents ?? string.Empty;
|
||||
if (Action.Type == Pipelines.ActionSourceType.Script)
|
||||
{
|
||||
// if (Action.Type == Pipelines.ActionSourceType.Script)
|
||||
// {
|
||||
var firstLine = contents.TrimStart(' ', '\t', '\r', '\n');
|
||||
var firstNewLine = firstLine.IndexOfAny(new[] { '\r', '\n' });
|
||||
if (firstNewLine >= 0)
|
||||
@@ -41,11 +41,11 @@ namespace GitHub.Runner.Worker.Handlers
|
||||
}
|
||||
|
||||
ExecutionContext.Output($"##[group]Run {firstLine}");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException($"Invalid action type {Action.Type} for {nameof(ScriptHandler)}");
|
||||
}
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// throw new InvalidOperationException($"Invalid action type {Action.Type} for {nameof(ScriptHandler)}");
|
||||
// }
|
||||
|
||||
var multiLines = contents.Replace("\r\n", "\n").TrimEnd('\n').Split('\n');
|
||||
foreach (var line in multiLines)
|
||||
|
||||
@@ -265,29 +265,91 @@ namespace GitHub.Runner.Worker
|
||||
if (step.Type == Pipelines.StepType.Action)
|
||||
{
|
||||
var action = step as Pipelines.ActionStep;
|
||||
Trace.Info($"Adding {action.DisplayName}.");
|
||||
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)
|
||||
|
||||
void EmitStep(Pipelines.ActionStep action)
|
||||
{
|
||||
foreach (var pair in message.ContextData)
|
||||
Trace.Info($"Adding {action.DisplayName}.");
|
||||
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)
|
||||
{
|
||||
contextData[pair.Key] = pair.Value;
|
||||
foreach (var pair in message.ContextData)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
actionRunner.TryEvaluateDisplayName(contextData, context);
|
||||
jobSteps.Add(actionRunner);
|
||||
|
||||
if (prepareResult.PreStepTracker.TryGetValue(step.Id, out var preStep))
|
||||
// HACK: if the step is "run: make," parse the Makefile and emit $"make dependency {target}"
|
||||
// Only works for the default target right now.
|
||||
bool isRunMake = false;
|
||||
if (action.Reference?.Type == Pipelines.ActionSourceType.Script)
|
||||
{
|
||||
Trace.Info($"Adding pre-{action.DisplayName}.");
|
||||
preStep.TryEvaluateDisplayName(contextData, context);
|
||||
preStep.DisplayName = $"Pre {preStep.DisplayName}";
|
||||
preJobSteps.Add(preStep);
|
||||
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)
|
||||
{
|
||||
// Get the path of the Makefile in the repository root.
|
||||
var githubContext = jobContext.ExpressionValues["github"] as GitHubContext;
|
||||
var workspaceDir = githubContext["workspace"] as StringContextData;
|
||||
var makefile = Path.Combine(workspaceDir, "Makefile");
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
24
src/Runner.Worker/MakefileReader.cs
Normal file
24
src/Runner.Worker/MakefileReader.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
2.283.2
|
||||
2.283.3
|
||||
|
||||
Reference in New Issue
Block a user