Skip to content

Commit

Permalink
chore: add revision lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN committed Apr 24, 2023
1 parent 3a73667 commit b3ad62c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,52 +39,59 @@ import {execSync} from 'child_process';
import packageJson from '../package.json';
import {PUPPETEER_REVISIONS} from '../src/revisions.js';

const currentProtocolPackageInstalledVersion =
packageJson.dependencies['devtools-protocol'];

/**
* Ensure that the devtools-protocol version is pinned.
*/
if (/^[^0-9]/.test(currentProtocolPackageInstalledVersion)) {
console.log(
`ERROR: devtools-protocol package is not pinned to a specific version.\n`
async function main() {
const currentProtocolPackageInstalledVersion =
packageJson.dependencies['devtools-protocol'];

/**
* Ensure that the devtools-protocol version is pinned.
*/
if (/^[^0-9]/.test(currentProtocolPackageInstalledVersion)) {
console.log(
`ERROR: devtools-protocol package is not pinned to a specific version.\n`
);
process.exit(1);
}

const chromeVersion = PUPPETEER_REVISIONS.chrome;
// find the right revision for our Chrome version.
const req = await fetch(
`https://chromiumdash.appspot.com/fetch_releases?channel=stable`
);
process.exit(1);
}

const chromeVersion = PUPPETEER_REVISIONS.chrome;
console.log('Current Chrome version', chromeVersion);

// TODO: lookup revision based on the version.
const chromeRevision = '1109224';
const stableReleases = await req.json();
const chromeRevision = stableReleases.find(release => {
return release.version === chromeVersion;
}).chromium_main_branch_position;
console.log(`Revisions for ${chromeVersion}: ${chromeRevision}`);

// find the right revision for our Chromium revision
const command = `npm view "devtools-protocol@<=0.0.${chromeRevision}" version | tail -1`;

const command = `npm view "devtools-protocol@<=0.0.${chromeRevision}" version | tail -1`;

console.log(
'Checking npm for devtools-protocol revisions:\n',
`'${command}'`,
'\n'
);
console.log(
'Checking npm for devtools-protocol revisions:\n',
`'${command}'`,
'\n'
);

const output = execSync(command, {
encoding: 'utf8',
});
const output = execSync(command, {
encoding: 'utf8',
});

const bestRevisionFromNpm = output.split(' ')[1]!.replace(/'|\n/g, '');
const bestRevisionFromNpm = output.split(' ')[1]!.replace(/'|\n/g, '');

if (currentProtocolPackageInstalledVersion !== bestRevisionFromNpm) {
console.log(`ERROR: bad devtools-protocol revision detected:
if (currentProtocolPackageInstalledVersion !== bestRevisionFromNpm) {
console.log(`ERROR: bad devtools-protocol revision detected:
Current Puppeteer Chromium revision: ${chromeRevision}
Current devtools-protocol version in package.json: ${currentProtocolPackageInstalledVersion}
Expected devtools-protocol version: ${bestRevisionFromNpm}`);

process.exit(1);
process.exit(1);
}

console.log(
`Correct devtools-protocol version found (${bestRevisionFromNpm}).`
);
process.exit(0);
}

console.log(
`Correct devtools-protocol version found (${bestRevisionFromNpm}).`
);
process.exit(0);
main();
2 changes: 1 addition & 1 deletion test/TestExpectations.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@
"testIdPattern": "[launcher.spec] Launcher specs Puppeteer Puppeteer.launch should work with no default arguments",
"platforms": ["darwin", "linux", "win32"],
"parameters": ["chrome"],
"expectations": ["TIMEOUT"]
"expectations": ["FAIL", "TIMEOUT"]
},
{
"testIdPattern": "[navigation.spec] navigation Page.goto should fail when navigating to bad SSL",
Expand Down

0 comments on commit b3ad62c

Please sign in to comment.