Three things this repository could not do: prove the plugin still works on a
WordPress or WooCommerce released after it, get a fix onto a shop without
someone uploading a zip, and do either of those for the next plugin without
starting over.
ci/ is the test harness. ci/site-test.sh builds a throwaway WordPress +
WooCommerce in containers at any versions you name — including `nightly` and
`beta` — installs exactly the files the release zip will contain, and runs
tests/smoke.php inside it with wp eval-file. Real cart, real coupons, real
WC_Shipping_Rate objects: a mocked cart keeps passing after WooCommerce has
changed underneath it, which is the one failure worth catching here. WP_DEBUG
is on and any notice logged from this plugin's directory fails the build,
because that is the shape an upgrade actually breaks in — nothing fails, a
notice appears, and two releases later it is a fatal.
compat.yml runs that weekly against today's releases, the next WordPress and
the next WooCommerce, the oldest PHP the header promises and the newest PHP.
When it is green it opens a PR bumping "Tested up to" and "WC tested up to" —
only when green, because WooCommerce shows that second value to the shop owner
as an untested-plugin banner, and that banner is what they read before deciding
whether to press update.
includes/class-updater.php is the distribution half. It hooks
update_plugins_{hostname} for the host in the new "Update URI" header and reads
the Gitea release API, so WordPress handles the notice, the download, the
"Enable auto-updates" link and wp plugin update with no further code. Update
URI earns its place twice: since 5.8 a plugin that declares one is never asked
about on wordpress.org, so a .org plugin sharing this slug cannot be pushed
onto a shop running this one. The check sends nothing about the site and
overrides WordPress's default user agent, which carries the site's own URL.
release.yml tags, tests, builds, publishes — then reads the feed back with no
credentials. A private repository and a release with no zip attached both leave
a page that looks perfect to anyone logged in and an update no shop is ever
offered.
Measured before committing, all green: WP 7.1 + WC 11.1 on PHP 8.3 and 7.4,
WP 7.2-alpha on 8.3, and the beta cell falling back to stable on 8.4. No
deprecations from this plugin on any of them.
Three guards are there because the bug they catch is invisible without them:
the annotated tag is re-fetched before its message is read (checkout turns it
into a lightweight tag pointing at the merge commit), the two workflow roots
are kept in sync (.gitea/workflows hides .github/workflows entirely), and every
file the code loads must be in the release zip — which caught class-updater.php
being referenced and uncommitted while every local test passed.
docs/REUSE.md is the port to the next plugin: copy ci/, rewrite five lines.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
80 lines
3.4 KiB
Bash
Executable File
80 lines
3.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Update "Tested up to" and "WC tested up to" to the versions that were just
|
|
# tested, and open a pull request if anything changed.
|
|
#
|
|
# Run only after the compatibility matrix has gone green against the current
|
|
# releases. The headers are a claim made to whoever installs the plugin — and
|
|
# in WooCommerce's case a banner the shop owner reads before deciding whether
|
|
# to update at all — so bumping them on a red build would be publishing a claim
|
|
# we have just watched fail.
|
|
#
|
|
# Writes nothing when the headers are already current, so a quiet week costs a
|
|
# green run and no noise.
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")/.."
|
|
. ci/lib.sh
|
|
ci_load_conf
|
|
|
|
current_wp=$(curl -fsS --max-time 20 'https://api.wordpress.org/core/stable-check/1.0/' \
|
|
| tr ',' '\n' | sed -n -E 's/.*"([0-9][^"]*)"[[:space:]]*:[[:space:]]*"latest".*/\1/p' | head -1)
|
|
current_wc=$(curl -fsS --max-time 20 'https://api.wordpress.org/plugins/info/1.0/woocommerce.json' \
|
|
| sed -n -E 's/.*"version":"([^"]+)".*/\1/p' | head -1)
|
|
|
|
[ -n "$current_wp" ] || { echo "Could not read the current WordPress version." >&2; exit 1; }
|
|
|
|
readme=
|
|
for f in readme.txt README.txt; do [ -f "$f" ] && readme=$f && break; done
|
|
|
|
changed=()
|
|
|
|
if [ -n "$readme" ]; then
|
|
tested_wp=$(sed -n -E 's/^Tested up to:[[:space:]]*([^[:space:]]+).*/\1/p' "$readme" | head -1)
|
|
if [ "$tested_wp" != "$current_wp" ]; then
|
|
sed -i -E "s/^Tested up to:.*/Tested up to: $current_wp/" "$readme"
|
|
changed+=("WordPress ${tested_wp:-?} → $current_wp")
|
|
fi
|
|
fi
|
|
|
|
if [ "$NEEDS_WOOCOMMERCE" = yes ] && [ -n "$current_wc" ]; then
|
|
tested_wc=$(ci_plugin_header 'WC tested up to')
|
|
if [ "$tested_wc" != "$current_wc" ]; then
|
|
sed -i -E "s/^([[:space:]]*\*[[:space:]]*WC tested up to:).*/\1 $current_wc/" "$PLUGIN_MAIN"
|
|
[ -n "$readme" ] && sed -i -E "s/^WC tested up to:.*/WC tested up to: $current_wc/" "$readme"
|
|
changed+=("WooCommerce ${tested_wc:-?} → $current_wc")
|
|
fi
|
|
fi
|
|
|
|
if [ ${#changed[@]} -eq 0 ]; then
|
|
echo "The compatibility headers are already current — nothing to do."
|
|
exit 0
|
|
fi
|
|
|
|
# Re-read from disk rather than trusting the sed: a pattern that matched
|
|
# nothing would otherwise produce an empty, cheerful pull request.
|
|
for f in "$PLUGIN_MAIN" ${readme:+"$readme"}; do
|
|
git diff --quiet -- "$f" && continue
|
|
echo "--- $f"
|
|
git diff -- "$f" | sed -n '/^[+-][^+-]/p'
|
|
done
|
|
git diff --quiet && { echo "Nothing actually changed on disk — check the sed patterns." >&2; exit 1; }
|
|
|
|
branch="compat/tested-up-to-$current_wp-wc-$current_wc"
|
|
git config user.name "compatibility check"
|
|
git config user.email "noreply@localhost"
|
|
git checkout -b "$branch"
|
|
git commit -am "Tested against WordPress $current_wp and WooCommerce $current_wc
|
|
|
|
$(printf '%s\n' "${changed[@]}")
|
|
|
|
The compatibility matrix went green against these versions before this
|
|
was written, so the headers now say what was actually tested. WooCommerce
|
|
shows the 'WC tested up to' value to the shop owner as an untested-plugin
|
|
banner, which is what they read before deciding whether to press update."
|
|
|
|
git push -u origin "$branch"
|
|
|
|
gh pr create \
|
|
--title "Tested against WordPress $current_wp and WooCommerce $current_wc" \
|
|
--body "$(printf 'The weekly compatibility run passed against the current releases, so the headers are updated to match:\n\n%s\n\nOpened automatically by `ci/bump-tested-up-to.sh`. The versions here were tested before this PR existed; if the matrix had failed, the job that opens this would not have run.\n' "$(printf -- '- %s\n' "${changed[@]}")")"
|