Skip to content

Commit

Permalink
deps: move to minimum Node 14 (GoogleChrome#13243)
Browse files Browse the repository at this point in the history
  • Loading branch information
brendankenny authored Oct 21, 2021
1 parent cbc9282 commit 95f5bbf
Show file tree
Hide file tree
Showing 35 changed files with 68 additions and 168 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ body:
attributes:
label: Node Version
description: >
What version of node.js were you using? (Only applicable to CLI and node) (Note: the minimum Node version we support is 12.13.0)
What version of node.js were you using? (Only applicable to CLI and node) (Note: the minimum Node version we support is 14.15.0)
validations:
required: false
- type: textarea
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
GITHUB_CONTEXT_PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
GITHUB_CONTEXT_BASE_SHA: ${{ github.event.before }}

- name: Use Node.js 12.x
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 12.x
node-version: 14.x

- run: yarn install --frozen-lockfile --network-timeout 1000000
- run: yarn build-all
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cron-weekly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ jobs:
steps:
- name: git clone
uses: actions/checkout@v2
- name: Use Node.js 12.x
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 12.x
node-version: 14.x
- run: yarn --frozen-lockfile

- run: yarn jest --testMatch="**/third-party/chromium-synchronization/*-test.js"
4 changes: 2 additions & 2 deletions .github/workflows/devtools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ jobs:
# The number is how many times this hash key was manually updated to break the cache.
key: ${{ runner.os }}-2-${{ hashFiles('lighthouse/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/*.js', 'lighthouse/.github/workflows/devtools.yml', 'lighthouse/lighthouse-core/test/chromium-web-tests/*', 'lighthouse/clients/devtools-entry.js', 'lighthouse/clients/devtools-report-assets.js', 'lighthouse/build/build-bundle.js', 'lighthouse/build/build-dt-report-resources.js') }}

- name: Use Node.js 12.x
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 12.x
node-version: 14.x

- run: yarn --frozen-lockfile
working-directory: ${{ github.workspace }}/lighthouse
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12.x
node-version: 14.x
registry-url: https://registry.npmjs.org/
- run: yarn --frozen-lockfile

Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ jobs:
# Depth of at least 2 for codecov coverage diffs. See https://github.com/GoogleChrome/lighthouse/pull/12079
fetch-depth: 2

- name: Use Node.js 12.x
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 12.x
node-version: 14.x

- name: Define ToT chrome path
if: matrix.chrome-channel == 'ToT'
Expand Down Expand Up @@ -82,10 +82,10 @@ jobs:
- name: git clone
uses: actions/checkout@v2

- name: Use Node.js 12.x
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 12.x
node-version: 14.x

- run: yarn install --frozen-lockfile --network-timeout 1000000
- run: yarn build-report
Expand All @@ -112,10 +112,10 @@ jobs:
- name: git clone
uses: actions/checkout@v2

- name: Use Node.js 12.x
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 12.x
node-version: 14.x

- run: yarn install --frozen-lockfile --network-timeout 1000000
- run: yarn build-report
Expand Down Expand Up @@ -143,10 +143,10 @@ jobs:
- name: git clone
uses: actions/checkout@v2

- name: Use Node.js 12.x
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 12.x
node-version: 14.x

- run: yarn install --frozen-lockfile --network-timeout 1000000
- run: yarn build-report
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
unit:
strategy:
matrix:
node: ['12', '14', '16']
node: ['14', '16', '17']
runs-on: ubuntu-latest
name: node ${{ matrix.node }}
env:
LATEST_NODE: '16'
LATEST_NODE: '17'

steps:
- name: git clone
Expand Down Expand Up @@ -76,10 +76,10 @@ jobs:
- name: git clone
uses: actions/checkout@v2

- name: Use Node.js 12.x
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 12.x
node-version: 14.x

- run: yarn install --frozen-lockfile --network-timeout 1000000
- run: yarn build-report
Expand Down
8 changes: 6 additions & 2 deletions build/build-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,12 @@ async function minifyScript(filePath) {
},
});

fs.writeFileSync(filePath, result.code);
if (DEBUG) fs.writeFileSync(`${filePath}.map`, result.map);
if (result.code) {
fs.writeFileSync(filePath, result.code);
}
if (DEBUG && typeof result.map === 'string') {
fs.writeFileSync(`${filePath}.map`, result.map);
}
}

