From f9c2bf1dd72541bf039c3c5fa4129814181ca261 Mon Sep 17 00:00:00 2001 From: Ava Stancu Date: Tue, 16 Aug 2022 17:17:42 +0200 Subject: [PATCH] Improved error logs for missing 'using' configuration in metadata file (#2052) Co-authored-by: Octavia Stancu --- src/Runner.Worker/ActionManifestManager.cs | 2 +- src/Test/L0/Worker/ActionManifestManagerL0.cs | 25 +++++++++++++++++++ .../composite_action_without_using_token.yml | 9 +++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/Test/TestData/composite_action_without_using_token.yml diff --git a/src/Runner.Worker/ActionManifestManager.cs b/src/Runner.Worker/ActionManifestManager.cs index 3740128443f..193c8a6eed9 100644 --- a/src/Runner.Worker/ActionManifestManager.cs +++ b/src/Runner.Worker/ActionManifestManager.cs @@ -503,7 +503,7 @@ private ActionExecutionData ConvertRuns( }; } - throw new NotSupportedException(nameof(ConvertRuns)); + throw new NotSupportedException("Missing 'using' value. 'using' requires 'composite', 'docker', 'node12' or 'node16'."); } private void ConvertInputs( diff --git a/src/Test/L0/Worker/ActionManifestManagerL0.cs b/src/Test/L0/Worker/ActionManifestManagerL0.cs index d11f3c1e85c..b6e3f855b34 100644 --- a/src/Test/L0/Worker/ActionManifestManagerL0.cs +++ b/src/Test/L0/Worker/ActionManifestManagerL0.cs @@ -698,6 +698,31 @@ public void Load_ConditionalCompositeAction() } } + [Fact] + [Trait("Level", "L0")] + [Trait("Category", "Worker")] + public void Load_CompositeActionNoUsing() + { + try + { + //Arrange + Setup(); + + var actionManifest = new ActionManifestManager(); + actionManifest.Initialize(_hc); + var action_path = Path.Combine(TestUtil.GetTestDataPath(), "composite_action_without_using_token.yml"); + + //Assert + var err = Assert.Throws(() => actionManifest.Load(_ec.Object, action_path)); + Assert.Contains($"Fail to load {action_path}", err.Message); + _ec.Verify(x => x.AddIssue(It.Is(s => s.Message.Contains("Missing 'using' value. 'using' requires 'composite', 'docker', 'node12' or 'node16'.")), It.IsAny()), Times.Once); + } + finally + { + Teardown(); + } + } + [Fact] [Trait("Level", "L0")] [Trait("Category", "Worker")] diff --git a/src/Test/TestData/composite_action_without_using_token.yml b/src/Test/TestData/composite_action_without_using_token.yml new file mode 100644 index 00000000000..6f8a4b5fe22 --- /dev/null +++ b/src/Test/TestData/composite_action_without_using_token.yml @@ -0,0 +1,9 @@ +name: "composite action" +description: "test composite action without value for the 'using' token in 'runs'" + +runs: + steps: + - id: mystep + shell: bash + run: | + echo "hello world"