diff --git a/.github/workflows/infra.yml b/.github/workflows/infra.yml index ec64e35cd5..c2b32aa7e6 100644 --- a/.github/workflows/infra.yml +++ b/.github/workflows/infra.yml @@ -18,8 +18,22 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: - node-version: 10.15 + node-version: 10 - uses: microsoft/playwright-github-action@v1 - run: npm ci - run: npm run build - 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 diff --git a/.github/workflows/publish_canary_driver.yml b/.github/workflows/publish_canary_driver.yml new file mode 100644 index 0000000000..6f4d74a4d2 --- /dev/null +++ b/.github/workflows/publish_canary_driver.yml @@ -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 }} diff --git a/.github/workflows/publish_canary_npm.yml b/.github/workflows/publish_canary_npm.yml index 19256142c6..2529d42a6b 100644 --- a/.github/workflows/publish_canary_npm.yml +++ b/.github/workflows/publish_canary_npm.yml @@ -20,7 +20,7 @@ jobs: - uses: microsoft/playwright-github-action@v1 - run: npm ci - 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 env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 08b516c05e..76190e70ab 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -231,6 +231,7 @@ jobs: with: name: video-${{ matrix.browser }}-linux-test-results path: test-results + test_android: name: Android Emulator runs-on: macos-10.15 diff --git a/src/inprocess.ts b/src/inprocess.ts index 01e3ac05f9..cbdde71109 100644 --- a/src/inprocess.ts +++ b/src/inprocess.ts @@ -26,7 +26,7 @@ import { installHarTracer } from './trace/harTracer'; import * as path from 'path'; 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(); installTracer(); diff --git a/utils/build/.gitignore b/utils/build/.gitignore new file mode 100644 index 0000000000..6caf68aff4 --- /dev/null +++ b/utils/build/.gitignore @@ -0,0 +1 @@ +output \ No newline at end of file diff --git a/utils/build/build-playwright-driver.sh b/utils/build/build-playwright-driver.sh new file mode 100755 index 0000000000..6a21f24482 --- /dev/null +++ b/utils/build/build-playwright-driver.sh @@ -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" diff --git a/utils/build/run-driver-posix.sh b/utils/build/run-driver-posix.sh new file mode 100755 index 0000000000..0b41225345 --- /dev/null +++ b/utils/build/run-driver-posix.sh @@ -0,0 +1,3 @@ +#!/bin/sh +SCRIPT_PATH="$(cd "$(dirname "$0")" ; pwd -P)" +$SCRIPT_PATH/node $SCRIPT_PATH/package/lib/cli/cli.js "$@" diff --git a/utils/build/run-driver-win.cmd b/utils/build/run-driver-win.cmd new file mode 100755 index 0000000000..47d2fc21d2 --- /dev/null +++ b/utils/build/run-driver-win.cmd @@ -0,0 +1,3 @@ +@ECHO OFF +SETLOCAL +"%~dp0\node.exe" "%~dp0\package\lib\cli\cli.js" %* diff --git a/utils/build/update_canary_version.js b/utils/build/update_canary_version.js new file mode 100755 index 0000000000..582dc4d45f --- /dev/null +++ b/utils/build/update_canary_version.js @@ -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'); diff --git a/utils/build/upload-playwright-driver.sh b/utils/build/upload-playwright-driver.sh new file mode 100755 index 0000000000..52d80e877a --- /dev/null +++ b/utils/build/upload-playwright-driver.sh @@ -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" diff --git a/utils/update_version.js b/utils/update_version.js deleted file mode 100755 index 2e6b8478a8..0000000000 --- a/utils/update_version.js +++ /dev/null @@ -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||--help] - - --next generate the @next version and put it across all packages - 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'); -}