/**
Expand Down
3 changes: 1 addition & 2 deletions build/build-dt-report-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ function writeFile(name, content) {
fs.writeFileSync(`${distDir}/${name}`, content);
}

fs.mkdirSync(distDir, {recursive: true}); // Ensure dist is present, else rmdir will throw. COMPAT: when dropping Node 12, replace with fs.rm(p, {force: true})
fs.rmdirSync(distDir, {recursive: true});
fs.rmSync(distDir, {recursive: true, force: true});
fs.mkdirSync(distDir, {recursive: true});

writeFile('report.js', htmlReportAssets.REPORT_JAVASCRIPT);
Expand Down
2 changes: 1 addition & 1 deletion build/build-sample-reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,6 @@ async function generateErrorLHR() {
appleTouchIconAudit.scoreDisplayMode = 'binary';
appleTouchIconAudit.score = 1;

fs.rmdirSync(TMP, {recursive: true});
fs.rmSync(TMP, {recursive: true, force: true});
return errorLhr;
}
3 changes: 1 addition & 2 deletions build/gh-pages-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ class GhPagesApp {
}

async build() {
fs.mkdirSync(this.distDir, {recursive: true}); // Ensure dist is present, else rmdir will throw. COMPAT: when dropping Node 12, replace with fs.rm(p, {force: true})
fs.rmdirSync(this.distDir, {recursive: true});
fs.rmSync(this.distDir, {recursive: true, force: true});

const html = await this._compileHtml();
safeWriteFile(`${this.distDir}/index.html`, html);
Expand Down
8 changes: 4 additions & 4 deletions docs/headless-chrome.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
Setup:

```sh
# Lighthouse requires Node 12 LTS (12.x) or later.
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - &&\
# Lighthouse requires Node 14 LTS (14.x) or later.
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - &&\
sudo apt-get install -y nodejs npm

# get chromium (stable)
Expand All @@ -27,8 +27,8 @@ lighthouse --chrome-flags="--headless" https://github.com
Alternatively, you can run full Chrome + xvfb instead of headless mode. These steps worked on Debian Jessie:

```sh
# get node 12
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
# get node 14
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs npm

# get chromium (stable) and Xvfb
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-cli/test/smokehouse/lighthouse-runners/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function runLighthouse(url, configJson, testRunnerOptions = {}) {
const tmpPath = await fs.mkdtemp(`${tmpDir}/smokehouse-`);
return internalRun(url, tmpPath, configJson, testRunnerOptions)
// Wait for internalRun() before removing scratch directory.
.finally(() => !isDebug && fs.rmdir(tmpPath, {recursive: true}));
.finally(() => !isDebug && fs.rm(tmpPath, {recursive: true, force: true}));
}

/**
Expand Down
6 changes: 3 additions & 3 deletions lighthouse-core/lib/asset-saver.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ async function saveTrace(traceData, traceFilename) {
const traceIter = traceJsonGenerator(traceData);
const writeStream = fs.createWriteStream(traceFilename);

// TODO: Can remove Readable.from() in Node 13, promisify(pipeline) in Node 15.
// TODO: Can remove promisify(pipeline) in Node 15.
// https://nodejs.org/api/stream.html#stream_stream_pipeline_streams_callback
return pipeline(stream.Readable.from(traceIter), writeStream);
return pipeline(traceIter, writeStream);
}

/**
Expand All @@ -250,7 +250,7 @@ function saveDevtoolsLog(devtoolsLog, devtoolLogFilename) {
const logIter = arrayOfObjectsJsonGenerator(devtoolsLog);
const writeStream = fs.createWriteStream(devtoolLogFilename);

return pipeline(stream.Readable.from(logIter), writeStream);
return pipeline(logIter, writeStream);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lighthouse-core/scripts/dogfood-lhci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ if [[ -z "$LHCI_CANARY_SERVER_TOKEN" ]]; then
fi

NODE_VERSION=$(node --version)
if [[ "$NODE_VERSION" != "v12"* ]]; then
echo "Not running dogfood script on node versions other than 12";
if [[ "$NODE_VERSION" != "v14"* ]]; then
echo "Not running dogfood script on node versions other than 14";
exit 0;
fi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const URLS_LIST = process.argv[2]
? path.resolve(process.cwd(), process.argv[2])
: path.join(LH_ROOT, 'lighthouse-core/scripts/gcp-collection/urls.txt');

fs.rmdirSync(TMP_DIR, {recursive: true});
fs.rmSync(TMP_DIR, {recursive: true, force: true});
fs.mkdirSync(TMP_DIR);

const MACHINE_BASE_INDEX = 0;
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/scripts/gcp-collection/gcp-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" | sud
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -

# Node apt-key
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -

# Install dependencies
sudo apt-get update
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/scripts/lantern/collect/gcp-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" | sud
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -

# Node apt-key
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -

# Install dependencies
sudo apt-get update
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/scripts/lantern/collect/golden.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async function main() {
/** @type {Golden} */
const golden = {sites: goldenSites};

