This commit is contained in:
TingluoHuang
2020-03-22 22:37:23 -04:00
parent 502b9f06f2
commit 738602ee55
3 changed files with 9 additions and 47 deletions

View File

@@ -139,10 +139,6 @@ namespace GitHub.Runner.Worker
preStepTracker[action.Id] = actionRunner;
}
else if (!definition.Data.Execution.HasMain && definition.Data.Execution.HasCleanup)
{
throw new NotSupportedException($"Action {repoAction.Name}@{repoAction.Ref} only has `post` execution, `pre` or `main` is required for an actions.");
}
}
}
}

View File

@@ -82,6 +82,13 @@ namespace GitHub.Runner.Worker
ActionExecutionData handlerData = definition.Data?.Execution;
ArgUtil.NotNull(handlerData, nameof(handlerData));
if (handlerData.HasInit &&
Action.Reference is Pipelines.RepositoryPathReference repoAction &&
string.Equals(repoAction.RepositoryType, Pipelines.PipelineConstants.SelfAlias, StringComparison.OrdinalIgnoreCase))
{
ExecutionContext.Warning($"`pre` execution is not supported for local action from '{repoAction.Path}'");
}
// The action has post cleanup defined.
// we need to create timeline record for them and add them to the step list that StepRunner is using
if (handlerData.HasCleanup && (Stage == ActionRunStage.Pre || Stage == ActionRunStage.Main))

View File

@@ -659,50 +659,9 @@ namespace GitHub.Runner.Common.Tests.Worker
{
await _actionManager.PrepareActionsAsync(_ec.Object, actions);
}
catch (NotSupportedException e)
catch (ArgumentNullException e)
{
Assert.Contains("`pre` or `main` is required for an actions.", e.Message);
}
}
finally
{
Teardown();
}
}
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]
public async void PrepareActions_RepositoryActionWithInvalidWrapperActionfile_Docker()
{
try
{
//Arrange
Setup();
var actionId = Guid.NewGuid();
var actions = new List<Pipelines.ActionStep>
{
new Pipelines.ActionStep()
{
Name = "action",
Id = actionId,
Reference = new Pipelines.RepositoryPathReference()
{
Name = "TingluoHuang/runner_L0",
Ref = "RepositoryActionWithInvalidWrapperActionfile_Docker",
RepositoryType = "GitHub"
}
}
};
//Act
try
{
await _actionManager.PrepareActionsAsync(_ec.Object, actions);
}
catch (NotSupportedException e)
{
Assert.Contains("`pre` or `main` is required for an actions.", e.Message);
Assert.Contains("Entry javascript fils is not provided.", e.Message);
}
}
finally