Improve Debugging Messages for Empty Tokens (#609)

* Improve Debugging Messages for Empty Tokens

* fix tests
This commit is contained in:
Ethan Chiu
2020-07-22 17:34:40 -04:00
committed by GitHub
parent bd1f245aac
commit 3d0147d322
2 changed files with 7 additions and 7 deletions

View File

@@ -135,7 +135,7 @@ namespace GitHub.Runner.Worker
// Evaluate Runs Last // Evaluate Runs Last
if (actionRunValueToken != null) if (actionRunValueToken != null)
{ {
actionDefinition.Execution = ConvertRuns(executionContext, templateContext, actionRunValueToken, actionOutputs); actionDefinition.Execution = ConvertRuns(executionContext, templateContext, actionRunValueToken, fileRelativePath, actionOutputs);
} }
} }
catch (Exception ex) catch (Exception ex)
@@ -359,6 +359,7 @@ namespace GitHub.Runner.Worker
IExecutionContext executionContext, IExecutionContext executionContext,
TemplateContext templateContext, TemplateContext templateContext,
TemplateToken inputsToken, TemplateToken inputsToken,
String fileRelativePath,
MappingToken outputs = null) MappingToken outputs = null)
{ {
var runsMapping = inputsToken.AssertMapping("runs"); var runsMapping = inputsToken.AssertMapping("runs");
@@ -442,7 +443,7 @@ namespace GitHub.Runner.Worker
{ {
if (string.IsNullOrEmpty(imageToken?.Value)) 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 else
{ {
@@ -463,7 +464,7 @@ namespace GitHub.Runner.Worker
{ {
if (string.IsNullOrEmpty(mainToken?.Value)) 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 else
{ {
@@ -481,8 +482,7 @@ namespace GitHub.Runner.Worker
{ {
if (steps == null) 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($"You are using a composite action but there are no steps provided in {fileRelativePath}.");
throw new ArgumentNullException($"No steps provided.");
} }
else else
{ {

View File

@@ -846,7 +846,7 @@ namespace GitHub.Runner.Common.Tests.Worker
{ {
var traceFile = Path.GetTempFileName(); var traceFile = Path.GetTempFileName();
File.Copy(_hc.TraceFileName, traceFile, true); 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 finally
@@ -2466,7 +2466,7 @@ runs:
{ {
var traceFile = Path.GetTempFileName(); var traceFile = Path.GetTempFileName();
File.Copy(_hc.TraceFileName, traceFile, true); 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 finally