fs.rmdirSync(common.goldenFolder, {recursive: true});
fs.rmSync(common.goldenFolder, {recursive: true, force: true});
fs.mkdirSync(common.goldenFolder);
saveGoldenData('site-index-plus-golden-expectations.json', JSON.stringify(golden, null, 2));
for (const result of goldenSites) {
Expand Down
6 changes: 0 additions & 6 deletions lighthouse-core/test/config/config-helpers-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const Runner = require('../../runner.js');
const Gatherer = require('../../gather/gatherers/gatherer.js');
const ImageElementsGatherer = require('../../gather/gatherers/image-elements.js');
const UserTimingsAudit = require('../../audits/user-timings.js');
const {isNode12SmallIcu} = require('../test-utils.js');
const {LH_ROOT} = require('../../../root.js');

jest.mock('process', () => ({
Expand Down Expand Up @@ -249,11 +248,6 @@ describe('.mergePlugins', () => {
describe('.resolveSettings', () => {
it('resolves the locale', () => {
const settings = resolveSettings({locale: 'zh-CN'});
// COMPAT: Node 12 only has 'en-US' by default.
if (isNode12SmallIcu()) {
expect(settings.locale).toEqual('en-US');
return;
}
expect(settings.locale).toEqual('zh');
});

Expand Down
5 changes: 0 additions & 5 deletions lighthouse-core/test/config/config-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const Gatherer = require('../../gather/gatherers/gatherer.js');
const Audit = require('../../audits/audit.js');
const i18n = require('../../lib/i18n/i18n.js');
const format = require('../../../shared/localization/format.js');
const {isNode12SmallIcu} = require('../test-utils.js');

/* eslint-env jest */

Expand Down Expand Up @@ -837,17 +836,13 @@ describe('Config', () => {
it('uses config setting for locale if set', () => {
const locale = 'ar-XB';
const config = new Config({settings: {locale}});
// COMPAT: Node 12 only has 'en' by default.
if (isNode12SmallIcu()) return;
assert.strictEqual(config.settings.locale, locale);
});

it('uses flag setting for locale if set', () => {
const settingsLocale = 'en-XA';
const flagsLocale = 'ar-XB';
const config = new Config({settings: {locale: settingsLocale}}, {locale: flagsLocale});
// COMPAT: Node 12 only has 'en' by default.
if (isNode12SmallIcu()) return;
assert.strictEqual(config.settings.locale, flagsLocale);
});
});
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/test/lib/asset-saver-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ describe('asset-saver helper', () => {
const outputPath = __dirname + '/json-serialization-test-data/';

afterEach(() => {
fs.rmdirSync(outputPath, {recursive: true});
fs.rmSync(outputPath, {recursive: true, force: true});
});

it('round trips saved artifacts', async () => {
Expand Down
24 changes: 0 additions & 24 deletions lighthouse-core/test/lib/i18n/i18n-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
const path = require('path');
const i18n = require('../../../lib/i18n/i18n.js');
const log = require('lighthouse-logger');
const {isNode12SmallIcu} = require('../../test-utils.js');

/* eslint-env jest */

Expand Down Expand Up @@ -50,16 +49,6 @@ describe('i18n', () => {

expect(i18n.lookupLocale(invalidLocale)).toEqual('en-US');

// COMPAT: Node 12 logs an extra warning that full-icu is not available.
if (isNode12SmallIcu()) {
expect(logListener).toBeCalledTimes(2);
expect(logListener).toHaveBeenNthCalledWith(1, ['i18n',
expect.stringMatching(/Requested locale not available in this version of node/)]);
expect(logListener).toHaveBeenNthCalledWith(2, ['i18n',
`locale(s) '${invalidLocale}' not available. Falling back to default 'en-US'`]);
return;
}

expect(logListener).toBeCalledTimes(1);
expect(logListener).toBeCalledWith(['i18n',
`locale(s) '${invalidLocale}' not available. Falling back to default 'en-US'`]);
Expand All @@ -68,12 +57,6 @@ describe('i18n', () => {
});

it('falls back to root tag prefix if specific locale not available', () => {
// COMPAT: Node 12 only has 'en-US' by default.
if (isNode12SmallIcu()) {
expect(i18n.lookupLocale('es-JKJK')).toEqual('en-US');
return;
}

expect(i18n.lookupLocale('es-JKJK')).toEqual('es');
});

Expand All @@ -87,13 +70,6 @@ describe('i18n', () => {
});

it('takes multiple locale strings and returns a possible, canonicalized one', () => {
// COMPAT: Node 12 only has 'en-US' by default.
if (isNode12SmallIcu()) {
expect(i18n.lookupLocale([invalidLocale, 'eN-uS', 'en-xa'], ['ar', 'es', 'en-US']))
.toEqual('en-US');
return;
}

expect(i18n.lookupLocale([invalidLocale, 'eS', 'en-xa'], ['ar', 'es']))
.toEqual('es');
});
Expand Down
Loading

0 comments on commit 95f5bbf

Please sign in to comment.