Skip to content

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

devops: introduce goma infrastructure for Chromium builds (#5377)

Andrey Lushnikovad557dc6da3d
diff --git a/browser_patches/chromium/.gitignore b/browser_patches/chromium/.gitignore
index 23b33df7f1..2658404cd7 100644
--- a/browser_patches/chromium/.gitignore
+++ b/browser_patches/chromium/.gitignore
@@ -1,2 +1,3 @@
/output
/depot_tools
+/electron-build-tools
diff --git a/browser_patches/chromium/build.sh b/browser_patches/chromium/build.sh
index fdc43569e8..306d668f1a 100755
--- a/browser_patches/chromium/build.sh
+++ b/browser_patches/chromium/build.sh
@@ -6,7 +6,7 @@ trap "cd $(pwd -P)" EXIT
cd "$(dirname $0)"
USAGE=$(cat<<EOF
- usage: $(basename $0) [--mirror|--mirror-linux|--mirror-win32|--mirror-win64|--mirror-mac|--compile-mac-arm64]
+ usage: $(basename $0) [--mirror|--mirror-linux|--mirror-win32|--mirror-win64|--mirror-mac|--compile-mac-arm64|--compile-linux|--compile-win32|--compile-win64|--compile-mac]
Either compiles chromium or mirrors it from Chromium Continuous Builds CDN.
EOF
@@ -121,6 +121,9 @@ compile_chromium() {
"swiftshader"
"v8_context_snapshot.bin"
)
+ else
+ echo "ERROR: unknown command, use --help for details"
+ exit 1
fi
# Get chromium SHA from the build revision.
@@ -163,15 +166,29 @@ EOF
echo 'target_cpu = "x86"' >> ./out/Default/args.gn
fi
+ if [[ ! -z "$USE_GOMA" ]]; then
+ echo 'use_goma = true' >> ./out/Default/args.gn
+ echo "goma_dir = '${SCRIPT_PATH}/electron-build-tools/third_party/goma'" >> ./out/Default/args.gn
+ fi
+
if [[ $1 == "--compile-win"* ]]; then
- /c/Windows/System32/cmd.exe "/c $(cygpath -w ${SCRIPT_PATH}/buildwin.bat)"
+ if [[ -z "$USE_GOMA" ]]; then
+ /c/Windows/System32/cmd.exe "/c $(cygpath -w ${SCRIPT_PATH}/buildwin.bat)"
+ else
+ /c/Windows/System32/cmd.exe "/c $(cygpath -w ${SCRIPT_PATH}/buildwingoma.bat)"
+ fi
else
gn gen out/Default
- autoninja -C out/Default chrome
- fi
-
- if [[ $1 == "--compile-linux" ]]; then
- autoninja -C out/Default chrome_sandbox clear_key_cdm
+ if [[ $1 == "--compile-linux" ]]; then
+ TARGETS="chrome chrome_sandbox clear_key_cdm"
+ else
+ TARGETS="chrome"
+ fi
+ if [[ -z "$USE_GOMA" ]]; then
+ autoninja -C out/Default $TARGETS
+ else
+ ninja -j 200 -C out/Default $TARGETS
+ fi
fi
# Prepare resulting archive.
diff --git a/browser_patches/chromium/buildwingoma.bat b/browser_patches/chromium/buildwingoma.bat
new file mode 100644
index 0000000000..2ae3174fc9
--- /dev/null
+++ b/browser_patches/chromium/buildwingoma.bat
@@ -0,0 +1,2 @@
+CALL gn gen out/Default
+CALL ninja -j 200 -C out/Default chrome
diff --git a/browser_patches/chromium/goma.sh b/browser_patches/chromium/goma.sh
new file mode 100755
index 0000000000..970abb96fc
--- /dev/null
+++ b/browser_patches/chromium/goma.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+set -e
+set +x
+
+trap "cd $(pwd -P)" EXIT
+cd "$(dirname $0)"
+
+if [[ ! -d ./electron-build-tools ]]; then
+ git clone --single-branch --branch msft-goma https://github.com/electron/build-tools/ electron-build-tools
+ cd electron-build-tools
+ npm install
+ mkdir -p third_party
+ ./src/e update-goma msftGoma
+ cd ..
+fi
+
+cd electron-build-tools
+
+if [[ $1 == "--help" ]]; then
+ echo "$(basename $0) [login|start|stop|--help]"
+ exit 0
+elif [[ $1 == "login" ]]; then
+ python ./third_party/goma/goma_auth.py login
+elif [[ $1 == "start" ]]; then
+ if [[ ! -z "$GOMA_LOGIN_COOKIE" ]]; then
+ echo "$GOMA_LOGIN_COOKIE" > "$HOME/.goma_oauth2_config"
+ fi
+ if [[ ! -f "$HOME/.goma_oauth2_config" ]]; then
+ echo "ERROR: goma is not logged in!"
+ echo "run '$(basename $0) login'"
+ exit 1
+ fi
+ python ./third_party/goma/goma_ctl.py ensure_start
+elif [[ $1 == "stop" ]]; then
+ python ./third_party/goma/goma_ctl.py stop
+else
+ echo "ERROR: unknown command - $1"
+ echo "Use --help to list all available commands"
+ exit 1
+fi
+