Skip to content

Commit

Permalink
ci: use bazel downloaded saucelabs connect binary
Browse files Browse the repository at this point in the history
The saucelabs connect tunnel utility is now downloaded via bazel as needed.
Previously it was part of the root `package.json` and downloaded whenever
a package install was executed. The utility archive was also not an actual
package which incidentally worked with npm but does not work with newer versions
of yarn.
  • Loading branch information
clydin committed Jun 14, 2024
1 parent 1d3a752 commit 57aa965
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 44 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@
"patch-package": "^7.0.0",
"playwright-core": "^1.41.2",
"prettier": "^3.0.0",
"sauce-connect": "https://saucelabs.com/downloads/sc-4.9.1-linux.tar.gz",
"semver": "^7.3.5",
"tmp": "^0.2.3",
"ts-node": "^10.9.1",
Expand Down
35 changes: 28 additions & 7 deletions tools/saucelabs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,68 @@ sh_binary(
name = "sauce_service_setup",
srcs = ["sauce-service.sh"],
args = ["setup"],
data = ["@npm//sauce-connect"],
data = ["//:sauce_connect"],
env = {
"SAUCE_CONNECT": "$(rootpath //:sauce_connect)",
},
)

sh_binary(
name = "sauce_service_start",
srcs = ["sauce-service.sh"],
args = ["start"],
data = ["@npm//sauce-connect"],
data = ["//:sauce_connect"],
env = {
"SAUCE_CONNECT": "$(rootpath //:sauce_connect)",
},
)

sh_binary(
name = "sauce_service_start_ready_wait",
srcs = ["sauce-service.sh"],
args = ["start-ready-wait"],
data = ["@npm//sauce-connect"],
data = ["//:sauce_connect"],
env = {
"SAUCE_CONNECT": "$(rootpath //:sauce_connect)",
},
)

sh_binary(
name = "sauce_service_ready_wait",
srcs = ["sauce-service.sh"],
args = ["ready-wait"],
data = ["@npm//sauce-connect"],
data = ["//:sauce_connect"],
env = {
"SAUCE_CONNECT": "$(rootpath //:sauce_connect)",
},
)

sh_binary(
name = "sauce_service_stop",
srcs = ["sauce-service.sh"],
args = ["stop"],
data = ["@npm//sauce-connect"],
data = ["//:sauce_connect"],
env = {
"SAUCE_CONNECT": "$(rootpath //:sauce_connect)",
},
)

sh_binary(
name = "sauce_service_tail",
srcs = ["sauce-service.sh"],
args = ["tail"],
data = ["@npm//sauce-connect"],
data = ["//:sauce_connect"],
env = {
"SAUCE_CONNECT": "$(rootpath //:sauce_connect)",
},
)

sh_binary(
name = "sauce_service_log",
srcs = ["sauce-service.sh"],
args = ["log"],
data = ["@npm//sauce-connect"],
data = ["//:sauce_connect"],
env = {
"SAUCE_CONNECT": "$(rootpath //:sauce_connect)",
},
)
66 changes: 34 additions & 32 deletions tools/saucelabs/sauce-service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,38 +93,40 @@ service-setup-command() {
@fail "SAUCE_TUNNEL_IDENTIFIER environment variable required"
fi

local unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) local machine=linux ;;
Darwin*) local machine=darwin ;;
CYGWIN*) local machine=windows ;;
MINGW*) local machine=windows ;;
MSYS_NT*) local machine=windows ;;
*) local machine=linux
printf "\nUnrecongized uname '${unameOut}'; defaulting to use node for linux.\n" >&2
printf "Please file an issue to https://github.com/bazelbuild/rules_nodejs/issues if \n" >&2
printf "you would like to add your platform to the supported rules_nodejs node platforms.\n\n" >&2
;;
esac

case "${machine}" in
# Path to sauce connect executable
linux)
if [[ -z "${BUILD_WORKSPACE_DIRECTORY:-}" ]]; then
# Started manually
SAUCE_CONNECT="${SCRIPT_DIR}/../../node_modules/sauce-connect/bin/sc"
else
# Started via `bazel run`
SAUCE_CONNECT="${BUILD_WORKSPACE_DIRECTORY}/node_modules/sauce-connect/bin/sc"
fi
;;
*)
if [[ -z "${SAUCE_CONNECT:-}" ]]; then
@fail "SAUCE_CONNECT environment variable is required on non-linux environments"
exit 1
fi
;;
esac
if [[ -z "${SAUCE_CONNECT:-}" ]]; then
local unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) local machine=linux ;;
Darwin*) local machine=darwin ;;
CYGWIN*) local machine=windows ;;
MINGW*) local machine=windows ;;
MSYS_NT*) local machine=windows ;;
*) local machine=linux
printf "\nUnrecongized uname '${unameOut}'; defaulting to use node for linux.\n" >&2
printf "Please file an issue to https://github.com/bazelbuild/rules_nodejs/issues if \n" >&2
printf "you would like to add your platform to the supported rules_nodejs node platforms.\n\n" >&2
;;
esac

case "${machine}" in
# Path to sauce connect executable
linux)
if [[ -z "${BUILD_WORKSPACE_DIRECTORY:-}" ]]; then
# Started manually
SAUCE_CONNECT="${SCRIPT_DIR}/../../node_modules/sauce-connect/bin/sc"
else
# Started via `bazel run`
SAUCE_CONNECT="${BUILD_WORKSPACE_DIRECTORY}/node_modules/sauce-connect/bin/sc"
fi
;;
*)
if [[ -z "${SAUCE_CONNECT:-}" ]]; then
@fail "SAUCE_CONNECT environment variable is required on non-linux environments"
exit 1
fi
;;
esac
fi

if [[ ! -f ${SAUCE_CONNECT} ]]; then
@fail "sc binary not found at ${SAUCE_CONNECT}"
Expand Down
4 changes: 0 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14184,10 +14184,6 @@ sass@1.77.4:
immutable "^4.0.0"
source-map-js ">=0.6.2 <2.0.0"

"sauce-connect@https://saucelabs.com/downloads/sc-4.9.1-linux.tar.gz":
version "0.0.0"
resolved "https://saucelabs.com/downloads/sc-4.9.1-linux.tar.gz#9310bc860f7870a1f872b11c4dc6073a1ad34e5e"

saucelabs@7.5.0, saucelabs@^1.5.0, saucelabs@^4.6.3:
version "7.5.0"
resolved "https://registry.yarnpkg.com/saucelabs/-/saucelabs-7.5.0.tgz#75c88a95e1519a63b79978d146a764a2eecb4f0e"
Expand Down

0 comments on commit 57aa965

Please sign in to comment.