-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
430 additions
and
323 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
import child from "child_process"; | ||
import { resolve } from "path"; | ||
import PCR from "puppeteer-chromium-resolver"; | ||
|
||
const __root = process.cwd(); | ||
|
||
async function run() { | ||
// eslint-disable-next-line new-cap | ||
const { puppeteer, executablePath } = await PCR({}); | ||
console.log("[ci] starting"); | ||
|
||
await /** @type {Promise<void>} */ ( | ||
new Promise((fulfill) => { | ||
const runvite = child.fork( | ||
resolve(__root, "node_modules", "vite", "bin", "vite.js"), | ||
["--port", "60173", "--no-open"], | ||
{ | ||
stdio: "pipe", | ||
} | ||
); | ||
|
||
process.on("exit", () => runvite.kill()); | ||
|
||
runvite.stderr.on("data", (data) => { | ||
console.log("stderr", String(data)); | ||
}); | ||
|
||
runvite.stdout.on("data", (data) => { | ||
const chunk = String(data); | ||
console.log("stdout", chunk); | ||
if (chunk.includes("Local") && chunk.includes("60173")) { | ||
fulfill(1); | ||
} | ||
}); | ||
|
||
console.log("[ci] spawning"); | ||
}) | ||
); | ||
|
||
console.log("[ci] spawned"); | ||
|
||
const browser = await puppeteer.launch({ | ||
headless: "new", | ||
executablePath, | ||
args: ["--no-sandbox", "--disable-setuid-sandbox"], | ||
}); | ||
|
||
console.log("[ci] puppeteer launched"); | ||
|
||
let unOptimizedDeps = []; | ||
|
||
const result = await /** @type {Promise<void>} */ ( | ||
// eslint-disable-next-line no-async-promise-executor | ||
new Promise(async (fulfill) => { | ||
const page = await browser.newPage(); | ||
|
||
page.on("pageerror", (msg) => { | ||
console.error(msg); | ||
fulfill(1); | ||
}); | ||
|
||
function logRequest(interceptedRequest) { | ||
const url = interceptedRequest.url(); | ||
const allow = [ | ||
"vite/dist/client/env.mjs", | ||
"@babel+runtime", | ||
".css", | ||
"@embroider/macros", | ||
"ember-source/ember/index.js", | ||
]; | ||
|
||
function importerAllowedUnoptimized(importer) { | ||
// virtual modules can contain the rewritten-app location | ||
if (allow.some((a) => url.includes(a))) { | ||
return true; | ||
} | ||
return !!( | ||
importer.includes("node_modules") && | ||
!importer.includes("rewritten-app") | ||
); | ||
} | ||
|
||
if ( | ||
url.includes("node_modules") && | ||
!url.includes("rewritten-app") && | ||
!url.includes(".vite/deps") && | ||
!url.includes("embroider_virtual") && | ||
!importerAllowedUnoptimized(interceptedRequest.initiator().url) | ||
) { | ||
console.error( | ||
"url does not use optimized dep", | ||
url, | ||
interceptedRequest.initiator() | ||
); | ||
unOptimizedDeps.push(url); | ||
} | ||
} | ||
page.on("request", logRequest); | ||
|
||
page.on("console", (msg) => { | ||
const text = msg.text(); | ||
const location = msg.location(); | ||
if (text.includes("HARNESS")) { | ||
try { | ||
const parsed = JSON.parse(text); | ||
if (parsed.type === "[HARNESS] done") { | ||
return fulfill(parsed.failed > 0 ? 1 : 0); | ||
} | ||
} catch (e) {} | ||
} | ||
if (location.url?.includes(`/qunit.js`)) { | ||
console.log(text); | ||
} else { | ||
console.debug(text); | ||
} | ||
}); | ||
|
||
await page.goto("http://localhost:60173/tests/?hidepassed&ci"); | ||
}) | ||
); | ||
|
||
await browser.close(); | ||
|
||
if (unOptimizedDeps.length) { | ||
console.error("unoptimized deps detected"); | ||
process.exit(1); | ||
return; | ||
} | ||
|
||
process.exit(result); | ||
} | ||
|
||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
import child from 'child_process'; | ||
import { resolve } from 'path'; | ||
import PCR from 'puppeteer-chromium-resolver'; | ||
|
||
const __root = process.cwd(); | ||
|
||
async function run() { | ||
// eslint-disable-next-line new-cap | ||
const { puppeteer, executablePath } = await PCR({}); | ||
console.log('[ci] starting'); | ||
|
||
await /** @type {Promise<void>} */ ( | ||
new Promise(fulfill => { | ||
const runvite = child.fork( | ||
resolve(__root, 'node_modules', 'vite', 'bin', 'vite.js'), | ||
['--port', '60173', '--no-open'], | ||
{ | ||
stdio: 'pipe', | ||
} | ||
); | ||
|
||
process.on('exit', () => runvite.kill()); | ||
|
||
runvite.stderr.on('data', data => { | ||
console.log('stderr', String(data)); | ||
}); | ||
|
||
runvite.stdout.on('data', data => { | ||
const chunk = String(data); | ||
console.log('stdout', chunk); | ||
if (chunk.includes('Local') && chunk.includes('60173')) { | ||
fulfill(1); | ||
} | ||
}); | ||
|
||
console.log('[ci] spawning'); | ||
}) | ||
); | ||
|
||
console.log('[ci] spawned'); | ||
|
||
const browser = await puppeteer.launch({ | ||
headless: 'new', | ||
executablePath, | ||
args: ['--no-sandbox', '--disable-setuid-sandbox'], | ||
}); | ||
|
||
console.log('[ci] puppeteer launched'); | ||
|
||
let unOptimizedDeps = []; | ||
|
||
const result = await /** @type {Promise<void>} */ ( | ||
// eslint-disable-next-line no-async-promise-executor | ||
new Promise(async fulfill => { | ||
const page = await browser.newPage(); | ||
|
||
page.on('pageerror', msg => { | ||
console.error(msg); | ||
fulfill(1); | ||
}); | ||
|
||
function logRequest(interceptedRequest) { | ||
const url = interceptedRequest.url(); | ||
const allow = [ | ||
'vite/dist/client/env.mjs', | ||
'@babel+runtime', | ||
'.css', | ||
'@embroider/macros', | ||
'ember-source/ember/index.js', | ||
]; | ||
|
||
function importerAllowedUnoptimized(importer) { | ||
// virtual modules can contain the rewritten-app location | ||
if (allow.some(a => url.includes(a))) { | ||
return true; | ||
} | ||
return !!(importer.includes('node_modules') && !importer.includes('rewritten-app')); | ||
} | ||
|
||
if ( | ||
url.includes('node_modules') && | ||
!url.includes('rewritten-app') && | ||
!url.includes('.vite/deps') && | ||
!url.includes('embroider_virtual') && | ||
!importerAllowedUnoptimized(interceptedRequest.initiator().url) | ||
) { | ||
console.error('url does not use optimized dep', url, interceptedRequest.initiator()); | ||
unOptimizedDeps.push(url); | ||
} | ||
} | ||
page.on('request', logRequest); | ||
|
||
page.on('console', msg => { | ||
const text = msg.text(); | ||
const location = msg.location(); | ||
if (text.includes('HARNESS')) { | ||
try { | ||
const parsed = JSON.parse(text); | ||
if (parsed.type === '[HARNESS] done') { | ||
return fulfill(parsed.failed > 0 ? 1 : 0); | ||
} | ||
} catch (e) {} | ||
} | ||
if (location.url?.includes(`/qunit.js`)) { | ||
console.log(text); | ||
} else { | ||
console.debug(text); | ||
} | ||
}); | ||
|
||
await page.goto('http://localhost:60173/tests/?hidepassed&ci'); | ||
}) | ||
); | ||
|
||
await browser.close(); | ||
|
||
if (unOptimizedDeps.length) { | ||
console.error('unoptimized deps detected'); | ||
process.exit(1); | ||
return; | ||
} | ||
|
||
process.exit(result); | ||
} | ||
|
||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters