diff --git a/ci/site-test.sh b/ci/site-test.sh index f42c4fe..b67b9e2 100755 --- a/ci/site-test.sh +++ b/ci/site-test.sh @@ -25,8 +25,23 @@ WP_VERSION="${WP_VERSION:-latest}" WC_VERSION="${WC_VERSION:-latest}" PHP_VERSION="${PHP_VERSION:-8.3}" -id="wpci-$$" +# 🔴 NOT just $$. A Gitea job runs in a fresh container where the shell gets a +# low PID, and those REPEAT across runs — so "wpci-$$" collides with the +# leftovers of any earlier run that did not clean up, and the job dies on +# `network with name wpci-147-net already exists`. Measured on Gitea run 999: +# every run landing on PID 147 was wedged permanently, while the same script on +# a laptop never collides because PIDs there are large and varied. +# +# The epoch and $RANDOM make the name unique per run even inside a container +# that always starts at the same PID. +id="wpci-$$-$(date +%s)-${RANDOM:-0}" net="$id-net" + +# The name is unique to this run, so anything already using it is debris from a +# crashed run and is ours to clear. Without this a single wedged name stays +# wedged forever, which is exactly what happened on the Gitea runner. +docker rm -f -v "$id-db" "$id-cli" >/dev/null 2>&1 || true +docker network rm "$net" >/dev/null 2>&1 || true # 🔴 -v, and it is the whole bug. `mariadb:lts` declares VOLUME # /var/lib/mysql, so every run creates an ANONYMOUS volume, and `docker rm -f` # does not remove anonymous volumes — only `docker rm -f -v` does. The named