devops: add cronjobs
This commit is contained in:
parent
57bbd81824
commit
e1f3f5cfed
61
browser_patches/checkout_build_archive_upload.sh
Executable file
61
browser_patches/checkout_build_archive_upload.sh
Executable file
|
|
@ -0,0 +1,61 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
set +x
|
||||||
|
|
||||||
|
if [[ ($1 == '--help') || ($1 == '-h') ]]; then
|
||||||
|
echo "usage: $(basename $0) [firefox|webkit] [-f|--force]"
|
||||||
|
echo
|
||||||
|
echo "Prepares checkout under browser folder, applies patches, builds, archives, and uploades if build is missing."
|
||||||
|
echo "Script will bail out early if the build for the browser version is already present."
|
||||||
|
echo
|
||||||
|
echo "Pass -f to upload anyway."
|
||||||
|
echo
|
||||||
|
echo "NOTE: This script is safe to run in a cronjob - it aquires a lock so that it does not run twice."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $# == 0 ]]; then
|
||||||
|
echo "missing browser: 'firefox' or 'webkit'"
|
||||||
|
echo "try './$(basename $0) --help' for more information"
|
||||||
|
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
|
||||||
|
|
||||||
|
ZIP_PATH="/tmp/archive-$BROWSER_NAME.zip"
|
||||||
|
if [[ -f $ZIP_PATH ]]; then
|
||||||
|
echo "Archive $ZIP_PATH already exists - remove and re-run the script."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# - make sure the lockfile is removed when we exit and then claim it
|
||||||
|
trap "rm -rf ${ZIP_PATH}; cd $(pwd -P); exit" INT TERM EXIT
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
|
# pull from upstream and check if a new build has to be uploaded.
|
||||||
|
if ! [[ ($2 == '-f') || ($2 == '--force') ]]; then
|
||||||
|
if ./upload.sh $BROWSER_NAME --check; then
|
||||||
|
echo "Build is already uploaded - no changes."
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "Build is missing - rebuilding"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Force-rebuilding the build."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "-- preparing checkout"
|
||||||
|
./do_checkout.sh $BROWSER_NAME
|
||||||
|
echo "-- building"
|
||||||
|
./$BROWSER_NAME/build.sh
|
||||||
|
echo "-- archiving to $ZIP_PATH"
|
||||||
|
./$BROWSER_NAME/archive.sh $ZIP_PATH
|
||||||
|
echo "-- uploading"
|
||||||
|
./upload.sh $BROWSER_NAME $ZIP_PATH
|
||||||
46
browser_patches/tools/cronjob.sh
Executable file
46
browser_patches/tools/cronjob.sh
Executable file
|
|
@ -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"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $# == 0 ]]; then
|
||||||
|
echo "missing browser: 'firefox' or 'webkit'"
|
||||||
|
echo "try './$(basename $0) --help' for more information"
|
||||||
|
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"
|
||||||
|
if [[ -d ${LOCKDIR} ]]; then
|
||||||
|
echo "Already running (lockdir $LOCKDIR exists. Remove it manually if running)"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
# 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: $FRIENDLY_CHECKOUT_PATH has dirty GIT state - commit everything and re-run the script."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
git pull origin master
|
||||||
|
../checkout_build_archive_upload.sh $BROWSER_NAME
|
||||||
|
|
@ -6,10 +6,13 @@ trap "cd $(pwd -P)" EXIT
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
if [[ ($1 == '--help') || ($1 == '-h') ]]; then
|
if [[ ($1 == '--help') || ($1 == '-h') ]]; then
|
||||||
echo "usage: $(basename $0) [firefox|webkit] [zip-path]"
|
echo "usage: $(basename $0) [firefox|webkit] [--check] [zip-path]"
|
||||||
echo
|
echo
|
||||||
echo "Upload .zip as a browser build."
|
echo "Upload .zip as a browser build."
|
||||||
echo
|
echo
|
||||||
|
echo "--check pass |--check| as a second parameter instead of a zip-path to check for"
|
||||||
|
echo " the build existing in the CDN"
|
||||||
|
echo
|
||||||
echo "NOTE: \$AZ_ACCOUNT_KEY (azure account name) and \$AZ_ACCOUNT_NAME (azure account name)"
|
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."
|
echo "env variables are required to upload builds to CDN."
|
||||||
exit 0
|
exit 0
|
||||||
|
|
@ -60,6 +63,16 @@ else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
BLOB_PATH="$BROWSER_NAME/$BUILD_NUMBER/$BLOB_NAME"
|
||||||
|
if [[ $2 == '--check' ]]; then
|
||||||
|
EXISTS=$(az storage blob exists -c builds --account-key $AZ_ACCOUNT_KEY --account-name $AZ_ACCOUNT_NAME -n "$BLOB_PATH" --query "exists")
|
||||||
|
if [[ $EXISTS == "true" ]]; then
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $# < 2 ]]; then
|
if [[ $# < 2 ]]; then
|
||||||
echo "missing path to zip archive to upload"
|
echo "missing path to zip archive to upload"
|
||||||
echo "try '$(basename $0) --help' for more information"
|
echo "try '$(basename $0) --help' for more information"
|
||||||
|
|
@ -75,7 +88,6 @@ if ! [[ $ZIP_PATH == *.zip ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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"
|
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 "UPLOAD SUCCESSFUL!"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue