Skip to content

Commit fccab04

Browse files
committed
fix(ci): repair apt state only after a failed cached dpkg install
1 parent 9ba607a commit fccab04

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎.github/scripts/install-playwright.sh‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,23 @@ install_from_cache() {
3030
local output
3131
if ! output=$(sudo DEBIAN_FRONTEND=noninteractive dpkg -i "$cache"/*.deb 2>&1); then
3232
printf '%s\n' "$output" | tail -n 5 | sed 's/^/Cache install failed: /'
33+
dpkg_failed=true
3334
return 1
3435
fi
3536
deps_present
3637
}
3738

3839
cache=${PLAYWRIGHT_APT_CACHE:-}
40+
dpkg_failed=false
3941
if ! deps_present; then
4042
if install_from_cache; then
4143
echo "Installed system dependencies from $cache"
4244
else
43-
# A failed dpkg run can leave packages half-configured; let apt finish or remove them first.
44-
sudo DEBIAN_FRONTEND=noninteractive apt-get -f install -y > /dev/null
45+
# Only a failed dpkg run leaves packages half-configured; apt must finish or remove them
46+
# before install-deps can install anything.
47+
if [ "$dpkg_failed" = true ]; then
48+
sudo DEBIAN_FRONTEND=noninteractive apt-get -f install -y > /dev/null
49+
fi
4550
bunx --no-install playwright install-deps "${browsers[@]}"
4651
if [ -n "$cache" ] && compgen -G '/var/cache/apt/archives/*.deb' > /dev/null; then
4752
mkdir -p "$cache"

0 commit comments

Comments
 (0)