Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into esm-core
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark committed Jun 17, 2022
2 parents 52d7e58 + 16a4ccf commit 72af740
Show file tree
Hide file tree
Showing 121 changed files with 1,258 additions and 973 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/devtools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ jobs:
# 3) every change to file in Lighthouse repo important to running these tests.
#
# The number is how many times this hash key was manually updated to break the cache.
key: ${{ runner.os }}-3-${{ env.WEEK_OF_THE_YEAR }}-${{ hashFiles('cdt-test-hash.txt') }}
restore-keys: ${{ runner.os }}-
key: ${{ runner.os }}-5-${{ env.WEEK_OF_THE_YEAR }}-${{ hashFiles('cdt-test-hash.txt') }}
restore-keys: ${{ runner.os }}-5
- name: Set GHA_DEVTOOLS_CACHE_HIT
if: steps.devtools-cache.outputs.cache-hit == 'true'
run: echo "GHA_DEVTOOLS_CACHE_HIT=1" >> $GITHUB_ENV
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/package-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ jobs:
- run: yarn build-report
- run: sudo apt-get install xvfb

- run: xvfb-run --auto-servernum bash $GITHUB_WORKSPACE/lighthouse-core/scripts/release/package-test.sh --fraggle-rock
# Disabled to fix CI while we investigate what the bug is.
# perf-diagnostics-third-party
- run: xvfb-run --auto-servernum bash $GITHUB_WORKSPACE/lighthouse-core/scripts/release/package-test.sh --fraggle-rock --invert-match perf-diagnostics-third-party

# Fail if any changes were written to source files.
- run: git diff --exit-code
2 changes: 2 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:

jobs:
publish:
# Prevent forks from running this job.
if: (github.event_name == 'schedule' && github.repository == 'GoogleChrome/lighthouse') || (github.event_name != 'schedule')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ jobs:

- run: sudo apt-get install xvfb
- name: yarn smoke --fraggle-rock
run: xvfb-run --auto-servernum yarn smoke --debug --fraggle-rock -j=2 --retries=2 --shard=${{ matrix.smoke-test-shard }}/$SHARD_TOTAL
# Disabled to fix CI while we investigate what the bug is.
# perf-diagnostics-third-party
run: xvfb-run --auto-servernum yarn smoke --debug --fraggle-rock -j=2 --retries=2 --shard=${{ matrix.smoke-test-shard }}/$SHARD_TOTAL --invert-match perf-diagnostics-third-party

# Fail if any changes were written to source files.
- run: git diff --exit-code
Expand Down Expand Up @@ -217,7 +219,9 @@ jobs:

- run: sudo apt-get install xvfb
- name: yarn test-bundle
run: xvfb-run --auto-servernum yarn test-bundle --fraggle-rock --shard=${{ matrix.smoke-test-shard }}/$SHARD_TOTAL
# Disabled to fix CI while we investigate what the bug is.
# perf-diagnostics-third-party
run: xvfb-run --auto-servernum yarn test-bundle --fraggle-rock --shard=${{ matrix.smoke-test-shard }}/$SHARD_TOTAL --invert-match perf-diagnostics-third-party

# Fail if any changes were written to source files.
- run: git diff --exit-code
Expand Down
Binary file added assets/flows/navigation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions assets/flows/navigation.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/flows/snapshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions assets/flows/snapshot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/flows/timespan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions assets/flows/timespan.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 3 additions & 6 deletions build/build-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import fs from 'fs';
import path from 'path';
import {execSync} from 'child_process';
import {createRequire} from 'module';

import esMain from 'es-main';
import {rollup} from 'rollup';
Expand All @@ -22,9 +23,8 @@ import {rollup} from 'rollup';
import * as rollupPlugins from './rollup-plugins.js';
import {Runner} from '../lighthouse-core/runner.js';
import {LH_ROOT, readJson} from '../root.js';
import {createCommonjsRefs} from '../lighthouse-core/scripts/esm-utils.js';

const {require} = createCommonjsRefs(import.meta);
const require = createRequire(import.meta.url);

/** The commit hash for the current HEAD. */
const COMMIT_HASH = execSync('git rev-parse HEAD').toString().trim();
Expand Down Expand Up @@ -239,10 +239,7 @@ async function cli(argv) {

// Test if called from the CLI or as a module.
if (esMain(import.meta)) {
cli(process.argv).catch(err => {
console.error(err);
process.exit(1);
});
await cli(process.argv);
}

export {
Expand Down
5 changes: 1 addition & 4 deletions build/build-dt-report-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,4 @@ async function buildReportGenerator() {
await bundle.close();
}

buildReportGenerator().catch(err => {
console.error(err);
process.exit(1);
});
await buildReportGenerator();
7 changes: 2 additions & 5 deletions build/build-extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async function packageExtension() {
});
}

