Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update CI config to include nodejs v20 #3014

Merged
merged 10 commits into from
Jan 15, 2024
29 changes: 18 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,24 @@ references:
# set of nodejs versions that should be tested.
# The nodejs version set as `nodejs_current` is the one used to
# release the package on npm.
#
# See https://nodejs.org/en/about/previous-releases for updates to nodejs versions.
nodejs_versions:
# nvm-windows wants a full Node version, not just `<major>.<minor>`.
- &nodejs_current "16.14.2"
- &nodejs_next "18.15"
- &nodejs_experimental "19.3"
- &nodejs_current "18.19.0"
- &nodejs_next "20.11.0"
# TODO(https://github.com/mozilla/web-ext/issues/3015): re-enable this once fixed
# by a testdouble dependency update.
# - &nodejs_experimental "21.5"
willdurand marked this conversation as resolved.
Show resolved Hide resolved

nodejs_enum: &nodejs_enum
type: enum
default: *nodejs_current
enum:
- *nodejs_current
- *nodejs_next
- *nodejs_experimental
# TODO(https://github.com/mozilla/web-ext/issues/3015): re-enable this once fixed
# - *nodejs_experimental
repo_path: &repo_path ~/web-ext
defaults: &defaults
working_directory: *repo_path
Expand Down Expand Up @@ -264,12 +269,13 @@ workflows:
filters:
tags:
only: /.*/
- build:
name: build-nodejs-experimental
nodejs: *nodejs_experimental
filters:
tags:
only: /.*/
# TODO(https://github.com/mozilla/web-ext/issues/3015): re-enable this once fixed
# - build:
# name: build-nodejs-experimental
# nodejs: *nodejs_experimental
# filters:
# tags:
# only: /.*/
rpl marked this conversation as resolved.
Show resolved Hide resolved
- test-windows:
filters:
tags:
Expand All @@ -279,8 +285,9 @@ workflows:
requires:
- build-nodejs-current
- build-nodejs-next
- build-nodejs-experimental
- test-windows
# TODO(https://github.com/mozilla/web-ext/issues/3015): re-enable this once fixed
#- build-nodejs-experimental
filters:
tags:
only: /.*/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ version on the command line with this:

You'll need:

- [Node.js](https://nodejs.org/en/), 16.0.0 or higher
- [Node.js](https://nodejs.org/en/) (current [LTS](https://github.com/nodejs/LTS))
- [npm](https://www.npmjs.com/), 8.0.0 or higher is recommended

Optionally, you may like:
Expand Down
39 changes: 19 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"lib/**"
],
"engines": {
"node": ">=16.0.0",
"node": ">=18.0.0",
"npm": ">=8.0.0"
},
"engine-strict": true,
Expand Down Expand Up @@ -120,7 +120,7 @@
"prettyjson": "1.2.5",
"shelljs": "0.8.5",
"sinon": "17.0.1",
"testdouble": "3.16.8",
"testdouble": "3.20.1",
"yauzl": "2.10.0"
},
"author": "Kumar McMillan",
Expand Down
9 changes: 4 additions & 5 deletions scripts/lib/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@ const runMocha = (args, execMochaOptions = {}, coverageEnabled) => {
shell.echo(`\nSetting mocha timeout from env var: ${MOCHA_TIMEOUT}\n`);
}

// Pass custom babel-loader node loader to transpile on the fly
// the tests modules.
binArgs.push('-n="loader=./tests/babel-loader.js"');
// Pass testdouble node loader to support ESM module mocking and
// transpiling on the fly the tests modules.
binArgs.push('-n="loader=testdouble"');

const res = spawnSync(binPath, binArgs, {
...execMochaOptions,
env: {
...process.env,
// Make sure NODE_ENV is set to test (which also enable babel
// install plugin for all modules transpiled on the fly by the
// tests/babel-loader.js).
// install plugin for all modules transpiled on the fly).
NODE_ENV: 'test',
},
stdio: 'inherit',
Expand Down
110 changes: 0 additions & 110 deletions tests/babel-loader.js

This file was deleted.

3 changes: 2 additions & 1 deletion tests/functional/fake-amo-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// - http://addons-server.readthedocs.io/en/latest/topics/api/signing.html

import http from 'http';
import os from 'os';

const FAKE_REPLIES = [
// Upload responses, see https://addons-server.readthedocs.io/en/latest/topics/api/addons.html#upload-detail-object
Expand Down Expand Up @@ -89,7 +90,7 @@ http
process.exit(1);
}
})
.listen(8989, '127.0.0.1', () => {
.listen(8989, os.platform() === 'win32' ? '::1' : '127.0.0.1', () => {
rpl marked this conversation as resolved.
Show resolved Hide resolved
process.stdout.write('listening');
process.stdout.uncork();
});
2 changes: 0 additions & 2 deletions tests/unit/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,8 @@ export function mockModule({
).href;

td.replaceEsm(fullModuleURL, namedExports, defaultExport);
global.__webextMocks?.add(fullModuleURL);
}

export function resetMockModules() {
td.reset();
global.__webextMocks?.clear();
}
9 changes: 8 additions & 1 deletion tests/unit/test-util/test.submit-addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,15 @@ class JSONResponse extends Response {
}

const mockNodeFetch = (nodeFetchStub, url, method, responses) => {
// Trust us... You don't want to know why... but if you really do like nightmares
// take a look to the details and links kindly provided in this comment
// that helped investigating this:
// https://github.com/mozilla/web-ext/issues/2917#issuecomment-1766000545
const urlMatch = url instanceof URL ? url.href : url;
const stubMatcher = nodeFetchStub.withArgs(
url instanceof URL ? url : new URL(url),
sinon.match(
(urlArg) => urlMatch === (urlArg instanceof URL ? urlArg.href : urlArg),
),
sinon.match.has('method', method),
);
for (let i = 0; i < responses.length; i++) {
Expand Down