Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

devops: revamp archive.sh scripts to accept a target .zip name

Andrey Lushnikov4f3834dd6914
diff --git a/browser_patches/firefox/archive.sh b/browser_patches/firefox/archive.sh
index 1d5e445c47..278ba9fd8c 100755
--- a/browser_patches/firefox/archive.sh
+++ b/browser_patches/firefox/archive.sh
@@ -1,48 +1,59 @@
#!/bin/bash
+set -e
+set +x
if [[ ("$1" == "-h") || ("$1" == "--help") ]]; then
- echo "usage: $(basename $0)"
+ echo "usage: $(basename $0) [output-absolute-path]"
echo
echo "Generate distributable .zip archive from ./checkout folder that was previously built."
echo
exit 0
fi
-set -e
-set -x
-
-createZIPForLinuxOrMac() {
- local zipname=$1
- local OBJ_FOLDER=$(ls -1 | grep obj-)
- if [[ $OBJ_FOLDER == "" ]]; then
- echo "ERROR: cannot find obj-* folder in the checkout/. Did you build?"
- exit 1;
- fi
- if ! [[ -d $OBJ_FOLDER/dist/firefox ]]; then
- echo "ERROR: cannot find $OBJ_FOLDER/dist/firefox folder in the checkout/. Did you build?"
- exit 1;
- fi
- # Copy the libstdc++ version we linked against.
- # TODO(aslushnikov): this won't be needed with official builds.
- if [[ "$(uname)" == "Linux" ]]; then
- cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6 $OBJ_FOLDER/dist/firefox/libstdc++.so.6
- fi
+if [[ $# != 1 ]]; then
+ echo "error: missing zip output path"
+ echo "try '$(basename $0) --help' for details"
+ exit 1
+fi
- # tar resulting directory and cleanup TMP.
- cd $OBJ_FOLDER/dist
- zip -r ../../../$zipname firefox
- cd -
-}
+ZIP_PATH=$1
+if [[ $ZIP_PATH != /* ]]; then
+ echo "ERROR: path $ZIP_PATH is not absolute"
+ exit 1
+fi
+if [[ $ZIP_PATH != *.zip ]]; then
+ echo "ERROR: path $ZIP_PATH must have .zip extension"
+ exit 1
+fi
+if [[ -f $ZIP_PATH ]]; then
+ echo "ERROR: path $ZIP_PATH exists; can't do anything."
+ exit 1
+fi
+if ! [[ -d $(dirname $ZIP_PATH) ]]; then
+ echo "ERROR: folder for path $($ZIP_PATH) does not exist."
+ exit 1
+fi
trap "cd $(pwd -P)" EXIT
cd "$(dirname $0)"
cd checkout
-if [[ "$(uname)" == "Darwin" ]]; then
- createZIPForLinuxOrMac "firefox-mac.zip"
-elif [[ "$(uname)" == "Linux" ]]; then
- createZIPForLinuxOrMac "firefox-linux.zip"
-else
- echo "ERROR: cannot upload on this platform!" 1>&2
+OBJ_FOLDER=$(ls -1 | grep obj-)
+if [[ $OBJ_FOLDER == "" ]]; then
+ echo "ERROR: cannot find obj-* folder in the checkout/. Did you build?"
+ exit 1;
+fi
+if ! [[ -d $OBJ_FOLDER/dist/firefox ]]; then
+ echo "ERROR: cannot find $OBJ_FOLDER/dist/firefox folder in the checkout/. Did you build?"
exit 1;
fi
+
+# Copy the libstdc++ version we linked against.
+# TODO(aslushnikov): this won't be needed with official builds.
+if [[ "$(uname)" == "Linux" ]]; then
+ cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6 $OBJ_FOLDER/dist/firefox/libstdc++.so.6
+fi
+
+# tar resulting directory and cleanup TMP.
+cd $OBJ_FOLDER/dist
+zip -r $ZIP_PATH firefox
diff --git a/browser_patches/upload.sh b/browser_patches/upload.sh
index 8c70d92f10..e9c4b40f82 100755
--- a/browser_patches/upload.sh
+++ b/browser_patches/upload.sh
@@ -6,21 +6,15 @@ trap "cd $(pwd -P)" EXIT
cd "$(dirname "$0")"
if [[ ($1 == '--help') || ($1 == '-h') ]]; then
- echo "usage: $(basename $0) [firefox|webkit]"
+ echo "usage: $(basename $0) [firefox|webkit] [zip-path]"
echo
- echo "Archive and upload a browser"
+ echo "Upload .zip as a browser build."
echo
echo "NOTE: \$AZ_ACCOUNT_KEY (azure account name) and \$AZ_ACCOUNT_NAME (azure account name)"
echo "env variables are required to upload builds to CDN."
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,36 +22,64 @@ if [[ (-z $AZ_ACCOUNT_KEY) || (-z $AZ_ACCOUNT_NAME) ]]; then
exit 1
fi
-ARCHIVE_SCRIPT=""
+if [[ $# < 1 ]]; then
+ echo "missing browser: 'firefox' or 'webkit'"
+ echo "try '$(basename $0) --help' for more information"
+ exit 1
+fi
BROWSER_NAME=""
BUILD_NUMBER=""
+BLOB_NAME=""
if [[ ("$1" == "firefox") || ("$1" == "firefox/") ]]; then
# we always apply our patches atop of beta since it seems to get better
# reliability guarantees.
- ARCHIVE_FOLDER="$PWD/firefox"
BUILD_NUMBER=$(cat "$PWD/firefox/BUILD_NUMBER")
- ARCHIVE_SCRIPT="$PWD/firefox/archive.sh"
BROWSER_NAME="firefox"
+ if [[ "$(uname)" == "Darwin" ]]; then
+ BLOB_NAME="firefox-mac.zip"
+ elif [[ "$(uname)" == "Linux" ]]; then
+ BLOB_NAME="firefox-linux.zip"
+ else
+ echo "ERROR: unzupported platform - $(uname)"
+ exit 1
+ fi
elif [[ ("$1" == "webkit") || ("$1" == "webkit/") ]]; then
- ARCHIVE_FOLDER="$PWD/webkit"
BUILD_NUMBER=$(cat "$PWD/webkit/BUILD_NUMBER")
- ARCHIVE_SCRIPT="$PWD/webkit/archive.sh"
BROWSER_NAME="webkit"
+ if [[ "$(uname)" == "Darwin" ]]; then
+ MAC_MAJOR_MINOR_VERSION=$(sw_vers -productVersion | grep -o '^\d\+.\d\+')
+ BLOB_NAME="minibrowser-mac-$MAC_MAJOR_MINOR_VERSION.zip"
+ elif [[ "$(uname)" == "Linux" ]]; then
+ BLOB_NAME="minibrowser-linux.zip"
+ else
+ echo "ERROR: unzupported platform - $(uname)"
+ exit 1
+ fi
else
echo ERROR: unknown browser to export - "$1"
exit 1
fi
-if ! [[ -z $(ls $ARCHIVE_FOLDER | grep '.zip') ]]; then
- echo ERROR: .zip file already exists in $ARCHIVE_FOLDER!
- echo Remove manually all zip files and re-run the script.
+if [[ $# < 2 ]]; then
+ echo "missing path to zip archive to upload"
+ echo "try '$(basename $0) --help' for more information"
+ exit 1
+fi
+ZIP_PATH=$2
+if ! [[ -f $ZIP_PATH ]]; then
+ echo "ERROR: $ZIP_PATH does not exist"
exit 1
fi
+if ! [[ $ZIP_PATH == *.zip ]]; then
+ echo "ERROR: $ZIP_PATH is not a zip archive (must have a .zip extension)"
+ exit 1
+fi
+
+BLOB_PATH="$BROWSER_NAME/$BUILD_NUMBER/$BLOB_NAME"
+az storage blob upload -c builds --account-key $AZ_ACCOUNT_KEY --account-name $AZ_ACCOUNT_NAME -f $ZIP_PATH -n "$BLOB_PATH"
+
+echo "UPLOAD SUCCESSFUL!"
+echo "-- SRC: $ZIP_PATH"
+echo "-- SIZE: $(du -h "$ZIP_PATH" | awk '{print $1}')"
+echo "-- DST: $BLOB_PATH"
-$ARCHIVE_SCRIPT
-ZIP_NAME=$(ls $ARCHIVE_FOLDER | grep '.zip')
-ZIP_PATH=$ARCHIVE_FOLDER/$ZIP_NAME
-BLOB_NAME="$BROWSER_NAME/$BUILD_NUMBER/$ZIP_NAME"
-az storage blob upload -c builds --account-key $AZ_ACCOUNT_KEY --account-name $AZ_ACCOUNT_NAME -f $ZIP_PATH -n "$BLOB_NAME"
-echo "Uploaded $(du -h "$ZIP_PATH" | awk '{print $1}') as $BLOB_NAME"
-rm $ZIP_PATH
diff --git a/browser_patches/webkit/archive.sh b/browser_patches/webkit/archive.sh
index 14104deb89..94d2bd0f84 100755
--- a/browser_patches/webkit/archive.sh
+++ b/browser_patches/webkit/archive.sh
@@ -1,19 +1,43 @@
#!/bin/bash
+set -e
+set +x
if [[ ("$1" == "-h") || ("$1" == "--help") ]]; then
- echo "usage: $(basename $0)"
+ echo "usage: $(basename $0) [output-absolute-path]"
echo
echo "Generate distributable .zip archive from ./checkout folder that was previously built."
echo
exit 0
fi
-set -e
-set -x
+if [[ $# != 1 ]]; then
+ echo "error: missing zip output path"
+ echo "try '$(basename $0) --help' for details"
+ exit 1
+fi
+
+ZIP_PATH=$1
+if [[ $ZIP_PATH != /* ]]; then
+ echo "ERROR: path $ZIP_PATH is not absolute"
+ exit 1
+fi
+if [[ $ZIP_PATH != *.zip ]]; then
+ echo "ERROR: path $ZIP_PATH must have .zip extension"
+ exit 1
+fi
+if [[ -f $ZIP_PATH ]]; then
+ echo "ERROR: path $ZIP_PATH exists; can't do anything."
+ exit 1
+fi
+if ! [[ -d $(dirname $ZIP_PATH) ]]; then
+ echo "ERROR: folder for path $($ZIP_PATH) does not exist."
+ exit 1
+fi
main() {
cd checkout
+ set -x
if [[ "$(uname)" == "Darwin" ]]; then
createZipForMac
elif [[ "$(uname)" == "Linux" ]]; then
@@ -42,8 +66,7 @@ createZipForLinux() {
rm $tmpdir/libgdk_pixbuf*
# tar resulting directory and cleanup TMP.
- local zipname="minibrowser-linux.zip"
- zip -jr ../$zipname $tmpdir
+ zip -jr $ZIP_PATH $tmpdir
rm -rf $tmpdir
}
@@ -69,9 +92,7 @@ createZipForMac() {
node ../concat_protocol.js > $tmpdir/protocol.json
# zip resulting directory and cleanup TMP.
- local MAC_MAJOR_MINOR_VERSION=$(sw_vers -productVersion | grep -o '^\d\+.\d\+')
- local zipname="minibrowser-mac-$MAC_MAJOR_MINOR_VERSION.zip"
- ditto -c -k $tmpdir ../$zipname
+ ditto -c -k $tmpdir $ZIP_PATH
rm -rf $tmpdir
}