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
27 changes: 20 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ 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"
- &nodejs_experimental "21.5"

nodejs_enum: &nodejs_enum
type: enum
Expand Down Expand Up @@ -173,13 +175,24 @@ jobs:
node_env: test
## Skip code coverage and the additional legacy bundling tests on jobs
## running on the next nodejs versions.
- unless:
- when:
condition:
equal: [*nodejs_current, << parameters.nodejs >>]
equal: [*nodejs_next, << parameters.nodejs >>]
steps:
- run:
name: run linting checks and unit tests
command: npm run test
- run_functional_tests
## Allow npm run test to fail when running on nodejs experimental.
# TODO(https://github.com/mozilla/web-ext/issues/3015): change this to do not
# allow failures on nodejs 21 once fixed by a testdouble dependency update.
- when:
condition:
equal: [*nodejs_experimental, << parameters.nodejs >>]
steps:
- run:
name: run linting checks and unit tests
command: npm run test
name: run linting checks and unit tests (but allow failure)
command: npm run test || echo "NOTE - Unit tests failed, but allowed to fail on nodejs experimental"
- run_functional_tests
## Steps only executed in jobs running on the current nodejs version.
- when:
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.

2 changes: 1 addition & 1 deletion tests/functional/fake-amo-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ http
process.exit(1);
}
})
.listen(8989, '127.0.0.1', () => {
.listen(8989, 'localhost', () => {
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