feat(cli): build driver and upload to cdn (#4841)
This commit is contained in:
parent
b00559bd53
commit
d47fb6a780
16
.github/workflows/infra.yml
vendored
16
.github/workflows/infra.yml
vendored
|
|
@ -18,8 +18,22 @@ jobs:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-node@v1
|
- uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version: 10.15
|
node-version: 10
|
||||||
- uses: microsoft/playwright-github-action@v1
|
- uses: microsoft/playwright-github-action@v1
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
- run: npm run lint
|
- run: npm run lint
|
||||||
|
|
||||||
|
build-playwright-driver:
|
||||||
|
name: "build-playwright-driver"
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: 10
|
||||||
|
- uses: microsoft/playwright-github-action@v1
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm run build
|
||||||
|
- run: node utils/build/update_canary_version.js
|
||||||
|
- run: utils/build/build-playwright-driver.sh
|
||||||
|
|
|
||||||
29
.github/workflows/publish_canary_driver.yml
vendored
Normal file
29
.github/workflows/publish_canary_driver.yml
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
name: "devrelease:driver"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- release-*
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish-canary-driver:
|
||||||
|
name: "publish playwright driver to CDN"
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
if: github.repository == 'microsoft/playwright'
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: 12.x
|
||||||
|
registry-url: 'https://registry.npmjs.org'
|
||||||
|
- uses: microsoft/playwright-github-action@v1
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm run build
|
||||||
|
- run: node utils/build/update_canary_version.js
|
||||||
|
- run: utils/build/build-playwright-driver.sh
|
||||||
|
- run: utils/build/upload-playwright-driver.sh
|
||||||
|
env:
|
||||||
|
AZ_UPLOAD_FOLDER: driver/next
|
||||||
|
AZ_ACCOUNT_KEY: ${{ secrets.AZ_ACCOUNT_KEY }}
|
||||||
|
AZ_ACCOUNT_NAME: ${{ secrets.AZ_ACCOUNT_NAME }}
|
||||||
2
.github/workflows/publish_canary_npm.yml
vendored
2
.github/workflows/publish_canary_npm.yml
vendored
|
|
@ -20,7 +20,7 @@ jobs:
|
||||||
- uses: microsoft/playwright-github-action@v1
|
- uses: microsoft/playwright-github-action@v1
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
- run: node utils/update_version.js --next
|
- run: node utils/build/update_canary_version.js
|
||||||
- run: utils/publish_all_packages.sh --tip-of-tree
|
- run: utils/publish_all_packages.sh --tip-of-tree
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
|
||||||
1
.github/workflows/tests.yml
vendored
1
.github/workflows/tests.yml
vendored
|
|
@ -231,6 +231,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
name: video-${{ matrix.browser }}-linux-test-results
|
name: video-${{ matrix.browser }}-linux-test-results
|
||||||
path: test-results
|
path: test-results
|
||||||
|
|
||||||
test_android:
|
test_android:
|
||||||
name: Android Emulator
|
name: Android Emulator
|
||||||
runs-on: macos-10.15
|
runs-on: macos-10.15
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import { installHarTracer } from './trace/harTracer';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
function setupInProcess(): PlaywrightAPI {
|
function setupInProcess(): PlaywrightAPI {
|
||||||
const playwright = new PlaywrightImpl(path.join(__dirname, '..'), require(path.join(__dirname, '..', 'browsers.json'))['browsers']);
|
const playwright = new PlaywrightImpl(path.join(__dirname, '..'), require('../browsers.json')['browsers']);
|
||||||
|
|
||||||
installDebugController();
|
installDebugController();
|
||||||
installTracer();
|
installTracer();
|
||||||
|
|
|
||||||
1
utils/build/.gitignore
vendored
Normal file
1
utils/build/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
output
|
||||||
69
utils/build/build-playwright-driver.sh
Executable file
69
utils/build/build-playwright-driver.sh
Executable file
|
|
@ -0,0 +1,69 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
set +x
|
||||||
|
|
||||||
|
trap "cd $(pwd -P)" EXIT
|
||||||
|
SCRIPT_PATH="$(cd "$(dirname "$0")" ; pwd -P)"
|
||||||
|
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
PACKAGE_VERSION=$(node -p "require('../../package.json').version")
|
||||||
|
rm -rf ./output
|
||||||
|
mkdir -p ./output
|
||||||
|
|
||||||
|
echo "Building playwright package"
|
||||||
|
../../packages/build_package.js playwright ./output/playwright.tgz
|
||||||
|
|
||||||
|
function build {
|
||||||
|
NODE_DIR=$1
|
||||||
|
SUFFIX=$2
|
||||||
|
ARCHIVE=$3
|
||||||
|
RUN_DRIVER=$4
|
||||||
|
NODE_URL=https://nodejs.org/dist/v12.20.1/${NODE_DIR}.${ARCHIVE}
|
||||||
|
|
||||||
|
echo "Building playwright-${PACKAGE_VERSION}-${SUFFIX}"
|
||||||
|
|
||||||
|
cd ${SCRIPT_PATH}
|
||||||
|
|
||||||
|
mkdir -p ./output/playwright-${SUFFIX}
|
||||||
|
tar -xzvf ./output/playwright.tgz -C ./output/playwright-${SUFFIX}/
|
||||||
|
|
||||||
|
curl ${NODE_URL} -o ./output/${NODE_DIR}.${ARCHIVE}
|
||||||
|
NPM_PATH=""
|
||||||
|
if [[ "${ARCHIVE}" == "zip" ]]; then
|
||||||
|
cd ./output
|
||||||
|
unzip ./${NODE_DIR}.zip
|
||||||
|
cd ..
|
||||||
|
cp ./output/${NODE_DIR}/node.exe ./output/playwright-${SUFFIX}/
|
||||||
|
NPM_PATH="node_modules/npm/bin/npm-cli.js"
|
||||||
|
elif [[ "${ARCHIVE}" == "tar.gz" ]]; then
|
||||||
|
tar -xzvf ./output/${NODE_DIR}.tar.gz -C ./output/
|
||||||
|
cp ./output/${NODE_DIR}/bin/node ./output/playwright-${SUFFIX}/
|
||||||
|
NPM_PATH="lib/node_modules/npm/bin/npm-cli.js"
|
||||||
|
else
|
||||||
|
echo "Unsupported ARCHIVE ${ARCHIVE}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp ./output/${NODE_DIR}/LICENSE ./output/playwright-${SUFFIX}/
|
||||||
|
cd ./output/playwright-${SUFFIX}/package
|
||||||
|
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 node "../../${NODE_DIR}/${NPM_PATH}" install --production
|
||||||
|
rm package-lock.json
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
if [[ "${RUN_DRIVER}" == *".cmd" ]]; then
|
||||||
|
cp ../../${RUN_DRIVER} ./playwright.cmd
|
||||||
|
chmod +x ./playwright.cmd
|
||||||
|
elif [[ "${RUN_DRIVER}" == *".sh" ]]; then
|
||||||
|
cp ../../${RUN_DRIVER} ./playwright.sh
|
||||||
|
chmod +x ./playwright.sh
|
||||||
|
else
|
||||||
|
echo "Unsupported RUN_DRIVER ${RUN_DRIVER}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
zip -r ../playwright-${PACKAGE_VERSION}-${SUFFIX}.zip .
|
||||||
|
}
|
||||||
|
|
||||||
|
build "node-v12.20.1-darwin-x64" "mac" "tar.gz" "run-driver-posix.sh"
|
||||||
|
build "node-v12.20.1-linux-x64" "linux" "tar.gz" "run-driver-posix.sh"
|
||||||
|
build "node-v12.20.1-win-x64" "win32_x64" "zip" "run-driver-win.cmd"
|
||||||
|
build "node-v12.20.1-win-x86" "win32" "zip" "run-driver-win.cmd"
|
||||||
3
utils/build/run-driver-posix.sh
Executable file
3
utils/build/run-driver-posix.sh
Executable file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
SCRIPT_PATH="$(cd "$(dirname "$0")" ; pwd -P)"
|
||||||
|
$SCRIPT_PATH/node $SCRIPT_PATH/package/lib/cli/cli.js "$@"
|
||||||
3
utils/build/run-driver-win.cmd
Executable file
3
utils/build/run-driver-win.cmd
Executable file
|
|
@ -0,0 +1,3 @@
|
||||||
|
@ECHO OFF
|
||||||
|
SETLOCAL
|
||||||
|
"%~dp0\node.exe" "%~dp0\package\lib\cli\cli.js" %*
|
||||||
28
utils/build/update_canary_version.js
Executable file
28
utils/build/update_canary_version.js
Executable file
|
|
@ -0,0 +1,28 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
/**
|
||||||
|
* Copyright (c) Microsoft Corporation.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const { execSync } = require('child_process');
|
||||||
|
|
||||||
|
const timestamp = execSync('git show -s --format=%ct HEAD', {
|
||||||
|
stdio: ['ignore', 'pipe', 'ignore']
|
||||||
|
}).toString('utf8').trim() + '000';
|
||||||
|
const packageJSON = require('../../package.json');
|
||||||
|
packageJSON.version = packageJSON.version + '-' + timestamp;
|
||||||
|
console.log('Setting version to ' + packageJSON.version);
|
||||||
|
fs.writeFileSync(path.join(__dirname, '..', '..', 'package.json'), JSON.stringify(packageJSON, undefined, 2) + '\n');
|
||||||
12
utils/build/upload-playwright-driver.sh
Executable file
12
utils/build/upload-playwright-driver.sh
Executable file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
set +x
|
||||||
|
|
||||||
|
trap "cd $(pwd -P)" EXIT
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
|
PACKAGE_VERSION=$(node -p "require('../../package.json').version")
|
||||||
|
az storage blob upload -c builds --account-key ${AZ_ACCOUNT_KEY} --account-name ${AZ_ACCOUNT_NAME} -f ./output/playwright-${PACKAGE_VERSION}-mac.zip -n "${AZ_UPLOAD_FOLDER}/playwright-${PACKAGE_VERSION}-mac.zip"
|
||||||
|
az storage blob upload -c builds --account-key ${AZ_ACCOUNT_KEY} --account-name ${AZ_ACCOUNT_NAME} -f ./output/playwright-${PACKAGE_VERSION}-linux.zip -n "${AZ_UPLOAD_FOLDER}/playwright-${PACKAGE_VERSION}-linux.zip"
|
||||||
|
az storage blob upload -c builds --account-key ${AZ_ACCOUNT_KEY} --account-name ${AZ_ACCOUNT_NAME} -f ./output/playwright-${PACKAGE_VERSION}-win32_x64.zip -n "${AZ_UPLOAD_FOLDER}/playwright-${PACKAGE_VERSION}-win32_x64.zip"
|
||||||
|
az storage blob upload -c builds --account-key ${AZ_ACCOUNT_KEY} --account-name ${AZ_ACCOUNT_NAME} -f ./output/playwright-${PACKAGE_VERSION}-win32.zip -n "${AZ_UPLOAD_FOLDER}/playwright-${PACKAGE_VERSION}-win32.zip"
|
||||||
|
|
@ -1,74 +0,0 @@
|
||||||
#!/usr/bin/env node
|
|
||||||
/**
|
|
||||||
* Copyright (c) Microsoft Corporation.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
const { execSync } = require('child_process');
|
|
||||||
|
|
||||||
const SCRIPT_NAME = path.basename(__filename);
|
|
||||||
const USAGE = `
|
|
||||||
Usage: ${SCRIPT_NAME} [--next|<version>|--help]
|
|
||||||
|
|
||||||
--next generate the @next version and put it across all packages
|
|
||||||
<version> set a new version across all packages. See examples for format
|
|
||||||
--help show this help message
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
${SCRIPT_NAME} v1.0.0
|
|
||||||
${SCRIPT_NAME} v1.0.0-next
|
|
||||||
${SCRIPT_NAME} --next
|
|
||||||
`;
|
|
||||||
|
|
||||||
if (process.argv[2] === '--help' || process.argv[2] === '-h') {
|
|
||||||
console.log(USAGE);
|
|
||||||
process.exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.argv.length !== 3) {
|
|
||||||
console.log(`ERROR: missing version argument. Use --help for details.`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
let version = process.argv[2];
|
|
||||||
if (version === '--next') {
|
|
||||||
const packageJSON = require('../package.json');
|
|
||||||
version = packageJSON.version;
|
|
||||||
if (!version.includes('-'))
|
|
||||||
version += '-next';
|
|
||||||
const timestamp = execSync('git show -s --format=%ct HEAD', {
|
|
||||||
stdio: ['ignore', 'pipe', 'ignore']
|
|
||||||
}).toString('utf8').trim() + '000';
|
|
||||||
version += '.' + timestamp;
|
|
||||||
console.log('Setting version to ' + version);
|
|
||||||
} else {
|
|
||||||
if (!version || !version.match(/^v\d+\.\d+\.\d+(-next)?$/)) {
|
|
||||||
console.error(`Malformed version "${version}". Use --help for details.`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
version = version.substring(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
updatePackage(path.join(__dirname, '..', 'package.json'), packageJSON => {
|
|
||||||
packageJSON.version = version;
|
|
||||||
});
|
|
||||||
|
|
||||||
function updatePackage(packageJSONPath, transform) {
|
|
||||||
console.log(`Updating ${packageJSONPath} to ${version}.`);
|
|
||||||
const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath, 'utf8'));
|
|
||||||
transform(packageJSON);
|
|
||||||
fs.writeFileSync(packageJSONPath, JSON.stringify(packageJSON, undefined, 2) + '\n');
|
|
||||||
}
|
|
||||||
Loading…
Reference in a new issue