From cf55fe660c8dfe41c6038e8ad857de0f519e4616 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Fri, 22 Nov 2019 20:25:36 -0800 Subject: [PATCH] devops: give all 4 buildbots designated bash script This makes it possible for every buildbot to build browsers one-by-one, instead of altogether. --- browser_patches/{ => buildbots}/bots.md | 2 +- .../buildbot-linux.sh} | 28 ++++------- .../buildbots/buildbot-mac-10.14.sh | 49 +++++++++++++++++++ .../buildbots/buildbot-mac-10.15.sh | 46 +++++++++++++++++ .../buildbot-windows.sh} | 14 +----- browser_patches/buildbots/crontab | 1 + browser_patches/tools/crontab | 2 - 7 files changed, 108 insertions(+), 34 deletions(-) rename browser_patches/{ => buildbots}/bots.md (96%) rename browser_patches/{tools/cronjob.sh => buildbots/buildbot-linux.sh} (63%) create mode 100755 browser_patches/buildbots/buildbot-mac-10.14.sh create mode 100755 browser_patches/buildbots/buildbot-mac-10.15.sh rename browser_patches/{tools/poll_build.sh => buildbots/buildbot-windows.sh} (74%) create mode 100644 browser_patches/buildbots/crontab delete mode 100644 browser_patches/tools/crontab diff --git a/browser_patches/bots.md b/browser_patches/buildbots/bots.md similarity index 96% rename from browser_patches/bots.md rename to browser_patches/buildbots/bots.md index 7ea049536a..2b0eea2f05 100644 --- a/browser_patches/bots.md +++ b/browser_patches/buildbots/bots.md @@ -59,5 +59,5 @@ Run `c:\mozilla-build\start-shell.bat` and checkout PlayWright repo to `/c/playw ## Running Build Loop 1. Launch `c:\mozilla-build/start-shell.bat` -2. Run `/c/playwright/browser_patches/tools/poll_build.sh` +2. Run `/c/playwright/browser_patches/buildbots/buildbot-windows.sh` 3. Disable "QuickEdit" terminal mode to avoid [terminal freezing and postponing builds](https://stackoverflow.com/questions/33883530/why-is-my-command-prompt-freezing-on-windows-10) diff --git a/browser_patches/tools/cronjob.sh b/browser_patches/buildbots/buildbot-linux.sh similarity index 63% rename from browser_patches/tools/cronjob.sh rename to browser_patches/buildbots/buildbot-linux.sh index 743cd91c86..8c26177774 100755 --- a/browser_patches/tools/cronjob.sh +++ b/browser_patches/buildbots/buildbot-linux.sh @@ -7,15 +7,11 @@ if [[ ($1 == '--help') || ($1 == '-h') ]]; then echo echo "Pull from upstream & run checkout_build_archive_upload.sh" echo "in a safe way so that multiple instances of the script cannot be run" + echo + echo "This script is designed to be run as a cronjob" exit 0 fi -if [[ $# == 0 ]]; then - echo "missing browser: 'firefox' or 'webkit'" - echo "try './$(basename $0) --help' for more information" - exit 1 -fi - if [[ (-z $AZ_ACCOUNT_KEY) || (-z $AZ_ACCOUNT_NAME) ]]; then echo "ERROR: Either \$AZ_ACCOUNT_KEY or \$AZ_ACCOUNT_NAME environment variable is missing." echo " 'Azure Account Name' and 'Azure Account Key' secrets that are required" @@ -28,22 +24,13 @@ if ! command -v az >/dev/null; then exit 1 fi -BROWSER_NAME="" -if [[ ("$1" == "firefox") || ("$1" == "firefox/") ]]; then - BROWSER_NAME="firefox" -elif [[ ("$1" == "webkit") || ("$1" == "webkit/") ]]; then - BROWSER_NAME="webkit" -else - echo ERROR: unknown browser - "$1" - exit 1 -fi - # Setup a LOCKDIR so that we don't run the same script multiple times. -LOCKDIR="/tmp/playwright__$(basename $0)-$BROWSER_NAME.lock" +LOCKDIR="/tmp/$(basename $0).lock" if [[ -d ${LOCKDIR} ]]; then echo "Already running (lockdir $LOCKDIR exists. Remove it manually if running)" exit 0 fi + mkdir -p $LOCKDIR # make sure the lockfile is removed when we exit and then claim it trap "rm -rf ${LOCKDIR}; cd $(pwd -P); exit" INT TERM EXIT @@ -51,9 +38,12 @@ cd "$(dirname "$0")" # 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." + echo "ERROR: dirty GIT state - commit everything and re-run the script." exit 1 fi git pull origin master -../checkout_build_archive_upload.sh $BROWSER_NAME >/tmp/checkout_build_archive_upload--$BROWSER_NAME.log +../checkout_build_archive_upload.sh firefox >/tmp/$(basename $0)-firefox-log.log + +git pull origin master +../checkout_build_archive_upload.sh webkit >/tmp/$(basename $0)-webkit-log.log diff --git a/browser_patches/buildbots/buildbot-mac-10.14.sh b/browser_patches/buildbots/buildbot-mac-10.14.sh new file mode 100755 index 0000000000..8c26177774 --- /dev/null +++ b/browser_patches/buildbots/buildbot-mac-10.14.sh @@ -0,0 +1,49 @@ +#!/bin/bash +set -e +set +x + +if [[ ($1 == '--help') || ($1 == '-h') ]]; then + echo "usage: $(basename $0) [firefox|webkit]" + echo + echo "Pull from upstream & run checkout_build_archive_upload.sh" + echo "in a safe way so that multiple instances of the script cannot be run" + echo + echo "This script is designed to be run as a cronjob" + exit 0 +fi + +if [[ (-z $AZ_ACCOUNT_KEY) || (-z $AZ_ACCOUNT_NAME) ]]; then + echo "ERROR: Either \$AZ_ACCOUNT_KEY or \$AZ_ACCOUNT_NAME environment variable is missing." + echo " 'Azure Account Name' and 'Azure Account Key' secrets that are required" + echo " to upload builds ot Azure CDN." + exit 1 +fi + +if ! command -v az >/dev/null; then + echo "ERROR: az is not found in PATH" + exit 1 +fi + +# Setup a LOCKDIR so that we don't run the same script multiple times. +LOCKDIR="/tmp/$(basename $0).lock" +if [[ -d ${LOCKDIR} ]]; then + echo "Already running (lockdir $LOCKDIR exists. Remove it manually if running)" + exit 0 +fi + +mkdir -p $LOCKDIR +# make sure the lockfile is removed when we exit and then claim it +trap "rm -rf ${LOCKDIR}; cd $(pwd -P); exit" INT TERM EXIT +cd "$(dirname "$0")" + +# Check if git repo is dirty. +if [[ -n $(git status -s) ]]; then + echo "ERROR: dirty GIT state - commit everything and re-run the script." + exit 1 +fi + +git pull origin master +../checkout_build_archive_upload.sh firefox >/tmp/$(basename $0)-firefox-log.log + +git pull origin master +../checkout_build_archive_upload.sh webkit >/tmp/$(basename $0)-webkit-log.log diff --git a/browser_patches/buildbots/buildbot-mac-10.15.sh b/browser_patches/buildbots/buildbot-mac-10.15.sh new file mode 100755 index 0000000000..5ab683752f --- /dev/null +++ b/browser_patches/buildbots/buildbot-mac-10.15.sh @@ -0,0 +1,46 @@ +#!/bin/bash +set -e +set +x + +if [[ ($1 == '--help') || ($1 == '-h') ]]; then + echo "usage: $(basename $0) [firefox|webkit]" + echo + echo "Pull from upstream & run checkout_build_archive_upload.sh" + echo "in a safe way so that multiple instances of the script cannot be run" + echo + echo "This script is designed to be run as a cronjob" + exit 0 +fi + +if [[ (-z $AZ_ACCOUNT_KEY) || (-z $AZ_ACCOUNT_NAME) ]]; then + echo "ERROR: Either \$AZ_ACCOUNT_KEY or \$AZ_ACCOUNT_NAME environment variable is missing." + echo " 'Azure Account Name' and 'Azure Account Key' secrets that are required" + echo " to upload builds ot Azure CDN." + exit 1 +fi + +if ! command -v az >/dev/null; then + echo "ERROR: az is not found in PATH" + exit 1 +fi + +# Setup a LOCKDIR so that we don't run the same script multiple times. +LOCKDIR="/tmp/$(basename $0).lock" +if [[ -d ${LOCKDIR} ]]; then + echo "Already running (lockdir $LOCKDIR exists. Remove it manually if running)" + exit 0 +fi + +mkdir -p $LOCKDIR +# make sure the lockfile is removed when we exit and then claim it +trap "rm -rf ${LOCKDIR}; cd $(pwd -P); exit" INT TERM EXIT +cd "$(dirname "$0")" + +# Check if git repo is dirty. +if [[ -n $(git status -s) ]]; then + echo "ERROR: dirty GIT state - commit everything and re-run the script." + exit 1 +fi + +git pull origin master +../checkout_build_archive_upload.sh webkit >/tmp/$(basename $0)-webkit-log.log diff --git a/browser_patches/tools/poll_build.sh b/browser_patches/buildbots/buildbot-windows.sh similarity index 74% rename from browser_patches/tools/poll_build.sh rename to browser_patches/buildbots/buildbot-windows.sh index 3b8ab688c0..50cbc7b59c 100755 --- a/browser_patches/tools/poll_build.sh +++ b/browser_patches/buildbots/buildbot-windows.sh @@ -26,23 +26,13 @@ if ! command -v az >/dev/null; then exit 1 fi -BROWSER_NAME="" -if [[ ("$1" == "firefox") || ("$1" == "firefox/") ]]; then - BROWSER_NAME="firefox" -elif [[ ("$1" == "webkit") || ("$1" == "webkit/") ]]; then - BROWSER_NAME="webkit" -else - echo ERROR: unknown browser - "$1" - exit 1 -fi - # make sure the lockfile is removed when we exit and then claim it trap "cd $(pwd -P);" EXIT cd "$(dirname "$0")" # 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." + echo "ERROR: dirty GIT state - commit everything and re-run the script." exit 1 fi @@ -51,7 +41,7 @@ while true; do iteration=$(( iteration + 1 )) echo "== ITERATION ${iteration} ==" git pull origin master - ../checkout_build_archive_upload.sh $BROWSER_NAME + ../checkout_build_archive_upload.sh firefox echo "------ Sleeping for 300 seconds before next turn... ------" sleep 300 done; diff --git a/browser_patches/buildbots/crontab b/browser_patches/buildbots/crontab new file mode 100644 index 0000000000..13d5351650 --- /dev/null +++ b/browser_patches/buildbots/crontab @@ -0,0 +1 @@ +*/5 * * * * . $HOME/.profile; $HOME/prog/cron/playwright/browser_patches/buildbots/buildbot-linux.sh >/tmp/buildbot-linux-cronjob.log diff --git a/browser_patches/tools/crontab b/browser_patches/tools/crontab deleted file mode 100644 index 7851e2d65f..0000000000 --- a/browser_patches/tools/crontab +++ /dev/null @@ -1,2 +0,0 @@ -*/1 * * * * . $HOME/.profile; $HOME/prog/cron/playwright/browser_patches/tools/cronjob.sh webkit &>/tmp/playwright-cronjob-building-log-webkit.txt -*/1 * * * * . $HOME/.profile; $HOME/prog/cron/playwright/browser_patches/tools/cronjob.sh firefox &>/tmp/playwright-cronjob-building-log-firefox.txt