Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
devops: revamp scripts
Andrey Lushnikov98e05b66fd20
diff --git a/browser_patches/checkout_build_archive_upload.sh b/browser_patches/checkout_build_archive_upload.shindex f715b72ce0..b343a7f878 100755--- a/browser_patches/checkout_build_archive_upload.sh+++ b/browser_patches/checkout_build_archive_upload.sh@@ -52,9 +52,7 @@ elsefiecho "-- preparing checkout"-# the "do_checkout" script asks if you want to reset existing branch.-# sure we do!-yes | ./do_checkout.sh $BROWSER_NAME+./prepare_checkout.sh $BROWSER_NAMEecho "-- building"./$BROWSER_NAME/build.shecho "-- archiving to $ZIP_PATH"diff --git a/browser_patches/do_checkout.sh b/browser_patches/do_checkout.shdeleted file mode 100755index dcf15a8d58..0000000000--- a/browser_patches/do_checkout.sh+++ /dev/null@@ -1,131 +0,0 @@-#!/bin/bash-set -e-set +x--trap "cd $(pwd -P)" EXIT-cd "$(dirname "$0")"--if [[ ($1 == '--help') || ($1 == '-h') ]]; then- echo "usage: $(basename $0) [firefox|webkit]"- echo- echo "Produces a browser checkout ready to be built."- echo- exit 0-fi--if [[ $# == 0 ]]; then- echo "missing browser: 'firefox' or 'webkit'"- echo "try './$(basename $0) --help' for more information"- exit 1-fi--# FRIENDLY_CHECKOUT_PATH is used only for logging.-FRIENDLY_CHECKOUT_PATH="";-CHECKOUT_PATH=""-# Export path is where we put the patches and BASE_REVISION-REMOTE_URL=""-BASE_BRANCH=""-if [[ ("$1" == "firefox") || ("$1" == "firefox/") ]]; then- # we always apply our patches atop of beta since it seems to get better- # reliability guarantees.- BASE_BRANCH="beta"- FRIENDLY_CHECKOUT_PATH="//browser_patches/firefox/checkout";- CHECKOUT_PATH="$PWD/firefox/checkout"- REMOTE_URL="https://github.com/mozilla/gecko-dev"-elif [[ ("$1" == "webkit") || ("$1" == "webkit/") ]]; then- # webkit has only a master branch.- BASE_BRANCH="master"- FRIENDLY_CHECKOUT_PATH="//browser_patches/webkit/checkout";- CHECKOUT_PATH="$PWD/webkit/checkout"- REMOTE_URL=""- REMOTE_URL="https://github.com/webkit/webkit"-else- echo ERROR: unknown browser - "$1"- exit 1-fi--# if there's no checkout folder - checkout one.-if ! [[ -d $CHECKOUT_PATH ]]; then- echo "-- $FRIENDLY_CHECKOUT_PATH is missing - checking out.."- git clone --single-branch --branch $BASE_BRANCH $REMOTE_URL $CHECKOUT_PATH-else- echo "-- checking $FRIENDLY_CHECKOUT_PATH folder - OK"-fi--# if folder exists but not a git repository - bail out.-if ! [[ -d $CHECKOUT_PATH/.git ]]; then- echo "ERROR: $FRIENDLY_CHECKOUT_PATH is not a git repository! Remove it and re-run the script."- exit 1-else- echo "-- checking $FRIENDLY_CHECKOUT_PATH is a git repo - OK"-fi--# Switch to git repository.-cd $CHECKOUT_PATH--# Check if git repo is dirty.-if [[ -n $(git status -s) ]]; then- echo "ERROR: $FRIENDLY_CHECKOUT_PATH has dirty GIT state - commit everything and re-run the script."- exit 1-fi--if [[ $(git config --get remote.origin.url) == "$REMOTE_URL" ]]; then- echo "-- checking git origin url to point to $REMOTE_URL - OK";-else- echo "ERROR: git origin url DOES NOT point to $REMOTE_URL. Remove $FRIENDLY_CHECKOUT_PATH and re-run the script.";- exit 1-fi--# if there's no "BASE_BRANCH" branch - bail out.-if ! git show-ref --verify --quiet refs/heads/$BASE_BRANCH; then- echo "ERROR: $FRIENDLY_CHECKOUT_PATH/ does not have '$BASE_BRANCH' branch! Remove checkout/ and re-run the script."- exit 1-else- echo "-- checking $FRIENDLY_CHECKOUT_PATH has 'beta' branch - OK"-fi--if ! [[ -z $(git log --oneline origin/$BASE_BRANCH..$BASE_BRANCH) ]]; then- echo "ERROR: branch '$BASE_BRANCH' and branch 'origin/$BASE_BRANCH' have diverged - bailing out. Remove checkout/ and re-run the script."- exit 1;-else- echo "-- checking that $BASE_BRANCH and origin/$BASE_BRANCH are not diverged - OK"-fi--git checkout $BASE_BRANCH-git pull origin $BASE_BRANCH--PINNED_COMMIT=$(cat ../BASE_REVISION)-if ! git cat-file -e $PINNED_COMMIT^{commit}; then- echo "ERROR: $FRIENDLY_CHECKOUT_PATH/ does not include the BASE_REVISION (@$PINNED_COMMIT). Remove checkout/ and re-run the script."- exit 1-else- echo "-- checking $FRIENDLY_CHECKOUT_PATH repo has BASE_REVISION (@$PINNED_COMMIT) commit - OK"-fi--# If there's already a PWDEV branch than we should check if it's fine to reset all changes-# to it.-if git show-ref --verify --quiet refs/heads/pwdev; then- read -p "Do you want to reset 'PWDEV' branch? (ALL CHANGES WILL BE LOST) Y/n " -n 1 -r- echo- # if it's not fine to reset branch - bail out.- if ! [[ $REPLY =~ ^[Yy]$ ]]; then- echo "If you want to keep the branch, than I can't do much! Bailing out!"- exit 1- else- git checkout pwdev- git reset --hard $PINNED_COMMIT- echo "-- PWDEV now points to BASE_REVISION (@$PINNED_COMMIT)"- fi-else- # Otherwise just create a new branch.- git checkout -b pwdev- git reset --hard $PINNED_COMMIT- echo "-- created 'pwdev' branch that points to BASE_REVISION (@$PINNED_COMMIT)."-fi--echo "-- applying all patches"-git am ../patches/*--echo-echo-echo "DONE. Browser is ready to be built."diff --git a/browser_patches/export.sh b/browser_patches/export.shindex 3d89e7c14f..96d0e48049 100755--- a/browser_patches/export.sh+++ b/browser_patches/export.sh@@ -5,10 +5,15 @@ set +xtrap "cd $(pwd -P)" EXITcd "$(dirname "$0")"+REMOTE_BROWSER_UPSTREAM="browser_upstream"+BUILD_BRANCH="playwright-build"+if [[ ($1 == '--help') || ($1 == '-h') ]]; thenecho "usage: export.sh [firefox|webkit] [custom_checkout_path]"echo- echo "Exports BASE_REVISION and patch from the checkout to browser folder."+ echo "Exports patch from the current branch of the checkout to browser folder."+ echo "The checkout has to be 'prepared', meaning that 'prepare_checkout.sh' should be"+ echo "run against it first."echoecho "You can optionally specify custom_checkout_path if you have browser checkout somewhere else"echo "and wish to export patches from it."@@ -25,22 +30,17 @@ fi# FRIENDLY_CHECKOUT_PATH is used only for logging.FRIENDLY_CHECKOUT_PATH="";CHECKOUT_PATH=""-# Export path is where we put the patches and BASE_REVISIONEXPORT_PATH=""-BASE_BRANCH=""if [[ ("$1" == "firefox") || ("$1" == "firefox/") ]]; then- # we always apply our patches atop of beta since it seems to get better- # reliability guarantees.- BASE_BRANCH="origin/beta"FRIENDLY_CHECKOUT_PATH="//browser_patches/firefox/checkout";CHECKOUT_PATH="$PWD/firefox/checkout"EXPORT_PATH="$PWD/firefox/"+ source "./firefox/UPSTREAM_CONFIG.sh"elif [[ ("$1" == "webkit") || ("$1" == "webkit/") ]]; then- # webkit has only a master branch.- BASE_BRANCH="origin/master"FRIENDLY_CHECKOUT_PATH="//browser_patches/webkit/checkout";CHECKOUT_PATH="$PWD/webkit/checkout"EXPORT_PATH="$PWD/webkit/"+ source "./webkit/UPSTREAM_CONFIG.sh"elseecho ERROR: unknown browser to export - "$1"exit 1@@ -72,6 +72,17 @@ fi# Switch to git repository.cd $CHECKOUT_PATH+# Setting up |$REMOTE_BROWSER_UPSTREAM| remote and fetch the $BASE_BRANCH+if git remote get-url $REMOTE_BROWSER_UPSTREAM >/dev/null; then+ if ! [[ $(git remote get-url $REMOTE_BROWSER_UPSTREAM) == "$REMOTE_URL" ]]; then+ echo "ERROR: remote $REMOTE_BROWSER_UPSTREAM is not pointng to '$REMOTE_URL'! run `prepare_checkout.sh` first"+ exit 1+ fi+else+ echo "ERROR: checkout does not have $REMOTE_BROWSER_UPSTREAM; run `prepare_checkout.sh` first"+ exit 1+fi+# Check if git repo is dirty.if [[ -n $(git status -s) ]]; thenecho "ERROR: $FRIENDLY_CHECKOUT_PATH has dirty GIT state - aborting export."@@ -81,28 +92,29 @@ elsefiCURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)-MERGE_BASE=$(git merge-base $BASE_BRANCH $CURRENT_BRANCH)+BASE_REVISION=$(git merge-base $REMOTE_BROWSER_UPSTREAM/$BASE_BRANCH $CURRENT_BRANCH)echo "=============================================================="echo " Repository: $FRIENDLY_CHECKOUT_PATH"-echo " Changes between branches: $BASE_BRANCH..$CURRENT_BRANCH"-echo " BASE_REVISION: $MERGE_BASE"+echo " Changes between branches: $REMOTE_BROWSER_UPSTREAM/$BASE_BRANCH..$CURRENT_BRANCH"+echo " BASE_REVISION: $BASE_REIVSION"echo-read -p "Export? Y/n " -n 1 -r-echo-# if it's not fine to reset branch - bail out.-if ! [[ $REPLY =~ ^[Yy]$ ]]; then- echo "Exiting."- exit 1-fi-echo $MERGE_BASE > $EXPORT_PATH/BASE_REVISION-git checkout -b tmpsquash_export_script $MERGE_BASE+echo $BASE_REIVSION > $EXPORT_PATH/BASE_REVISION+git checkout -b tmpsquash_export_script $BASE_REIVSIONgit merge --squash $CURRENT_BRANCH-git commit -am "chore: bootstrap"+if ! git commit -am "chore: bootstrap"; then+ echo "No changes!"+ git checkout $CURRENT_BRANCH+ git branch -D tmpsquash_export_script+ exit 0+fiPATCH_NAME=$(git format-patch -1 HEAD)mv $PATCH_NAME $EXPORT_PATH/patches/git checkout $CURRENT_BRANCHgit branch -D tmpsquash_export_script+echo "REMOTE_URL=\"$REMOTE_URL\"+BASE_BRANCH=\"$BASE_BRANCH\"+BASE_REVISION=\"$BASE_REIVSION\"" > $EXPORT_PATH/UPSTREAM_CONFIG.sh# Increment BUILD_NUMBERBUILD_NUMBER=$(cat $EXPORT_PATH/BUILD_NUMBER)diff --git a/browser_patches/firefox/BASE_REVISION b/browser_patches/firefox/BASE_REVISIONdeleted file mode 100644index 37eb8e8658..0000000000--- a/browser_patches/firefox/BASE_REVISION+++ /dev/null@@ -1 +0,0 @@-46ca28eadfe840021e2ea496fa6b26f924fa135bdiff --git a/browser_patches/firefox/README.md b/browser_patches/firefox/README.mddeleted file mode 100644index e3368007ed..0000000000--- a/browser_patches/firefox/README.md+++ /dev/null@@ -1,22 +0,0 @@-# Building Juggler (Linux & Mac)--1. Run `./do_checkout.sh` script. This will create a "checkout" folder with gecko-dev mirror from-GitHub and apply the PlayWright-specific patches.-2. Run `./do_build.sh` script to compile browser. Note: you'll need to follow [build instructions](https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Build_Instructions) to setup host environment first.--# Updating `FIREFOX_REVISION` and `//patches/*`--The `./export.sh` script will export a patch that describes all the differences between the current branch in `./checkout`-and the `beta` branch in `./checkout`.--# Uploading to Azure CDN--Uploading requires having both `AZ_ACCOUNT_KEY` and `AZ_ACCOUNT_NAME` env variables to be defined.--The following sequence of steps will checkout, build and upload build to Azure CDN on both Linux and Mac:--```sh-$ ./do_checkout.sh-$ ./build.sh-$ ./upload.sh-```diff --git a/browser_patches/firefox/UPSTREAM_CONFIG.sh b/browser_patches/firefox/UPSTREAM_CONFIG.shnew file mode 100644index 0000000000..21d9846f16--- /dev/null+++ b/browser_patches/firefox/UPSTREAM_CONFIG.sh@@ -0,0 +1,3 @@+REMOTE_URL="https://github.com/mozilla/gecko-dev"+BASE_BRANCH="beta"+BASE_REVISION="46ca28eadfe840021e2ea496fa6b26f924fa135b"diff --git a/browser_patches/firefox/build.sh b/browser_patches/firefox/build.shindex eadd946aff..07ee3d540f 100755--- a/browser_patches/firefox/build.sh+++ b/browser_patches/firefox/build.sh@@ -6,11 +6,13 @@ trap "cd $(pwd -P)" EXITcd "$(dirname $0)"cd "checkout"-if ! [[ $(git rev-parse --abbrev-ref HEAD) == "pwdev" ]]; then- echo "ERROR: Cannot build any branch other than PWDEV"+BUILD_BRANCH="playwright-build"++if ! [[ $(git rev-parse --abbrev-ref HEAD) == "$BUILD_BRANCH" ]]; then+ echo "ERROR: Cannot build any branch other than $BUILD_BRANCH"exit 1;else- echo "-- checking git branch is PWDEV - OK"+ echo "-- checking git branch is $BUILD_BRANCH - OK"fiif [[ "$(uname)" == "Darwin" ]]; thendiff --git a/browser_patches/prepare_checkout.sh b/browser_patches/prepare_checkout.shnew file mode 100755index 0000000000..542b39e44e--- /dev/null+++ b/browser_patches/prepare_checkout.sh@@ -0,0 +1,108 @@+#!/bin/bash+set -e+set +x++trap "cd $(pwd -P)" EXIT+cd "$(dirname "$0")"++REMOTE_BROWSER_UPSTREAM="browser_upstream"+BUILD_BRANCH="playwright-build"++if [[ ($1 == '--help') || ($1 == '-h') ]]; then+ echo "usage: $(basename $0) [firefox|webkit] [custom_checkout_path]"+ echo+ echo "Prepares browser checkout. The checkout is a GIT repository that:"+ echo "- has a '$REMOTE_BROWSER_UPSTREAM' remote pointing to a REMOTE_URL from UPSTREAM_CONFIG.sh"+ echo "- has a '$BUILD_BRANCH' branch that is BASE_REVISION with all the patches applied."+ echo+ echo "You can optionally specify custom_checkout_path if you want to use some other browser checkout"+ echo+ exit 0+fi++if [[ $# == 0 ]]; then+ echo "missing browser: 'firefox' or 'webkit'"+ echo "try './$(basename $0) --help' for more information"+ exit 1+fi++# FRIENDLY_CHECKOUT_PATH is used only for logging.+FRIENDLY_CHECKOUT_PATH="";+CHECKOUT_PATH=""+if [[ ("$1" == "firefox") || ("$1" == "firefox/") ]]; then+ FRIENDLY_CHECKOUT_PATH="//browser_patches/firefox/checkout";+ CHECKOUT_PATH="$PWD/firefox/checkout"+ source "./firefox/UPSTREAM_CONFIG.sh"+elif [[ ("$1" == "webkit") || ("$1" == "webkit/") ]]; then+ FRIENDLY_CHECKOUT_PATH="//browser_patches/webkit/checkout";+ CHECKOUT_PATH="$PWD/webkit/checkout"+ source "./webkit/UPSTREAM_CONFIG.sh"+else+ echo ERROR: unknown browser - "$1"+ exit 1+fi++# we will use this just for beauty.+if [[ $# == 2 ]]; then+ echo "WARNING: using custom checkout path $CHECKOUT_PATH"+ CHECKOUT_PATH=$2+ FRIENDLY_CHECKOUT_PATH="<custom_checkout>"+fi++# if there's no checkout folder - checkout one.+if ! [[ -d $CHECKOUT_PATH ]]; then+ echo "-- $FRIENDLY_CHECKOUT_PATH is missing - checking out.."+ git clone --single-branch --branch $BASE_BRANCH $REMOTE_URL $CHECKOUT_PATH+else+ echo "-- checking $FRIENDLY_CHECKOUT_PATH folder - OK"+fi++# if folder exists but not a git repository - bail out.+if ! [[ -d $CHECKOUT_PATH/.git ]]; then+ echo "ERROR: $FRIENDLY_CHECKOUT_PATH is not a git repository! Remove it and re-run the script."+ exit 1+else+ echo "-- checking $FRIENDLY_CHECKOUT_PATH is a git repo - OK"+fi++# ============== SETTING UP GIT REPOSITORY ==============+cd $CHECKOUT_PATH++# Bail out if git repo is dirty.+if [[ -n $(git status -s) ]]; then+ echo "ERROR: $FRIENDLY_CHECKOUT_PATH has dirty GIT state - commit everything and re-run the script."+ exit 1+fi++# Setting up |$REMOTE_BROWSER_UPSTREAM| remote and fetch the $BASE_BRANCH+if git remote get-url $REMOTE_BROWSER_UPSTREAM >/dev/null; then+ echo "-- setting |$REMOTE_BROWSER_UPSTREAM| remote url to $REMOTE_URL"+ git remote set-url $REMOTE_BROWSER_UPSTREAM $REMOTE_URL+else+ echo "-- adding |$REMOTE_BROWSER_UPSTREAM| remote to $REMOTE_URL"+ git remote add $REMOTE_BROWSER_UPSTREAM $REMOTE_URL+fi+git fetch $REMOTE_BROWSER_UPSTREAM $BASE_BRANCH++# Check if we have the $BASE_REVISION commit in GIT+if ! git cat-file -e $BASE_REVISION^{commit}; then+ echo "ERROR: $FRIENDLY_CHECKOUT_PATH/ does not include the BASE_REVISION (@$BASE_REVISION). Wrong revision number?"+ exit 1+else+ echo "-- checking $FRIENDLY_CHECKOUT_PATH repo has BASE_REVISION (@$BASE_REVISION) commit - OK"+fi++# Check out the $BASE_REVISION+git checkout $BASE_REVISION++# Create a playwright-build branch and apply all the patches to it.+if git show-ref --verify --quiet refs/heads/playwright-build; then+ git branch -D playwright-build+fi+git checkout -b playwright-build+echo "-- applying all patches"+git am ../patches/*++echo+echo+echo "DONE. Browser is ready to be built."diff --git a/browser_patches/tools/check_cdn.sh b/browser_patches/tools/check_cdn.shindex e50c4ff404..223c3aab7f 100755--- a/browser_patches/tools/check_cdn.sh+++ b/browser_patches/tools/check_cdn.sh@@ -17,17 +17,17 @@ ARCHIVES=("$HOST/firefox/%s/firefox-linux.zip""$HOST/firefox/%s/firefox-win.zip""$HOST/webkit/%s/minibrowser-linux.zip"- "$HOST/webkit/%s/minibrowser-mac10.14.zip"- "$HOST/webkit/%s/minibrowser-mac10.15.zip"+ "$HOST/webkit/%s/minibrowser-mac-10.14.zip"+ "$HOST/webkit/%s/minibrowser-mac-10.15.zip")ALIASES=("FF-MAC""FF-LINUX""FF-WIN"+ "WK-LINUX""WK-MAC-10.14""WK-MAC-10.15"- "WK-LINUX")COLUMN="%-15s"diff --git a/browser_patches/webkit/BASE_REVISION b/browser_patches/webkit/BASE_REVISIONdeleted file mode 100644index 7b297e2fcc..0000000000--- a/browser_patches/webkit/BASE_REVISION+++ /dev/null@@ -1 +0,0 @@-734d4fc1b6da79b72e234e4a50435f25dd90d769diff --git a/browser_patches/webkit/UPSTREAM_CONFIG.sh b/browser_patches/webkit/UPSTREAM_CONFIG.shnew file mode 100644index 0000000000..2555176190--- /dev/null+++ b/browser_patches/webkit/UPSTREAM_CONFIG.sh@@ -0,0 +1,3 @@+REMOTE_URL="https://github.com/webkit/webkit"+BASE_BRANCH="master"+BASE_REVISION="734d4fc1b6da79b72e234e4a50435f25dd90d769"diff --git a/browser_patches/webkit/build.sh b/browser_patches/webkit/build.shindex 2315846292..571d8da1fa 100755--- a/browser_patches/webkit/build.sh+++ b/browser_patches/webkit/build.sh@@ -6,11 +6,13 @@ trap "cd $(pwd -P)" EXITcd "$(dirname $0)"cd "checkout"-if ! [[ $(git rev-parse --abbrev-ref HEAD) == "pwdev" ]]; then- echo "ERROR: Cannot build any branch other than PWDEV"+BUILD_BRANCH="playwright-build"++if ! [[ $(git rev-parse --abbrev-ref HEAD) == "$BUILD_BRANCH" ]]; then+ echo "ERROR: Cannot build any branch other than $BUILD_BRANCH"exit 1;else- echo "-- checking git branch is PWDEV - OK"+ echo "-- checking git branch is $BUILD_BRANCH - OK"fiif [[ "$(uname)" == "Darwin" ]]; then