mirror of
https://github.com/actions/runner.git
synced 2025-12-10 12:36:23 +00:00
Fix detecting if the step is run: make
This commit is contained in:
@@ -266,7 +266,7 @@ namespace GitHub.Runner.Worker
|
|||||||
{
|
{
|
||||||
var action = step as Pipelines.ActionStep;
|
var action = step as Pipelines.ActionStep;
|
||||||
|
|
||||||
void EmitStep()
|
void EmitStep(Pipelines.ActionStep action)
|
||||||
{
|
{
|
||||||
Trace.Info($"Adding {action.DisplayName}.");
|
Trace.Info($"Adding {action.DisplayName}.");
|
||||||
var actionRunner = HostContext.CreateService<IActionRunner>();
|
var actionRunner = HostContext.CreateService<IActionRunner>();
|
||||||
@@ -295,48 +295,61 @@ namespace GitHub.Runner.Worker
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HACK: if the step is "run: make," parse the Makefile and emit $"make dependency {target}"
|
// HACK: if the step is "run: make," parse the Makefile and emit $"make dependency {target}"
|
||||||
if (action.DisplayName == "Run make")
|
// Only works for the default target right now.
|
||||||
|
bool isRunMake = false;
|
||||||
|
if (action.Reference?.Type == Pipelines.ActionSourceType.Script)
|
||||||
{
|
{
|
||||||
// Load the inputs.
|
var inputs = action.Inputs.AssertMapping(null);
|
||||||
jobContext.Debug("Loading inputs");
|
foreach (var pair in inputs)
|
||||||
var inputs = templateEvaluator.EvaluateStepInputs(action.Inputs, jobContext.ExpressionValues, jobContext.ExpressionFunctions);
|
|
||||||
|
|
||||||
// Check if we are running a Makefile.
|
|
||||||
// Only works for the default target right now.
|
|
||||||
if (inputs["script"] == "make")
|
|
||||||
{
|
{
|
||||||
// Get the path of the Makefile in the repository root.
|
var propertyName = pair.Key.AssertString($"{PipelineTemplateConstants.Steps}");
|
||||||
var githubContext = jobContext.ExpressionValues["github"] as GitHubContext;
|
if (string.Equals(propertyName.Value, "script", StringComparison.OrdinalIgnoreCase))
|
||||||
var workspaceDir = githubContext["workspace"] as StringContextData;
|
{
|
||||||
var makefile = Path.Combine(workspaceDir, "Makefile");
|
var tokenToParse = pair.Value.AssertScalar($"{PipelineTemplateConstants.Steps} item {PipelineTemplateConstants.Run}");
|
||||||
if (!File.Exists(makefile))
|
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 = MakefileManager.ReadTargetDependencies(jobContext, makefile, target: "all");
|
||||||
|
if (targetDependencies.Count == 0)
|
||||||
{
|
{
|
||||||
// Forget about trying to be smart. Just do the normal thing.
|
// Forget about trying to be smart. Just do the normal thing.
|
||||||
EmitStep();
|
EmitStep(action);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Assume the default target is named `all`.
|
foreach (var target in targetDependencies)
|
||||||
var targetDependencies = MakefileManager.ReadTargetDependencies(jobContext, makefile, target: "all");
|
|
||||||
if (targetDependencies.Count == 0)
|
|
||||||
{
|
{
|
||||||
// Forget about trying to be smart. Just do the normal thing.
|
action = (Pipelines.ActionStep)action.Clone();
|
||||||
EmitStep();
|
action.Id = Guid.NewGuid();
|
||||||
}
|
action.DisplayName = $"make dependency {target}";
|
||||||
else
|
EmitStep(action);
|
||||||
{
|
|
||||||
foreach (var target in targetDependencies)
|
|
||||||
{
|
|
||||||
action.DisplayName = $"make dependency {target}";
|
|
||||||
EmitStep();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
EmitStep();
|
EmitStep(action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user