From 3d0147d322d6be1424e73dce97ebf5aaa2ebcbae Mon Sep 17 00:00:00 2001 From: Ethan Chiu <17chiue@gmail.com> Date: Wed, 22 Jul 2020 17:34:40 -0400 Subject: [PATCH] Improve Debugging Messages for Empty Tokens (#609) * Improve Debugging Messages for Empty Tokens * fix tests --- src/Runner.Worker/ActionManifestManager.cs | 10 +++++----- src/Test/L0/Worker/ActionManagerL0.cs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Runner.Worker/ActionManifestManager.cs b/src/Runner.Worker/ActionManifestManager.cs index 5be77c174..aa6637f85 100644 --- a/src/Runner.Worker/ActionManifestManager.cs +++ b/src/Runner.Worker/ActionManifestManager.cs @@ -135,7 +135,7 @@ namespace GitHub.Runner.Worker // Evaluate Runs Last if (actionRunValueToken != null) { - actionDefinition.Execution = ConvertRuns(executionContext, templateContext, actionRunValueToken, actionOutputs); + actionDefinition.Execution = ConvertRuns(executionContext, templateContext, actionRunValueToken, fileRelativePath, actionOutputs); } } catch (Exception ex) @@ -359,6 +359,7 @@ namespace GitHub.Runner.Worker IExecutionContext executionContext, TemplateContext templateContext, TemplateToken inputsToken, + String fileRelativePath, MappingToken outputs = null) { var runsMapping = inputsToken.AssertMapping("runs"); @@ -442,7 +443,7 @@ namespace GitHub.Runner.Worker { if (string.IsNullOrEmpty(imageToken?.Value)) { - throw new ArgumentNullException($"Image is not provided."); + throw new ArgumentNullException($"You are using a Container Action but an image is not provided in {fileRelativePath}."); } else { @@ -463,7 +464,7 @@ namespace GitHub.Runner.Worker { if (string.IsNullOrEmpty(mainToken?.Value)) { - throw new ArgumentNullException($"Entry javascript file is not provided."); + throw new ArgumentNullException($"You are using a JavaScript Action but there is not an entry JavaScript file provided in {fileRelativePath}."); } else { @@ -481,8 +482,7 @@ namespace GitHub.Runner.Worker { if (steps == null) { - // TODO: Add a more helpful error message + including file name, etc. to show user that it's because of their yaml file - throw new ArgumentNullException($"No steps provided."); + throw new ArgumentNullException($"You are using a composite action but there are no steps provided in {fileRelativePath}."); } else { diff --git a/src/Test/L0/Worker/ActionManagerL0.cs b/src/Test/L0/Worker/ActionManagerL0.cs index 0481d9894..0a343ebc1 100644 --- a/src/Test/L0/Worker/ActionManagerL0.cs +++ b/src/Test/L0/Worker/ActionManagerL0.cs @@ -846,7 +846,7 @@ namespace GitHub.Runner.Common.Tests.Worker { var traceFile = Path.GetTempFileName(); File.Copy(_hc.TraceFileName, traceFile, true); - Assert.Contains("Entry javascript file is not provided.", File.ReadAllText(traceFile)); + Assert.Contains("You are using a JavaScript Action but there is not an entry JavaScript file provided in", File.ReadAllText(traceFile)); } } finally @@ -2466,7 +2466,7 @@ runs: { var traceFile = Path.GetTempFileName(); File.Copy(_hc.TraceFileName, traceFile, true); - Assert.Contains("Entry javascript file is not provided.", File.ReadAllText(traceFile)); + Assert.Contains("You are using a JavaScript Action but there is not an entry JavaScript file provided in", File.ReadAllText(traceFile)); } } finally