async function run() {
async function main() {
await Promise.all([
buildEntryPoint(),
copyAssets(),
Expand All @@ -97,7 +97,4 @@ async function run() {
await packageExtension();
}

run().catch(err => {
console.error(err);
process.exit(1);
});
await main();
22 changes: 8 additions & 14 deletions build/build-lightrider-bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ async function buildReportGenerator() {
const bundle = await rollup({
input: 'report/generator/report-generator.js',
plugins: [
rollupPlugins.inlineFs({verbose: Boolean(process.env.DEBUG)}),
rollupPlugins.shim({
[`${LH_ROOT}/report/generator/flow-report-assets.js`]: 'export default {}',
'fs': 'export default {}',
}),
rollupPlugins.nodeResolve(),
rollupPlugins.inlineFs({verbose: Boolean(process.env.DEBUG)}),
rollupPlugins.commonjs(),
],
});

Expand Down Expand Up @@ -63,15 +64,8 @@ async function buildStaticServerBundle() {
await bundle.close();
}

async function run() {
await Promise.all([
buildEntryPoint(),
buildReportGenerator(),
buildStaticServerBundle(),
]);
}

run().catch(err => {
console.error(err);
process.exit(1);
});
await Promise.all([
buildEntryPoint(),
buildReportGenerator(),
buildStaticServerBundle(),
]);
5 changes: 1 addition & 4 deletions build/build-report-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,7 @@ ${makeGenericCreateComponentFunctionCode(compiledTemplates)}
}

if (esMain(import.meta)) {
main().catch(err => {
console.error(err);
process.exit(1);
});
await main();
}

export {normalizeTextNodeText};
37 changes: 31 additions & 6 deletions build/build-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,42 @@ async function buildFlowReport() {
}

async function buildEsModulesBundle() {
// Include the type detail for bundle.esm.d.ts generation
const i18nModuleShim = `
/**
* Returns a new LHR with all strings changed to the new requestedLocale.
* @param {LH.Result} lhr
* @param {LH.Locale} requestedLocale
* @return {{lhr: LH.Result, missingIcuMessageIds: string[]}}
*/
export function swapLocale(lhr, requestedLocale) {
// Stub function only included for types
return {
lhr,
missingIcuMessageIds: [],
};
}
/**
* Populate the i18n string lookup dict with locale data
* Used when the host environment selects the locale and serves lighthouse the intended locale file
* @see https://docs.google.com/document/d/1jnt3BqKB-4q3AE94UWFA0Gqspx8Sd_jivlB7gQMlmfk/edit
* @param {LH.Locale} locale
* @param {Record<string, {message: string}>} lhlMessages
*/
function registerLocaleData(locale, lhlMessages) {
// Stub function only included for types
}
export const format = {registerLocaleData};
`;

const bundle = await rollup({
input: 'report/clients/bundle.js',
plugins: [
rollupPlugins.commonjs(),
// Exclude this 30kb from the devtools bundle for now.
rollupPlugins.shim({
[`${LH_ROOT}/shared/localization/i18n-module.js`]:
'export const swapLocale = _ => {}; export const format = _ => {};',
[`${LH_ROOT}/shared/localization/i18n-module.js`]: i18nModuleShim,
}),
],
});
Expand Down Expand Up @@ -167,10 +195,7 @@ async function main() {
}

if (esMain(import.meta)) {
main().catch(err => {
console.error(err);
process.exit(1);
});
await main();
}

export {
Expand Down
19 changes: 9 additions & 10 deletions build/build-sample-reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ const flowResult = readJson(
`${LH_ROOT}/lighthouse-core/test/fixtures/fraggle-rock/reports/sample-flow-result.json`
);

const snapshotLhr = flowResult.steps.find(step => step.lhr.gatherMode === 'snapshot')?.lhr;
const timespanLhr = flowResult.steps.find(step => step.lhr.gatherMode === 'timespan')?.lhr;
if (!snapshotLhr) throw new Error('Could not find a snapshot report on the sample flow result');
if (!timespanLhr) throw new Error('Could not find a timespan report on the sample flow result');

const DIST = path.join(LH_ROOT, 'dist');

(async function() {
async function buildSampleReports() {
const snapshotLhr = flowResult.steps.find(step => step.lhr.gatherMode === 'snapshot')?.lhr;
const timespanLhr = flowResult.steps.find(step => step.lhr.gatherMode === 'timespan')?.lhr;
if (!snapshotLhr) throw new Error('Could not find a snapshot report on the sample flow result');
if (!timespanLhr) throw new Error('Could not find a timespan report on the sample flow result');

addPluginCategory(lhr);
const errorLhr = await generateErrorLHR();

Expand Down Expand Up @@ -68,10 +68,7 @@ const DIST = path.join(LH_ROOT, 'dist');
});

generateFlowReports();
})().catch(err => {
console.error(err);
process.exit(1);
});
}

function generateFlowReports() {
const filenameToFlowResult = {
Expand Down Expand Up @@ -205,3 +202,5 @@ async function generateErrorLHR() {
fs.rmSync(TMP, {recursive: true, force: true});
return errorLhr;
}

await buildSampleReports();
7 changes: 2 additions & 5 deletions build/build-smokehouse-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const bundleOutFile = `${distDir}/smokehouse-bundle.js`;
const smokehouseLibFilename = './lighthouse-cli/test/smokehouse/frontends/lib.js';
const smokehouseCliFilename = `${LH_ROOT}/lighthouse-cli/test/smokehouse/lighthouse-runners/cli.js`;

async function build() {
async function main() {
const bundle = await rollup({
input: smokehouseLibFilename,
context: 'globalThis',
Expand All @@ -37,7 +37,4 @@ async function build() {
await bundle.close();
}

build().catch(err => {
console.error(err);
process.exit(1);
});
await main();
Loading

0 comments on commit 72af740

Please sign in to comment.