The subtree is in place, so everything that used to fetch and patch core at
build time now just copies it.
tools/build.sh copies wordpress/ — no download, no checksum step,
because there is nothing to fetch and nothing to
trust that is not already in the repository
docker/Dockerfile COPY wordpress/ instead of curl + sha256 + patch;
the build args and the `patch` package are gone
docker-compose.yml no WP_VERSION / WP_URL / WP_SHA256 to keep in step
tools/update-wordpress.sh is rewritten around what the subtree makes
possible. It imports the pristine release onto sirius-press/wordpress-upstream
and then `git subtree merge`s that branch, which three-way merges upstream
against the fork's own commit. A patch either applies with fuzz and hopes or
fails and leaves you re-deriving the change by hand; a merge conflict is
resolved once, in the file, and the next release merges against the
resolution.
patches/ survives as documentation rather than mechanism, and is now
generated: tools/refresh-patches.sh diffs the subtree against the pristine
import and rewrites the directory, with --check for CI. It answers the
question anyone auditing a fork asks first — what exactly did you change
inside WordPress? — in a minute, which `git log wordpress/` cannot, because
that log is mostly upstream imports. Generated documentation stays true; a
hand-maintained record of a core diff drifts, and a stale one is worse than
none because people trust it.
One test change worth noting: the syntax sweep no longer walks all of
wordpress/. It lints the fork's own PHP plus every core file patches/ says
the fork touches, which keeps the suite at seven seconds instead of a minute
while still covering the only core file that can break.
82 lines
2.5 KiB
Bash
82 lines
2.5 KiB
Bash
#!/usr/bin/env bash
|
|
# Run the Sirius Press test suite.
|
|
#
|
|
# tests/run.sh
|
|
#
|
|
# Needs PHP 7.4+ with GMP or BCMath, and Node 18+ for the interop suite. Both
|
|
# are optional in the sense that the script says which one is missing and runs
|
|
# the rest — but the interop suite is the one that proves a signature made in
|
|
# a browser verifies on the server, so a run without it has not checked the
|
|
# thing most worth checking.
|
|
|
|
set -uo pipefail
|
|
|
|
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PHP_BIN="${PHP:-php}"
|
|
NODE_BIN="${NODE:-node}"
|
|
status=0
|
|
|
|
bar() { printf '\n\033[1m%s\033[0m\n' "$*"; }
|
|
|
|
if command -v "$PHP_BIN" >/dev/null 2>&1; then
|
|
for suite in test-crypto test-identity test-export; do
|
|
bar "php ${suite}"
|
|
"$PHP_BIN" "$here/$suite.php" || status=1
|
|
done
|
|
else
|
|
printf '\033[33mskipped:\033[0m no PHP on PATH (set PHP=/path/to/php)\n' >&2
|
|
status=1
|
|
fi
|
|
|
|
if command -v "$NODE_BIN" >/dev/null 2>&1; then
|
|
bar "node interop (browser wallet vs PHP)"
|
|
"$NODE_BIN" "$here/interop.mjs" || status=1
|
|
else
|
|
printf '\033[33mskipped:\033[0m no Node on PATH — the browser wallet was not checked against PHP\n' >&2
|
|
status=1
|
|
fi
|
|
|
|
bar "syntax"
|
|
syntax_ok=1
|
|
if command -v "$PHP_BIN" >/dev/null 2>&1; then
|
|
# The fork's own PHP, plus every core file the fork patches. Sweeping all
|
|
# of wordpress/ would lint 3,800 files of upstream code that upstream
|
|
# already tests, and turn a one-second suite into a minute of waiting.
|
|
lint_targets() {
|
|
find "$here/../plugins" "$here/../mu-plugins" "$here" \
|
|
-name '*.php' -not -path '*/node_modules/*' 2>/dev/null
|
|
for patch in "$here"/../patches/*.patch; do
|
|
[ -e "$patch" ] || continue
|
|
sed -n 's|^--- a/||p' "$patch" | while IFS= read -r rel; do
|
|
case "$rel" in *.php) echo "$here/../wordpress/$rel" ;; esac
|
|
done
|
|
done
|
|
}
|
|
while IFS= read -r file; do
|
|
[ -f "$file" ] || continue
|
|
if ! "$PHP_BIN" -l "$file" >/dev/null 2>&1; then
|
|
echo " FAIL $file"
|
|
"$PHP_BIN" -l "$file" 2>&1 | head -3
|
|
syntax_ok=0
|
|
status=1
|
|
fi
|
|
done < <(lint_targets)
|
|
fi
|
|
if command -v "$NODE_BIN" >/dev/null 2>&1; then
|
|
while IFS= read -r file; do
|
|
if ! "$NODE_BIN" --check "$file" >/dev/null 2>&1; then
|
|
echo " FAIL $file"
|
|
syntax_ok=0
|
|
status=1
|
|
fi
|
|
done < <(find "$here/../plugins" "$here" -name '*.js' -not -path '*/node_modules/*' 2>/dev/null)
|
|
fi
|
|
[ "$syntax_ok" -eq 1 ] && echo " ok the fork's PHP and JS parses, including every patched core file"
|
|
|
|
echo
|
|
if [ "$status" -eq 0 ]; then
|
|
printf '\033[32mAll suites passed.\033[0m\n\n'
|
|
else
|
|
printf '\033[31mSomething failed or was skipped.\033[0m\n\n'
|
|
fi
|
|
exit "$status"
|