From 738602ee55e515b3ee0e2b95e30d0b236ca349bf Mon Sep 17 00:00:00 2001 From: TingluoHuang Date: Sun, 22 Mar 2020 22:37:23 -0400 Subject: [PATCH] c --- src/Runner.Worker/ActionManager.cs | 4 --- src/Runner.Worker/ActionRunner.cs | 7 +++++ src/Test/L0/Worker/ActionManagerL0.cs | 45 ++------------------------- 3 files changed, 9 insertions(+), 47 deletions(-) diff --git a/src/Runner.Worker/ActionManager.cs b/src/Runner.Worker/ActionManager.cs index c08381211..0ccbd0549 100644 --- a/src/Runner.Worker/ActionManager.cs +++ b/src/Runner.Worker/ActionManager.cs @@ -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."); - } } } } diff --git a/src/Runner.Worker/ActionRunner.cs b/src/Runner.Worker/ActionRunner.cs index 3c0198970..523fdb2fb 100644 --- a/src/Runner.Worker/ActionRunner.cs +++ b/src/Runner.Worker/ActionRunner.cs @@ -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)) diff --git a/src/Test/L0/Worker/ActionManagerL0.cs b/src/Test/L0/Worker/ActionManagerL0.cs index 479ff8b81..2a6e9356b 100644 --- a/src/Test/L0/Worker/ActionManagerL0.cs +++ b/src/Test/L0/Worker/ActionManagerL0.cs @@ -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 - { - 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