actions / runner

The Runner for GitHub Actions :rocket:

Home Page:https://github.com/features/actions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Supporting Node.js 14 and 16 LTS as the runtime of JavaScript action

peaceiris opened this issue · comments

Describe the enhancement

Node.js v14.15.0 has been released and the 14.x release line now moves into Active LTS. Can the GitHub Actions runner support it as the runtime of a JavaScript (TypeScript) action? Is there a roadmap for this?

Code Snippet

Today, we can set node12 to runs.using.

runs:
  using: 'node12'
  main: 'main.js'

Can we set node14 (or node16) as follows?

runs:
  using: 'node14'
  main: 'main.js'

Additional information

https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-javascript-actions

We also need to update the documentation when node14 is available.

Looks like this is not easy 😭

else if (string.Equals(usingToken.Value, "node12", StringComparison.OrdinalIgnoreCase))
{
if (string.IsNullOrEmpty(mainToken?.Value))
{
throw new ArgumentNullException($"You are using a JavaScript Action but there is not an entry JavaScript file provided in {fileRelativePath}.");
}
else
{
return new NodeJSActionExecutionData()
{
Script = mainToken.Value,
Pre = preToken?.Value,
InitCondition = preIfToken?.Value ?? "always()",
Post = postToken?.Value,
CleanupCondition = postIfToken?.Value ?? "always()"
};
}
}

No. This is a problem of the actions/runner.

peaceiris/actions-gh-pages#539

https://github.com/peaceiris/actions-gh-pages/pull/539/checks?check_run_id=1437553870#step:19:20
Error: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter ''using: node14' is not supported, use 'docker' or 'node12' instead.')

We need:

  • compile alpine node14
  • update the ./external.sh script to download the node14
  • update C# code and yaml schema to support node14
  • update documentation

Hello,
Is there any update on this or timeline of when to expect this feature?

Thank you,
Milan Zítka

@TingluoHuang I started working on this but I don't have any significant experience with C# so any help or direction would be much appreciated.

Should we just wait for node.js 16 to become LTS and then directly goes to node 16? I don't see too many benefits that go to node 14.

"Active LTS Start: 2021-10-26"
https://nodejs.org/en/about/releases/

not that far away 👍🏻

... we could even start much sooner with using: node14 support in preview to find and flush out any potential issues. no need to wait till October ... we'll just have to turn the crank it least a couple of times. But I do like going straight to 16.

What would be the benefit of supporting node 14? Any features that would be unlocked by using it?

among other things: top-level await, which is great for CLI apps, such as actions written in JS

I'm not sure if this is what is being suggested, but please don't make us wait until after October. I have so much code that requires v14 because of optional chaining.

It would be great to get a node16 runner!

It's not ideal, but as a workaround it wasn't too painful to flip a JS action that followed the official template to run as a Docker action... add a minimal Dockerfile with the node version you need, and tweak the action.yml ✨ 🎷 🐩

Dockerfile

FROM node:16-alpine
COPY dist dist
ENTRYPOINT [ "node", "/dist/index.js" ]

action.yml

 runs:
-  using: 'node12'
-  main: 'dist/index.js'
+  using: 'docker'
+  image: 'Dockerfile'

storacha-network/add-to-web3@3b56538

Node 14 or 16 would be great for my action here since it uses an ES module and it's not trivial to get that running under Node 12.

I printed the node version in the runner, which is v12.13.1. Bumping this to the latest v12 LTS version would likely already help with ES module compatibility.

I also noticed that when printing node --version, the output it v14.17.6 so that version seems to be available as well, but not via node14 or so.

I was able to find a workaround for running a ES module-based action!

Make a run.cjs script which then forks and defers to the node that is installed on the path in the runner by default, which at this time of writing is v14.17.6.

run.cjs:

child = require('child_process');
path = require('path');

// fork to system-installed node which is v14.17.6 at this time of writing
// this workaround can be removed once the Github actions runner supports a newer version of Node.js
child.fork(path.resolve(__dirname, 'dist/index.mjs'), [], {execPath: "node"});

Full example: https://github.com/borkdude/nbb-action-example

I've got a live example for a workaround: https://github.com/thoughtsunificator/chrome-publish-action feel free to fork.

We still hope that the runner supports multiple Node versions and the fundamental issue will be solved, not any workaround.

According to the Node.js release cycle, the end-of-life of v12 LTS is 2022-04-30.

Any update on this? I have a few projects I'm looking to update to version 14

The pull-request #1439 will close this and be released in version 2.285.0. (Note: there is no option for node14)