Skip to content

Commit

Permalink
chore: generate protocol during browser roll (#2719)
Browse files Browse the repository at this point in the history
We now commit protocol.ts files during the roll.
New utils/roll_browser.js helps with that.

This makes our installation very shallow:
- build installer;
- download browsers.
  • Loading branch information
dgozman authored Jul 1, 2020
1 parent 991e8d4 commit 5c4751d
Show file tree
Hide file tree
Showing 20 changed files with 26,052 additions and 137 deletions.
5 changes: 2 additions & 3 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ build: off
install:
- ps: Install-Product node $env:nodejs_version
- npm ci
- npm run ctest
- npm run wtest
- npm run ftest
- npm run build
- npm run test
13 changes: 7 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ jobs:
- checkout

- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
key: dependency-cache-{{ checksum "browsers.json" }}

- run:
command: npm ci

- run:
command: npm run build

- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
key: dependency-cache-{{ checksum "browsers.json" }}
paths:
- ./.local-browsers
- $HOME/.cache/ms-playwright

- run:
command: |
xvfb-run --auto-servernum npm run ctest
xvfb-run --auto-servernum npm run wtest
xvfb-run --auto-servernum npm run ftest
xvfb-run --auto-servernum npm run test
47 changes: 0 additions & 47 deletions .cirrus.yml

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/infra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ jobs:
sudo apt-get install libgbm-dev
sudo apt-get install xvfb
- run: npm ci
- run: npm run build
- run: npm run lint
1 change: 1 addition & 0 deletions .github/workflows/publish_canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
registry-url: 'https://registry.npmjs.org'
- uses: microsoft/playwright-github-action@v1
- run: npm ci
- run: npm run build
- run: node utils/update_version.js --next
- run: utils/publish_all_packages.sh --tip-of-tree
env:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
registry-url: 'https://registry.npmjs.org'
- uses: microsoft/playwright-github-action@v1
- run: npm ci
- run: npm run build
- run: utils/publish_all_packages.sh --release
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
node-version: 10
- uses: microsoft/playwright-github-action@v1
- run: npm ci
- run: npm run build
- run: mkdir -p coredumps
# Set core dump file name pattern
- run: sudo bash -c 'echo "$(pwd -P)/coredumps/core-pid_%p.dump" > /proc/sys/kernel/core_pattern'
Expand Down Expand Up @@ -61,6 +62,7 @@ jobs:
node-version: 10
- uses: microsoft/playwright-github-action@v1
- run: npm ci
- run: npm run build
- run: npm run ctest 2>./chromium-mac-testrun.log
env:
DEBUG: "*"
Expand All @@ -85,6 +87,7 @@ jobs:
node-version: 10
- uses: microsoft/playwright-github-action@v1
- run: npm ci
- run: npm run build
- run: npm run ctest 2>./chromium-win-testrun.log
shell: bash
env:
Expand All @@ -110,6 +113,7 @@ jobs:
node-version: 10
- uses: microsoft/playwright-github-action@v1
- run: npm ci
- run: npm run build
- run: mkdir -p coredumps
# Set core dump file name pattern
- run: sudo bash -c 'echo "$(pwd -P)/coredumps/core-pid_%p.dump" > /proc/sys/kernel/core_pattern'
Expand Down Expand Up @@ -145,6 +149,7 @@ jobs:
node-version: 10
- uses: microsoft/playwright-github-action@v1
- run: npm ci
- run: npm run build
- run: npm run wtest 2>./webkit-mac-testrun.log
env:
DEBUG: "*,-pw:wrapped*"
Expand All @@ -169,6 +174,7 @@ jobs:
node-version: 10
- uses: microsoft/playwright-github-action@v1
- run: npm ci
- run: npm run build
- run: npm run wtest 2>./webkit-win-testrun.log
shell: bash
env:
Expand All @@ -194,6 +200,7 @@ jobs:
node-version: 10
- uses: microsoft/playwright-github-action@v1
- run: npm ci
- run: npm run build
- run: mkdir -p coredumps
# Set core dump file name pattern
- run: sudo bash -c 'echo "$(pwd -P)/coredumps/core-pid_%p.dump" > /proc/sys/kernel/core_pattern'
Expand Down Expand Up @@ -229,6 +236,7 @@ jobs:
node-version: 10
- uses: microsoft/playwright-github-action@v1
- run: npm ci
- run: npm run build
- run: npm run ftest 2>./firefox-mac-testrun.log
env:
DEBUG: "*"
Expand All @@ -253,6 +261,7 @@ jobs:
node-version: 10
- uses: microsoft/playwright-github-action@v1
- run: npm ci
- run: npm run build
- run: npm run ftest 2>./firefox-win-testrun.log
shell: bash
env:
Expand Down Expand Up @@ -283,6 +292,7 @@ jobs:
node-version: ${{ matrix.node_version }}
- uses: microsoft/playwright-github-action@v1
- run: npm ci
- run: npm run build
- run: bash packages/installation-tests/installation-tests.sh

headful_linux:
Expand All @@ -295,6 +305,7 @@ jobs:
node-version: 10
- uses: microsoft/playwright-github-action@v1
- run: npm ci
- run: npm run build
- run: mkdir -p coredumps
# Set core dump file name pattern
- run: sudo bash -c 'echo "$(pwd -P)/coredumps/core-pid_%p.dump" > /proc/sys/kernel/core_pattern'
Expand Down Expand Up @@ -326,6 +337,7 @@ jobs:
node-version: 10
- uses: microsoft/playwright-github-action@v1
- run: npm ci
- run: npm run build
- run: mkdir -p coredumps
# Set core dump file name pattern
- run: sudo bash -c 'echo "$(pwd -P)/coredumps/core-pid_%p.dump" > /proc/sys/kernel/core_pattern'
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,5 @@
yarn.lock
/node6
/src/generated/*
/src/chromium/protocol.ts
/src/firefox/protocol.ts
/src/webkit/protocol.ts
lib/
/types/*
12 changes: 4 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,12 @@ jobs:
# this is needed for running headful tests
- xvfb
script:
- npm run lint
- xvfb-run --auto-servernum npm run ctest
- xvfb-run --auto-servernum npm run ftest
- xvfb-run --auto-servernum npm run wtest
- npm run build
- xvfb-run --auto-servernum npm run test
- os: osx
osx_image: xcode11.3
node_js: '12'
script:
- npm run lint
- npm run ctest
- npm run ftest
- npm run wtest
- npm run build
- npm run test

8 changes: 2 additions & 6 deletions browser_patches/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,8 @@ Send a PR to the Playwright repo to be reviewed.

## 4. Rolling Playwright to the new browser build

Once the patch has been committed, the build bots will kick in, compile and upload a new browser version to all the platforms.

You can check the CDN status:
Once the patch has been committed, the build bots will kick in, compile and upload a new browser version to all the platforms. Then you can roll the browser:

```sh
$ ./browser_patches/tools/check_cdn.sh
$ node utils/roll_browser.js chromium 123456
```

As the builds appear, you can roll to a new browser version in the `./browsers.json` file.
1 change: 1 addition & 0 deletions browsers.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"comment": "Do not edit this file, use utils/roll_browser.js",
"browsers": [
{
"name": "chromium",
Expand Down
68 changes: 8 additions & 60 deletions install-from-github.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,67 +18,15 @@
// This file is only run when someone installs via the github repo

const {execSync} = require('child_process');
const path = require('path');
const fs = require('fs');
const util = require('util');
const rmAsync = util.promisify(require('rimraf'));

(async () => {
const SRC_FOLDER = path.join(__dirname, 'src');
const LIB_FOLDER = path.join(__dirname, 'lib');
const srcTypeScriptFiles = (await listFiles(path.join(__dirname, 'src'))).filter(filepath => filepath.toLowerCase().endsWith('.ts'));
const outdatedFiles = await Promise.all(srcTypeScriptFiles.map(async srcFile => {
const libFileTS = path.join(LIB_FOLDER, path.relative(SRC_FOLDER, srcFile));
const libFile = libFileTS.substring(0, libFileTS.lastIndexOf('.')) + '.js';
try {
const [srcStat, libStat] = await Promise.all([fs.promises.stat(srcFile), fs.promises.stat(libFile)]);
return srcStat.ctimeMs > libStat.ctimeMs;
} catch (e) {
// Either `.ts` of `.js` file is missing - rebuild is required.
return true;
}
}));
if (outdatedFiles.some(Boolean)) {
console.log(`Rebuilding playwright...`);
try {
execSync('npm run build');
} catch (e) {
}
}
await downloadAllBrowsersAndGenerateProtocolTypes();
})();

async function listFiles(dirpath) {
const files = [];
await dfs(dirpath);
return files;

async function dfs(dirpath) {
const entries = await fs.promises.readdir(dirpath, {withFileTypes: true});
files.push(...entries.filter(entry => entry.isFile()).map(entry => path.join(dirpath, entry.name)));
await Promise.all(entries.filter(entry => entry.isDirectory()).map(entry => dfs(path.join(dirpath, entry.name))));
}
console.log(`Rebuilding installer...`);
try {
execSync('npm run tsc-installer');
} catch (e) {
}

async function downloadAllBrowsersAndGenerateProtocolTypes() {
const { installBrowsersWithProgressBar } = require('./lib/install/installer');
const protocolGenerator = require('./utils/protocol-types-generator');
const browserPaths = require('./lib/install/browserPaths');
const browsersPath = browserPaths.browsersPath(__dirname);
const browsers = require(path.join(__dirname, 'browsers.json'))['browsers'];
await installBrowsersWithProgressBar(__dirname);
for (const browser of browsers) {
const browserPath = browserPaths.browserDirectory(browsersPath, browser);
await protocolGenerator.generateProtocol(browser.name, browserPaths.executablePath(browserPath, browser)).catch(console.warn);
}
console.log(`Downloading browsers...`);
const { installBrowsersWithProgressBar } = require('./lib/install/installer');
installBrowsersWithProgressBar(__dirname);

try {
console.log('Generating types...');
execSync('npm run generate-types');
} catch (e) {
}

async function readdirAsync(dirpath) {
return fs.promises.readdir(dirpath).then(dirs => dirs.map(dir => path.join(dirpath, dir)));
}
}
console.log(`Done. Use "npm run watch" to compile.`);
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@
"coverage": "cross-env COVERAGE=true BROWSER=all node --unhandled-rejections=strict test/test.js",
"eslint": "[ \"$CI\" = true ] && eslint --quiet -f codeframe --ext js,ts ./src || eslint --ext js,ts ./src",
"tsc": "tsc -p .",
"tsc-installer": "tsc -p ./src/install/tsconfig.json",
"doc": "node utils/doclint/cli.js",
"test-infra": "node utils/doclint/check_public_api/test/test.js && node utils/doclint/preprocessor/test.js && node utils/testrunner/test/test.js",
"lint": "npm run eslint && npm run tsc && npm run doc && npm run test-types && npm run test-infra",
"debug-test": "node --inspect-brk test/test.js",
"clean": "rimraf lib && rimraf types",
"prepare": "node install-from-github.js",
"build": "node utils/runWebpack.js --mode='development' && tsc -p .",
"build": "node utils/runWebpack.js --mode='development' && tsc -p . && npm run generate-types",
"watch": "node utils/runWebpack.js --mode='development' --watch --silent | tsc -w -p .",
"test-types": "npm run generate-types && npx -p typescript@3.7.5 tsc -p utils/generate_types/test/tsconfig.json",
"generate-types": "node utils/generate_types/"
Expand Down
Loading

0 comments on commit 5c4751d

Please sign in to comment.