Skip to content

Commit

Permalink
Merge pull request #4278 from microsoft/octogonz/node-18
Browse files Browse the repository at this point in the history
Update our CI pipelines to include Node 18
  • Loading branch information
octogonz committed Aug 11, 2023
2 parents d7d3589 + 6e42605 commit 0916c2d
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 10 deletions.
21 changes: 18 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ jobs:
include:
- NodeVersion: 14
OS: ubuntu-latest
- NodeVersion: 16
- NodeVersion: 18
OS: ubuntu-latest
- NodeVersion: 16
OS: windows-latest
- NodeVersion: 18
OS: windows-latest
name: Node.js v${{ matrix.NodeVersion }} (${{ matrix.OS }})
runs-on: ${{ matrix.OS }}
steps:
Expand All @@ -33,6 +35,12 @@ jobs:
with:
node-version: ${{ matrix.NodeVersion }}

# Workaround for Node 18 incompatibility with Webpack 4
- name: Enable Webpack 4 workaround
shell: bash
run: echo "NODE_OPTIONS=--openssl-legacy-provider" >> "$GITHUB_ENV"
if: matrix.NodeVersion == 18

- name: Verify Change Logs
run: node common/scripts/install-run-rush.js change --verify

Expand All @@ -50,11 +58,18 @@ jobs:
# See https://github.com/microsoft/rushstack/issues/2981
BROWSERSLIST_IGNORE_OLD_DATA: 1

- name: Ensure repo README is up-to-date
run: node repo-scripts/repo-toolbox/lib/start.js readme --verify

- name: Rush test (rush-lib)
run: node apps/rush/lib/start-dev.js test --verbose --production --timeline
env:
# Prevent time-based browserslist update warning
# See https://github.com/microsoft/rushstack/issues/2981
BROWSERSLIST_IGNORE_OLD_DATA: 1
- name: Ensure repo README is up-to-date
run: node repo-scripts/repo-toolbox/lib/start.js readme --verify

# One of the post run actions apparently uses older Node.js that rejects --openssl-legacy-provider
- name: Revert Webpack 4 workaround
shell: bash
run: echo "NODE_OPTIONS=" >> "$GITHUB_ENV"
if: matrix.NodeVersion == 18
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,20 @@ jspm_packages/
.idea/
*.iml

# Visual Studio Code
.vscode

# Rush temporary files
common/deploy/
common/temp/
common/autoinstallers/*/.npmrc
**/.rush/temp/
*.lock

# Heft temporary files
.cache
.heft

# Visual Studio Code
.vscode

# Common toolchain intermediate files
temp
lib
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "Update Node.js version checks to support the new LTS release",
"type": "none"
}
],
"packageName": "@microsoft/rush"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "Update \"rush init\" template to use PNPM 7.33.5",
"type": "none"
}
],
"packageName": "@microsoft/rush"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "Update the \"rush init\" template's .gitignore to avoid spurious diffs for files such as \"autoinstaller.lock\"",
"type": "none"
}
],
"packageName": "@microsoft/rush"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/heft-webpack4-plugin",
"comment": "Display a warning if Node.js 17 or newer is used without the \"--openssl-legacy-provider\" workaround",
"type": "minor"
}
],
"packageName": "@rushstack/heft-webpack4-plugin"
}
28 changes: 28 additions & 0 deletions heft-plugins/heft-webpack4-plugin/src/Webpack4Plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,37 @@ export default class Webpack4Plugin implements IHeftTaskPlugin<IWebpackPluginOpt
return this._webpackCompiler;
}

