简体   繁体   English

GitHub 操作 - 为什么使用不同的节点版本构建?

[英]GitHub Actions - Why build with different Node versions?

I'm new to GitHub Actions (and continuous integration in general).我是 GitHub 操作(以及一般的持续集成)的新手。 I was just reading Using Node.js with GitHub Actions and I found this snippet there from the Node.js workflow template :我刚刚阅读Using Node.js with GitHub Actions ,我从Node.js 工作流模板中找到了这个片段:

    strategy:
      matrix:
        node-version: [8.x, 10.x, 12.x]

It's mentioned that有人提到

The template includes a matrix strategy that builds and tests your code with three Node.js versions: 8.x, 10.x, and 12.x.该模板包含一个矩阵策略,可以使用三个 Node.js 版本构建和测试您的代码:8.x、10.x 和 12.x。 The 'x' is a wildcard character that matches the latest minor and patch release available for a version. 'x' 是一个通配符,与一个版本可用的最新次要版本和补丁版本相匹配。 Each version of Node.js specified in the node-version array creates a job that runs the same steps. node-version数组中指定的每个 Node.js 版本都会创建一个运行相同步骤的作业。

My question is — why build and test with different Node versions?我的问题是——为什么要使用不同的 Node 版本进行构建和测试? Why not just use one version?为什么不只使用一个版本?

Thank you!谢谢!

Node.js versions 8 , 10 and 12 are commonly used versions of Node.js. Node.js 版本8、1012Node.js的常用版本。 Versions 9 and 11 are considered experimental, since they are odd numbers, and therefore do not get LTS (Long Term Support).版本911被认为是实验性的,因为它们是奇数,因此不会获得 LTS(长期支持)。 On the other hand, versions 8 , 10 and 12 are stable.另一方面,版本81012是稳定的。

Firebase cloud functions require either Node.js version 8 or 10 , showing that versions 8 and 10 are still quite widely used. Firebase 云函数需要 Node.js 版本810 ,表明版本810仍然被广泛使用。

Node.js version 14 was released a few months ago, but I doubt people will move to it until a while later when most of the bugs have been fixed, so it is not entirely necessary to test it, but you can if you want. Node.js 版本14是几个月前发布的,但我怀疑人们会在一段时间后修复大部分错误时才开始使用它,因此并不完全需要对其进行测试,但如果你愿意,可以。


As you can see, Node.js versions 8 , 10 and 12 are the most widely used versions of Node.js and therefore, it would be a good idea to make sure that your JavaScript code works with those 3 versions to ensure a lot of people can use your code.如您所见, Node.js版本8、1012是 Node.js 最广泛使用的版本,因此,确保您的 Z686155AF75A60A0F6E9D80C1F7EDD3 代码可以使用您的很多人是个好主意代码。

If you want to ensure complete compatibility, you can test with even more versions of Node.js, but I doubt you would need to, as Node.js is usually quite backwards-compatible.如果您想确保完全兼容,您可以使用更多版本的 Node.js 进行测试,但我怀疑您是否需要这样做,因为 Node.js 通常向后兼容。

If you want to see which versions of Node.js are currently being supported, visit the Node.js releases page.如果您想查看当前支持哪些版本的 Node.js,请访问Node.js 版本页面。

This relates to the important question of "How to build and test with different versions of node?".这涉及到“如何使用不同版本的节点构建和测试?”的重要问题。 For example, I have package dependencies that will not build with earlier versions of node (antlr4 being one example), yet I still need to test the distributed code on older versions.例如,我有 package 依赖项,这些依赖项无法使用早期版本的节点(antlr4 就是一个例子)构建,但我仍然需要在旧版本上测试分布式代码。 This seems to be impossible as things stand (to build with, for example, node 14.x, and test the built code with node 12.x)?从目前的情况来看,这似乎是不可能的(例如,使用节点 14.x 构建,并使用节点 12.x 测试构建的代码)?

(though this was not the poster's concern) (虽然这不是海报的关注点)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM