fix(ci): read the browser version from stdout, and drop the stray gitlink
Two of the three findings open on the release pull request. `runs()` piped `--version` through `head -1` with the streams merged. A browser that works still warns on stderr - GPU, dbus, the root-without-sandbox notice - so the first warning was read as the version, the `chrom` match failed, and the script installed libraries it did not need before exiting 1 with nothing exported. Under `set -o pipefail`, closing the pipe with `head -1` did the same to any browser printing more than one line. The version now comes from stdout and the warnings are kept apart for the failure message, which is where they are worth having. Both cases are pinned by new tests: a browser that warns on stderr and prints two stdout lines passes, and the browser that cannot start still reports its loader error. `dc-lint719` was a gitlink at the repository root with no .gitmodules entry, so a clone produced an empty directory and `git submodule update --init` reported "No url found for submodule path". Removed from the tree.
This commit is contained in:
1 parent
1e7c47bc05
commit
c5d45597e3
3 files changed
+45
-9
No files matched your search
@@ -49,8 +49,26 @@ install_deps() {
|
||||
xauth xvfb zip unzip jq
|
||||
}
|
||||
|
||||
runs() { # <path> -> prints its version, non-zero if it will not start
|
||||
"$1" --version 2>&1 | head -1
|
||||
# Sets VERSION to the first line the browser prints on stdout, and ERR to
|
||||
# whatever it writes on stderr. Stderr is kept out of VERSION because a browser
|
||||
# that works still warns there (GPU, dbus, root-without-sandbox), but it is kept
|
||||
# for the failure message, which is the only place it is useful.
|
||||
#
|
||||
# Reads from files rather than piping: `| head -1` closes the pipe, and under
|
||||
# `set -o pipefail` that turns a browser which prints more than one line into a
|
||||
# failure.
|
||||
VERSION=""
|
||||
ERR=""
|
||||
runs() { # <path>, returns the browser's exit status
|
||||
local out err
|
||||
out="$(mktemp)"
|
||||
err="$(mktemp)"
|
||||
"$1" --version >"$out" 2>"$err"
|
||||
local status=$?
|
||||
VERSION="$(sed -n '1p' "$out")"
|
||||
ERR="$(cat "$err")"
|
||||
rm -f "$out" "$err"
|
||||
return $status
|
||||
}
|
||||
|
||||
# The directories searched, and the prefix the absolute candidates hang off,
|
||||
@@ -118,19 +136,20 @@ else
|
||||
source="downloaded from the pinned snapshot"
|
||||
fi
|
||||
|
||||
version="$(runs "$browser")"
|
||||
if [ $? -ne 0 ] || ! printf '%s' "$version" | grep -qi "chrom\|chrome"; then
|
||||
log "browser will not start: $version"
|
||||
runs "$browser"
|
||||
if [ $? -ne 0 ] || ! printf '%s' "$VERSION" | grep -qi "chrom\|chrome"; then
|
||||
log "browser will not start: $VERSION $ERR"
|
||||
if [ "$source" = "from the runner" ]; then
|
||||
log "installing its libraries and retrying"
|
||||
install_deps
|
||||
version="$(runs "$browser")"
|
||||
runs "$browser"
|
||||
fi
|
||||
if [ $? -ne 0 ] || ! printf '%s' "$version" | grep -qi "chrom\|chrome"; then
|
||||
log "still not runnable after installing libraries: $version"
|
||||
if [ $? -ne 0 ] || ! printf '%s' "$VERSION" | grep -qi "chrom\|chrome"; then
|
||||
log "still not runnable after installing libraries: $VERSION $ERR"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
version="$VERSION"
|
||||
|
||||
log "using $browser"
|
||||
log " source: $source"
|
||||
|
||||
@@ -81,6 +81,24 @@ if [ "$rc" -eq 0 ]; then
|
||||
fails=$((fails + 1))
|
||||
fi
|
||||
|
||||
# 5. A browser that warns on stderr before printing its version must be read as
|
||||
# working - the warnings a real Chrome prints (GPU, dbus, root-without-sandbox)
|
||||
# are not its version.
|
||||
warny="$tmp/warny/chromium"
|
||||
mkdir -p "$tmp/warny"
|
||||
printf '#!/bin/sh\necho "[1108/1200.123:WARNING:gpu_init.cc(521)] Passthrough is not supported" >&2\necho "Chromium 157.0.8103.0"\necho "second stdout line"\n' > "$warny"
|
||||
chmod +x "$warny"
|
||||
env_file="$tmp/env.5"
|
||||
: > "$env_file"
|
||||
out="$(DC_CHROMIUM="$warny" DC_PATH="$tmp/no-such-path" GITHUB_ENV="$env_file" bash "$script" 2>&1)"
|
||||
rc=$?
|
||||
expect "reads the version, not the warning" "version: Chromium 157.0.8103.0" "$out"
|
||||
expect "exports the path" "CYPRESS_BROWSER=$warny" "$(cat "$env_file")"
|
||||
if [ "$rc" -ne 0 ]; then
|
||||
echo "FAIL: a browser printing stderr warnings and two stdout lines must still pass"
|
||||
fails=$((fails + 1))
|
||||
fi
|
||||
|
||||
if [ "$fails" -eq 0 ]; then
|
||||
echo "resolve-browser: all cases pass"
|
||||
else
|
||||
|
||||
-1
Submodule dc-lint719 deleted from a8f62bdfe2.
Reference in new issue
Block a user