private _warnAboutNodeJsIncompatibility(taskSession: IHeftTaskSession): void {
const versionMatch: RegExpExecArray | null = /^([0-9]+)\./.exec(process.versions.node); // parse the SemVer MAJOR part
if (versionMatch) {
const nodejsMajorVersion: number = parseInt(versionMatch[1]);
if (nodejsMajorVersion > 16) {
// Match strings like this:
// "--max-old-space-size=4096 --openssl-legacy-provider"
// "--openssl-legacy-provider=true"
// Do not accidentally match strings like this:
// "--openssl-legacy-provider-unrelated"
// "---openssl-legacy-provider"
if (!/(^|[^a-z\-])--openssl-legacy-provider($|[^a-z\-])/.test(process.env.NODE_OPTIONS ?? '')) {
taskSession.logger.emitWarning(
new Error(
`Node.js ${nodejsMajorVersion} is incompatible with Webpack 4. To work around this problem, use the environment variable NODE_OPTIONS="--openssl-legacy-provider"`
)
);
}
}
} else {
taskSession.logger.emitWarning(new Error(`Unable to parse Node.js version "${process.versions.node}"`));
}
}

private async _runWebpackAsync(
taskSession: IHeftTaskSession,
heftConfiguration: HeftConfiguration,
options: IWebpackPluginOptions
): Promise<void> {
this._warnAboutNodeJsIncompatibility(taskSession);

this._validateEnvironmentVariable(taskSession);
if (taskSession.parameters.watch || this._isServeMode) {
// Should never happen, but just in case
Expand Down Expand Up @@ -236,6 +262,8 @@ export default class Webpack4Plugin implements IHeftTaskPlugin<IWebpackPluginOpt
options: IWebpackPluginOptions,
requestRun: () => void
): Promise<void> {
this._warnAboutNodeJsIncompatibility(taskSession);

// Save a handle to the original promise, since the this-scoped promise will be replaced whenever
// the compilation completes.
let webpackCompilationDonePromise: Promise<void> | undefined = this._webpackCompilationDonePromise;
Expand Down
2 changes: 2 additions & 0 deletions libraries/rush-lib/assets/rush-init/[dot]gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ common/deploy/
common/temp/
common/autoinstallers/*/.npmrc
**/.rush/temp/
*.lock

# Heft temporary files
.cache
.heft
2 changes: 1 addition & 1 deletion libraries/rush-lib/assets/rush-init/rush.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* Specify one of: "pnpmVersion", "npmVersion", or "yarnVersion". See the Rush documentation
* for details about these alternatives.
*/
"pnpmVersion": "6.7.1",
"pnpmVersion": "7.33.5",

/*[LINE "HYPOTHETICAL"]*/ "npmVersion": "6.14.15",
/*[LINE "HYPOTHETICAL"]*/ "yarnVersion": "1.9.4",
Expand Down
2 changes: 1 addition & 1 deletion libraries/rush-lib/src/logic/NodeJsCompatibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type { RushConfiguration } from '../api/RushConfiguration';
* LTS schedule: https://nodejs.org/en/about/releases/
* LTS versions: https://nodejs.org/en/download/releases/
*/
const UPCOMING_NODE_LTS_VERSION: number = 18;
const UPCOMING_NODE_LTS_VERSION: number = 20;
const nodeVersion: string = process.versions.node;
const nodeMajorVersion: number = semver.major(nodeVersion);

Expand Down
4 changes: 2 additions & 2 deletions rush.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* Specify one of: "pnpmVersion", "npmVersion", or "yarnVersion". See the Rush documentation
* for details about these alternatives.
*/
"pnpmVersion": "7.26.1",
"pnpmVersion": "7.33.5",

// "npmVersion": "6.14.15",
// "yarnVersion": "1.9.4",
Expand All @@ -42,7 +42,7 @@
* LTS schedule: https://nodejs.org/en/about/releases/
* LTS versions: https://nodejs.org/en/download/releases/
*/
"nodeSupportedVersionRange": ">=14.15.0 <15.0.0 || >=16.13.0 <17.0.0",
"nodeSupportedVersionRange": ">=14.15.0 <15.0.0 || >=16.13.0 <17.0.0 || >=18.15.0 <19.0.0",

/**
* If the version check above fails, Rush will display a message showing the current
Expand Down

0 comments on commit 0916c2d

Please sign in to comment.