Skip to content

Commit 0dd01dc

Browse files
committed
test-env: the pinned WordPress never updates itself under a gate (from aff7378)
1 parent 0938106 commit 0dd01dc

3 files changed

Lines changed: 43 additions & 3 deletions

File tree

‎skills/html2wp/SKILL.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,8 +1939,9 @@ assets/scripts/test-env.sh down <slug> # tear down when done
19391939

19401940
`up` runs on a UNIQUE `docker compose` project (`h2wp-<slug>-<runid>`), finds
19411941
its own free host port (real allocation via Docker, not an assumed `8082`),
1942-
installs wp-cli and WordPress itself (the base `wordpress:latest` image ships
1943-
neither wp-cli nor a mysql client — verify before assuming either is there),
1942+
installs wp-cli and WordPress itself (the base image, WordPress 7.0.2 pinned by
1943+
digest with its auto-updater off, ships neither wp-cli nor a mysql client —
1944+
verify before assuming either is there),
19441945
sets a permalink structure and asserts `.htaccess` actually got real
19451946
`RewriteRule` lines rather than empty BEGIN/END markers, fixes `wp-content`
19461947
ownership to `www-data`, and deletes WordPress's sample content. It writes

‎skills/html2wp/assets/scripts/test-env-compose.yml‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ services:
2727
# after that file is gone (see up_cmd). Empty when set by nothing.
2828
h2wp.state: "${H2WP_STATE_FILE:-}"
2929
wp:
30-
# WordPress 7.0.2, pinned for the same reason as the database.
30+
# WordPress 7.0.2, pinned for the same reason as the database: pinned by
31+
# digest AND with the updater off. WordPress lives in the wp_data volume,
32+
# and a site on the stock image updates its own core through wp-cron
33+
# (major versions included): an idle preview went from 7.0.2 to 7.1.2 in
34+
# place, and the gate running at that minute met maintenance mode. The
35+
# constant stops core, plugin, theme and translation auto-updates.
36+
# Repin deliberately (and record it), never by drift.
3137
image: wordpress:latest@sha256:fe04ca18a5897be659e0d48686467dc939409b6ee53394507d0d08396595be67
3238
depends_on:
3339
- db
@@ -36,6 +42,7 @@ services:
3642
WORDPRESS_DB_NAME: wordpress
3743
WORDPRESS_DB_USER: wordpress
3844
WORDPRESS_DB_PASSWORD: wppw
45+
WORDPRESS_CONFIG_EXTRA: "define('AUTOMATIC_UPDATER_DISABLED', true);"
3946
ports:
4047
# No host port pinned on purpose — Docker allocates a free one
4148
# atomically, which is a real free-port search (no bind-then-hope race)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) 2026 BELNEM s.r.o. html2wp Source-Available Licence — see LICENSE.
3+
#
4+
# The test WordPress holds still: a fresh `test-env.sh up` runs the pinned
5+
# WordPress, and WordPress's own update checks (the wp-cron events that
6+
# installed 7.1.2 over an idle 7.0.2 preview, maintenance mode included)
7+
# change nothing: same version afterwards, no .maintenance file, and the
8+
# updater reports itself disabled.
9+
# Needs Docker. Uses its own throwaway env and removes it.
10+
set -uo pipefail
11+
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12+
command -v docker >/dev/null || { echo "SKIP: docker not available"; exit 0; }
13+
TMP="$(mktemp -d)"; SLUG="p-pinned-$$"
14+
cleanup() { (cd "$TMP" && bash "$HERE/test-env.sh" down "$SLUG" >/dev/null 2>&1); rm -rf "$TMP"; }
15+
trap cleanup EXIT
16+
fail=0; check() { if [ "$2" = "$3" ]; then echo " ok $1"; else echo " FAIL $1: got '$2', want '$3'"; fail=1; fi; }
17+
18+
cd "$TMP"
19+
bash "$HERE/test-env.sh" up "$SLUG" > up.log 2>&1 || { echo "up failed:"; tail -20 up.log; exit 1; }
20+
WP="$(python3 -c "import json;print(json.load(open('.test-env-$SLUG.json'))['wpCli'])")"
21+
# The version the image ships, read from the image's own copy: the pin is the
22+
# digest, so the test never hardcodes a WordPress release.
23+
IMG="$($WP eval 'include "/usr/src/wordpress/wp-includes/version.php"; echo $wp_version;' 2>/dev/null)"
24+
before="$($WP core version)"
25+
check "a fresh up runs the image's WordPress" "$before" "$IMG"
26+
check "the updater is off" "$($WP eval 'require_once ABSPATH."wp-admin/includes/class-wp-automatic-updater.php"; echo (new WP_Automatic_Updater())->is_disabled() ? "off" : "on";')" "off"
27+
$WP cron event run wp_version_check >/dev/null 2>&1
28+
$WP cron event run wp_maybe_auto_update >/dev/null 2>&1
29+
check "after WordPress's own update run: same version" "$($WP core version)" "$before"
30+
check "no maintenance mode left behind" "$($WP eval 'echo file_exists(ABSPATH.".maintenance") ? "present" : "absent";')" "absent"
31+
32+
[ "$fail" = 0 ] && echo "ALL OK" || { echo "FAILED"; exit 1; }

0 commit comments

Comments
 (0)