From 72fc37b4bad77056348cdcb0429cfee62b5a2656 Mon Sep 17 00:00:00 2001 From: Francesco Renzi Date: Thu, 29 Sep 2022 12:54:48 +0000 Subject: [PATCH 1/3] Add warning for users using deprecated commands --- src/Runner.Common/Constants.cs | 1 + src/Runner.Worker/ActionCommandManager.cs | 25 ++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Runner.Common/Constants.cs b/src/Runner.Common/Constants.cs index 979e33d5694..33ab3ce0451 100644 --- a/src/Runner.Common/Constants.cs +++ b/src/Runner.Common/Constants.cs @@ -159,6 +159,7 @@ public static class Features public static readonly string WorkerCrash = "WORKER_CRASH"; public static readonly string LowDiskSpace = "LOW_DISK_SPACE"; public static readonly string UnsupportedCommand = "UNSUPPORTED_COMMAND"; + public static readonly string UnsupportedCommandMessage = "The `{0}` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/"; public static readonly string UnsupportedCommandMessageDisabled = "The `{0}` command is disabled. Please upgrade to using Environment Files or opt into unsecure command execution by setting the `ACTIONS_ALLOW_UNSECURE_COMMANDS` environment variable to `true`. For more information see: https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/"; public static readonly string UnsupportedStopCommandTokenDisabled = "You cannot use a endToken that is an empty string, the string 'pause-logging', or another workflow command. For more information see: https://docs.github.com/actions/learn-github-actions/workflow-commands-for-github-actions#example-stopping-and-starting-workflow-commands or opt into insecure command execution by setting the `ACTIONS_ALLOW_UNSECURE_STOPCOMMAND_TOKENS` environment variable to `true`."; public static readonly string UnsupportedSummarySize = "$GITHUB_STEP_SUMMARY upload aborted, supports content up to a size of {0}k, got {1}k. For more information see: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-markdown-summary"; diff --git a/src/Runner.Worker/ActionCommandManager.cs b/src/Runner.Worker/ActionCommandManager.cs index a705d67ed40..4b4d4937944 100644 --- a/src/Runner.Worker/ActionCommandManager.cs +++ b/src/Runner.Worker/ActionCommandManager.cs @@ -307,6 +307,17 @@ public sealed class SetOutputCommandExtension : RunnerService, IActionCommandExt public void ProcessCommand(IExecutionContext context, string line, ActionCommand command, ContainerInfo container) { + if (context.Global.Variables.GetBoolean("DistributedTask.DeprecateOldWorkflowCommands2") ?? false) + { + var issue = new Issue() + { + Type = IssueType.Warning, + Message = String.Format(Constants.Runner.UnsupportedCommandMessage, this.Command) + }; + issue.Data[Constants.Runner.InternalTelemetryIssueDataKey] = Constants.Runner.UnsupportedCommand; + context.AddIssue(issue); + } + if (!command.Properties.TryGetValue(SetOutputCommandProperties.Name, out string outputName) || string.IsNullOrEmpty(outputName)) { throw new Exception("Required field 'name' is missing in ##[set-output] command."); @@ -331,6 +342,18 @@ public sealed class SaveStateCommandExtension : RunnerService, IActionCommandExt public void ProcessCommand(IExecutionContext context, string line, ActionCommand command, ContainerInfo container) { + if (context.Global.Variables.GetBoolean("DistributedTask.DeprecateOldWorkflowCommands2") ?? false) + { + var issue = new Issue() + { + Type = IssueType.Warning, + Message = String.Format(Constants.Runner.UnsupportedCommandMessage, this.Command) + }; + issue.Data[Constants.Runner.InternalTelemetryIssueDataKey] = Constants.Runner.UnsupportedCommand; + context.AddIssue(issue); + } + + if (!command.Properties.TryGetValue(SaveStateCommandProperties.Name, out string stateName) || string.IsNullOrEmpty(stateName)) { throw new Exception("Required field 'name' is missing in ##[save-state] command."); @@ -586,7 +609,7 @@ public abstract class IssueCommandExtension : RunnerService, IActionCommandExten public void ProcessCommand(IExecutionContext context, string inputLine, ActionCommand command, ContainerInfo container) { ValidateLinesAndColumns(command, context); - + command.Properties.TryGetValue(IssueCommandProperties.File, out string file); command.Properties.TryGetValue(IssueCommandProperties.Line, out string line); command.Properties.TryGetValue(IssueCommandProperties.Column, out string column); From 07c96658d705c510152d4ed71cdfe7cdd0d36e48 Mon Sep 17 00:00:00 2001 From: Francesco Renzi Date: Thu, 29 Sep 2022 13:13:57 +0000 Subject: [PATCH 2/3] Rename feature flag --- src/Runner.Worker/ActionCommandManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Runner.Worker/ActionCommandManager.cs b/src/Runner.Worker/ActionCommandManager.cs index 4b4d4937944..2fbf23c9ca9 100644 --- a/src/Runner.Worker/ActionCommandManager.cs +++ b/src/Runner.Worker/ActionCommandManager.cs @@ -307,7 +307,7 @@ public sealed class SetOutputCommandExtension : RunnerService, IActionCommandExt public void ProcessCommand(IExecutionContext context, string line, ActionCommand command, ContainerInfo container) { - if (context.Global.Variables.GetBoolean("DistributedTask.DeprecateOldWorkflowCommands2") ?? false) + if (context.Global.Variables.GetBoolean("DistributedTask.DeprecateStepOutputCommands") ?? false) { var issue = new Issue() { @@ -342,7 +342,7 @@ public sealed class SaveStateCommandExtension : RunnerService, IActionCommandExt public void ProcessCommand(IExecutionContext context, string line, ActionCommand command, ContainerInfo container) { - if (context.Global.Variables.GetBoolean("DistributedTask.DeprecateOldWorkflowCommands2") ?? false) + if (context.Global.Variables.GetBoolean("DistributedTask.DeprecateStepOutputCommands") ?? false) { var issue = new Issue() { From 1a7b3e01178f070c770d9709c667812737b2b6a7 Mon Sep 17 00:00:00 2001 From: Francesco Renzi Date: Mon, 3 Oct 2022 16:00:08 +0000 Subject: [PATCH 3/3] Remove empty line --- src/Runner.Worker/ActionCommandManager.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Runner.Worker/ActionCommandManager.cs b/src/Runner.Worker/ActionCommandManager.cs index 2fbf23c9ca9..e301515da02 100644 --- a/src/Runner.Worker/ActionCommandManager.cs +++ b/src/Runner.Worker/ActionCommandManager.cs @@ -353,7 +353,6 @@ public void ProcessCommand(IExecutionContext context, string line, ActionCommand context.AddIssue(issue); } - if (!command.Properties.TryGetValue(SaveStateCommandProperties.Name, out string stateName) || string.IsNullOrEmpty(stateName)) { throw new Exception("Required field 'name' is missing in ##[save-state] command.");