Test against the newest WordPress and WooCommerce, and ship updates
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>
This commit is contained in:
co-authored by
Claude Opus 5
parent
e4a40e53a0
commit
eca2851d35
Executable
+84
@@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env bash
|
||||
# Guard the trap in .gitea/workflows.
|
||||
#
|
||||
# Gitea uses .gitea/workflows IF IT EXISTS, and falls back to .github/workflows
|
||||
# only when it does not. It never merges them. So a workflow that lives only in
|
||||
# .github/ simply does not run on Gitea — no error, no run to click on. It
|
||||
# looks exactly like a runner that has not picked the job up, so you wait, and
|
||||
# waiting never fixes it.
|
||||
#
|
||||
# Workflows that must behave identically on both forges are therefore kept
|
||||
# byte-identical in both roots, and this script fails when they drift or when
|
||||
# one appears in only one root without a stated reason.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
# Workflows that are deliberately single-forge, and why.
|
||||
declare -A only_on=(
|
||||
["auto-merge.yml"]="github: it drives the GitHub merge API. Gitea merges the owner's green PRs itself."
|
||||
["release.yml"]="both, but different: each publishes to the forge it runs on, and Gitea is where the update feed lives."
|
||||
)
|
||||
|
||||
fail=0
|
||||
|
||||
for root in .github .gitea; do
|
||||
[ -d "$root/workflows" ] || { echo "$root/workflows is missing."; fail=1; }
|
||||
done
|
||||
|
||||
for f in .github/workflows/*.yml .gitea/workflows/*.yml; do
|
||||
[ -e "$f" ] || continue
|
||||
name=$(basename "$f")
|
||||
gh=".github/workflows/$name"
|
||||
gt=".gitea/workflows/$name"
|
||||
|
||||
case "${only_on[$name]:-}" in
|
||||
github:*)
|
||||
[ -f "$gt" ] && { echo "$name is marked GitHub-only but exists in .gitea/workflows too."; fail=1; }
|
||||
continue
|
||||
;;
|
||||
both,*|"both, "*)
|
||||
# Present in both, intentionally different. Both copies must exist.
|
||||
{ [ -f "$gh" ] && [ -f "$gt" ]; } \
|
||||
|| { echo "$name is expected in both roots, but one copy is missing."; fail=1; }
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ ! -f "$gh" ] || [ ! -f "$gt" ]; then
|
||||
echo "$name exists in only one workflow root and is not listed in ci/workflows-in-sync.sh."
|
||||
echo " A workflow missing from .gitea/workflows does not run on Gitea, silently."
|
||||
fail=1
|
||||
continue
|
||||
fi
|
||||
|
||||
if ! cmp -s "$gh" "$gt"; then
|
||||
echo "$name has drifted between the two roots:"
|
||||
diff -u "$gh" "$gt" || true
|
||||
fail=1
|
||||
fi
|
||||
done
|
||||
|
||||
# Measured on Gitea 1.27.2: a workflow-level `concurrency:` block produced no
|
||||
# run at all — not a failed one, not a cancelled one. It may have been fixed
|
||||
# since, but the cost of keeping the rule is nil and the cost of rediscovering
|
||||
# it is an afternoon of blaming the runner.
|
||||
if grep -rn '^concurrency:' .gitea/workflows/ 2>/dev/null; then
|
||||
echo "A workflow-level concurrency: block can stop a Gitea workflow from running at all."
|
||||
fail=1
|
||||
fi
|
||||
|
||||
# A workflow that does not parse produces no run — the same symptom as every
|
||||
# other trap in this file. ci.yml cannot catch its own syntax error this way,
|
||||
# but release.yml and compat.yml can be caught here rather than on the tag.
|
||||
if python3 -c 'import yaml' 2>/dev/null; then
|
||||
for f in .github/workflows/*.yml .gitea/workflows/*.yml; do
|
||||
[ -e "$f" ] || continue
|
||||
python3 -c 'import sys,yaml; yaml.safe_load(open(sys.argv[1]))' "$f" \
|
||||
|| { echo "$f is not valid YAML, so it will simply never run."; fail=1; }
|
||||
done
|
||||
else
|
||||
echo "(PyYAML is not installed here, so the workflow files were not parsed.)"
|
||||
fi
|
||||
|
||||
[ "$fail" = 0 ] || exit 1
|
||||
echo "Workflows: in sync."
|
||||
Reference in New Issue
Block a user