diff --git a/src/Misc/externals.sh b/src/Misc/externals.sh index bc90fea1c63..8c5f5e51580 100755 --- a/src/Misc/externals.sh +++ b/src/Misc/externals.sh @@ -4,6 +4,7 @@ PRECACHE=$2 NODE_URL=https://nodejs.org/dist NODE12_VERSION="12.13.1" +NODE14_VERSION="14.17.0" get_abs_path() { # exploits the fact that pwd will print abs path when no args @@ -126,6 +127,8 @@ function acquireExternalTool() { if [[ "$PACKAGERUNTIME" == "win-x64" || "$PACKAGERUNTIME" == "win-x86" ]]; then acquireExternalTool "$NODE_URL/v${NODE12_VERSION}/$PACKAGERUNTIME/node.exe" node12/bin acquireExternalTool "$NODE_URL/v${NODE12_VERSION}/$PACKAGERUNTIME/node.lib" node12/bin + acquireExternalTool "$NODE_URL/v${NODE14_VERSION}/$PACKAGERUNTIME/node.exe" node14/bin + acquireExternalTool "$NODE_URL/v${NODE14_VERSION}/$PACKAGERUNTIME/node.lib" node14/bin if [[ "$PRECACHE" != "" ]]; then acquireExternalTool "https://github.com/microsoft/vswhere/releases/download/2.6.7/vswhere.exe" vswhere fi @@ -134,18 +137,23 @@ fi # Download the external tools only for OSX. if [[ "$PACKAGERUNTIME" == "osx-x64" ]]; then acquireExternalTool "$NODE_URL/v${NODE12_VERSION}/node-v${NODE12_VERSION}-darwin-x64.tar.gz" node12 fix_nested_dir + acquireExternalTool "$NODE_URL/v${NODE14_VERSION}/node-v${NODE14_VERSION}-darwin-x64.tar.gz" node14 fix_nested_dir fi # Download the external tools for Linux PACKAGERUNTIMEs. if [[ "$PACKAGERUNTIME" == "linux-x64" ]]; then acquireExternalTool "$NODE_URL/v${NODE12_VERSION}/node-v${NODE12_VERSION}-linux-x64.tar.gz" node12 fix_nested_dir acquireExternalTool "https://vstsagenttools.blob.core.windows.net/tools/nodejs/${NODE12_VERSION}/alpine/x64/node-${NODE12_VERSION}-alpine-x64.tar.gz" node12_alpine + acquireExternalTool "$NODE_URL/v${NODE14_VERSION}/node-v${NODE14_VERSION}-linux-x64.tar.gz" node14 fix_nested_dir + acquireExternalTool "https://unofficial-builds.nodejs.org/download/release/v${NODE14_VERSION}/node-v${NODE14_VERSION}-linux-x64-musl.tar.xz" node14_alpine fi if [[ "$PACKAGERUNTIME" == "linux-arm64" ]]; then acquireExternalTool "$NODE_URL/v${NODE12_VERSION}/node-v${NODE12_VERSION}-linux-arm64.tar.gz" node12 fix_nested_dir + acquireExternalTool "$NODE_URL/v${NODE14_VERSION}/node-v${NODE14_VERSION}-linux-arm64.tar.gz" node14 fix_nested_dir fi if [[ "$PACKAGERUNTIME" == "linux-arm" ]]; then acquireExternalTool "$NODE_URL/v${NODE12_VERSION}/node-v${NODE12_VERSION}-linux-armv7l.tar.gz" node12 fix_nested_dir + acquireExternalTool "$NODE_URL/v${NODE14_VERSION}/node-v${NODE14_VERSION}-linux-armv7l.tar.gz" node14 fix_nested_dir fi diff --git a/src/Runner.Worker/ActionManager.cs b/src/Runner.Worker/ActionManager.cs index ceda3dbb375..3b892a71e67 100644 --- a/src/Runner.Worker/ActionManager.cs +++ b/src/Runner.Worker/ActionManager.cs @@ -1216,6 +1216,8 @@ public sealed class NodeJSActionExecutionData : ActionExecutionData public string Pre { get; set; } public string Post { get; set; } + + public string Using { get; set; } = "node12"; } public sealed class PluginActionExecutionData : ActionExecutionData diff --git a/src/Runner.Worker/ActionManifestManager.cs b/src/Runner.Worker/ActionManifestManager.cs index 78d7bf41ac4..17fb3a3a438 100644 --- a/src/Runner.Worker/ActionManifestManager.cs +++ b/src/Runner.Worker/ActionManifestManager.cs @@ -59,7 +59,7 @@ public ActionDefinitionData Load(IExecutionContext executionContext, string mani ActionDefinitionData actionDefinition = new ActionDefinitionData(); // Clean up file name real quick - // Instead of using Regex which can be computationally expensive, + // Instead of using Regex which can be computationally expensive, // we can just remove the # of characters from the fileName according to the length of the basePath string basePath = HostContext.GetDirectory(WellKnownDirectory.Actions); string fileRelativePath = manifestFile; @@ -451,7 +451,10 @@ private ActionExecutionData ConvertRuns( }; } } - else if (string.Equals(usingToken.Value, "node12", StringComparison.OrdinalIgnoreCase)) + else if ( + string.Equals(usingToken.Value, "node12", StringComparison.OrdinalIgnoreCase) || + string.Equals(usingToken.Value, "node14", StringComparison.OrdinalIgnoreCase) + ) { if (string.IsNullOrEmpty(mainToken?.Value)) { @@ -461,6 +464,7 @@ private ActionExecutionData ConvertRuns( { return new NodeJSActionExecutionData() { + Using = usingToken.Value.ToLower(), Script = mainToken.Value, Pre = preToken?.Value, InitCondition = preIfToken?.Value ?? "always()", @@ -486,7 +490,7 @@ private ActionExecutionData ConvertRuns( } else { - throw new ArgumentOutOfRangeException($"'using: {usingToken.Value}' is not supported, use 'docker' or 'node12' instead."); + throw new ArgumentOutOfRangeException($"'using: {usingToken.Value}' is not supported, use 'docker', 'node12', or 'node14' instead."); } } else if (pluginToken != null) diff --git a/src/Runner.Worker/Handlers/NodeScriptActionHandler.cs b/src/Runner.Worker/Handlers/NodeScriptActionHandler.cs index 64b412489c9..7442c6202e8 100644 --- a/src/Runner.Worker/Handlers/NodeScriptActionHandler.cs +++ b/src/Runner.Worker/Handlers/NodeScriptActionHandler.cs @@ -80,7 +80,7 @@ public async Task RunAsync(ActionRunStage stage) workingDirectory = HostContext.GetDirectory(WellKnownDirectory.Work); } - var nodeRuntimeVersion = await StepHost.DetermineNodeRuntimeVersion(ExecutionContext); + var nodeRuntimeVersion = await StepHost.DetermineNodeRuntimeVersion(ExecutionContext, Data.Using); string file = Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Externals), nodeRuntimeVersion, "bin", $"node{IOUtil.ExeExtension}"); // Format the arguments passed to node. diff --git a/src/Runner.Worker/Handlers/StepHost.cs b/src/Runner.Worker/Handlers/StepHost.cs index 0907eaed23e..8101199db5c 100644 --- a/src/Runner.Worker/Handlers/StepHost.cs +++ b/src/Runner.Worker/Handlers/StepHost.cs @@ -23,7 +23,7 @@ public interface IStepHost : IRunnerService string ResolvePathForStepHost(string path); - Task DetermineNodeRuntimeVersion(IExecutionContext executionContext); + Task DetermineNodeRuntimeVersion(IExecutionContext executionContext, string defaultVersion); Task ExecuteAsync(string workingDirectory, string fileName, @@ -58,9 +58,10 @@ public string ResolvePathForStepHost(string path) return path; } - public Task DetermineNodeRuntimeVersion(IExecutionContext executionContext) + public Task DetermineNodeRuntimeVersion(IExecutionContext executionContext, string defaultVersion) { - return Task.FromResult("node12"); + + return Task.FromResult(defaultVersion); } public async Task ExecuteAsync(string workingDirectory, @@ -123,7 +124,7 @@ public string ResolvePathForStepHost(string path) } } - public async Task DetermineNodeRuntimeVersion(IExecutionContext executionContext) + public async Task DetermineNodeRuntimeVersion(IExecutionContext executionContext, string defaultVersion) { // Best effort to determine a compatible node runtime // There may be more variation in which libraries are linked than just musl/glibc, @@ -148,14 +149,14 @@ public async Task DetermineNodeRuntimeVersion(IExecutionContext executio var msg = $"JavaScript Actions in Alpine containers are only supported on x64 Linux runners. Detected {os} {arch}"; throw new NotSupportedException(msg); } - nodeExternal = "node12_alpine"; + nodeExternal = $"{defaultVersion}_alpine"; executionContext.Debug($"Container distribution is alpine. Running JavaScript Action with external tool: {nodeExternal}"); return nodeExternal; } } } // Optimistically use the default - nodeExternal = "node12"; + nodeExternal = defaultVersion; executionContext.Debug($"Running JavaScript Action with default external tool: {nodeExternal}"); return nodeExternal; } diff --git a/src/Runner.Worker/action_yaml.json b/src/Runner.Worker/action_yaml.json index 2873da7cd33..c4d2b83bebe 100644 --- a/src/Runner.Worker/action_yaml.json +++ b/src/Runner.Worker/action_yaml.json @@ -46,7 +46,7 @@ "runs": { "one-of": [ "container-runs", - "node12-runs", + "node-runs", "plugin-runs", "composite-runs" ] @@ -80,7 +80,7 @@ "loose-value-type": "string" } }, - "node12-runs": { + "node-runs": { "mapping": { "properties": { "using": "non-empty-string",