Skip to content

Commit 2494aa2

Browse files
committed
Add warning to notify about forcing node16 (#2678)
* add warning * fix tests * aggregate to one warning * fix linter * fix comm
1 parent 9ef4121 commit 2494aa2

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

src/Runner.Common/Constants.cs

+2
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ public static class Features
170170
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";
171171
public static readonly string SummaryUploadError = "$GITHUB_STEP_SUMMARY upload aborted, an error occurred when uploading the summary. For more information see: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-markdown-summary";
172172
public static readonly string Node12DetectedAfterEndOfLife = "Node.js 12 actions are deprecated. Please update the following actions to use Node.js 16: {0}. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/.";
173+
public static readonly string EnforcedNode12DetectedAfterEndOfLife = "The following actions uses node12 which is deprecated and will be forced to run on node16: {0}. For more info: https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/";
174+
public static readonly string EnforcedNode12DetectedAfterEndOfLifeEnvVariable = "Node16ForceActionsWarnings";
173175
}
174176

175177
public static class RunnerEvent

src/Runner.Worker/Handlers/HandlerFactory.cs

+22
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,28 @@ public IHandler Create(
6868
bool isOptOut = isWorkflowOptOutSet ? StringUtil.ConvertToBoolean(workflowOptOut) : isLocalOptOut;
6969
if (!isOptOut)
7070
{
71+
var repoAction = action as Pipelines.RepositoryPathReference;
72+
if (repoAction != null)
73+
{
74+
var warningActions = new HashSet<string>();
75+
if (executionContext.Global.Variables.TryGetValue(Constants.Runner.EnforcedNode12DetectedAfterEndOfLifeEnvVariable, out var node16ForceWarnings))
76+
{
77+
warningActions = StringUtil.ConvertFromJson<HashSet<string>>(node16ForceWarnings);
78+
}
79+
80+
var repoActionFullName = "";
81+
if (string.IsNullOrEmpty(repoAction.Name))
82+
{
83+
repoActionFullName = repoAction.Path; // local actions don't have a 'Name'
84+
}
85+
else
86+
{
87+
repoActionFullName = $"{repoAction.Name}/{repoAction.Path ?? string.Empty}".TrimEnd('/') + $"@{repoAction.Ref}";
88+
}
89+
90+
warningActions.Add(repoActionFullName);
91+
executionContext.Global.Variables.Set("Node16ForceActionsWarnings", StringUtil.ConvertToJson(warningActions));
92+
}
7193
nodeData.NodeVersion = "node16";
7294
}
7395
}

src/Runner.Worker/JobRunner.cs

+6
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,12 @@ private async Task<TaskResult> CompleteJobAsync(IJobServer jobServer, IExecution
348348
jobContext.Warning(string.Format(Constants.Runner.Node12DetectedAfterEndOfLife, actions));
349349
}
350350

351+
if (jobContext.Global.Variables.TryGetValue(Constants.Runner.EnforcedNode12DetectedAfterEndOfLifeEnvVariable, out var node16ForceWarnings))
352+
{
353+
var actions = string.Join(", ", StringUtil.ConvertFromJson<HashSet<string>>(node16ForceWarnings));
354+
jobContext.Warning(string.Format(Constants.Runner.EnforcedNode12DetectedAfterEndOfLife, actions));
355+
}
356+
351357
try
352358
{
353359
await ShutdownQueue(throwOnFailure: true);

0 commit comments

Comments
 (0)