From cd8e4ddba19f79874650ec54ba786c51d771f54e Mon Sep 17 00:00:00 2001 From: Tingluo Huang Date: Tue, 12 May 2020 16:09:13 -0400 Subject: [PATCH] Validate inputs only for repo action, no warning for small delay. (#476) * validate inputs only for repo action, no warning for small delay. * l0 --- src/Runner.Worker/ActionRunner.cs | 10 +++++++--- src/Runner.Worker/ExecutionContext.cs | 6 ++++-- src/Test/L0/Worker/ActionRunnerL0.cs | 5 +++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Runner.Worker/ActionRunner.cs b/src/Runner.Worker/ActionRunner.cs index b0c245ac3..78c7943c7 100644 --- a/src/Runner.Worker/ActionRunner.cs +++ b/src/Runner.Worker/ActionRunner.cs @@ -170,11 +170,15 @@ namespace GitHub.Runner.Worker } } - foreach (var input in userInputs) + // Validate inputs only for actions with action.yml + if (Action.Reference.Type == Pipelines.ActionSourceType.Repository) { - if (!validInputs.Contains(input)) + foreach (var input in userInputs) { - ExecutionContext.Warning($"Unexpected input '{input}', valid inputs are ['{string.Join("', '", validInputs)}']"); + if (!validInputs.Contains(input)) + { + ExecutionContext.Warning($"Unexpected input '{input}', valid inputs are ['{string.Join("', '", validInputs)}']"); + } } } diff --git a/src/Runner.Worker/ExecutionContext.cs b/src/Runner.Worker/ExecutionContext.cs index f47629bf3..54dbe3826 100644 --- a/src/Runner.Worker/ExecutionContext.cs +++ b/src/Runner.Worker/ExecutionContext.cs @@ -109,6 +109,7 @@ namespace GitHub.Runner.Worker public sealed class ExecutionContext : RunnerService, IExecutionContext { private const int _maxIssueCount = 10; + private const int _throttlingDelayReportThreshold = 10 * 1000; // Don't report throttling with less than 10 seconds delay private readonly TimelineRecord _record = new TimelineRecord(); private readonly Dictionary _detailRecords = new Dictionary(); @@ -335,7 +336,7 @@ namespace GitHub.Runner.Worker } // report total delay caused by server throttling. - if (_totalThrottlingDelayInMilliseconds > 0) + if (_totalThrottlingDelayInMilliseconds > _throttlingDelayReportThreshold) { this.Warning($"The job has experienced {TimeSpan.FromMilliseconds(_totalThrottlingDelayInMilliseconds).TotalSeconds} seconds total delay caused by server throttling."); } @@ -851,7 +852,8 @@ namespace GitHub.Runner.Worker { Interlocked.Add(ref _totalThrottlingDelayInMilliseconds, Convert.ToInt64(data.Delay.TotalMilliseconds)); - if (!_throttlingReported) + if (!_throttlingReported && + _totalThrottlingDelayInMilliseconds > _throttlingDelayReportThreshold) { this.Warning(string.Format("The job is currently being throttled by the server. You may experience delays in console line output, job status reporting, and action log uploads.")); diff --git a/src/Test/L0/Worker/ActionRunnerL0.cs b/src/Test/L0/Worker/ActionRunnerL0.cs index 73f215a3f..f8185d26d 100644 --- a/src/Test/L0/Worker/ActionRunnerL0.cs +++ b/src/Test/L0/Worker/ActionRunnerL0.cs @@ -295,9 +295,10 @@ namespace GitHub.Runner.Common.Tests.Worker { Name = "action", Id = actionId, - Reference = new Pipelines.ContainerRegistryReference() + Reference = new Pipelines.RepositoryPathReference() { - Image = "ubuntu:16.04" + Name = "actions/runner", + Ref = "v1" }, Inputs = actionInputs };