Skip to content

feat: keep WP Codebox current via subtree-aware plugin updates#189

Merged
chubes4 merged 1 commit into
mainfrom
fix-wp-codebox-drift-subtree-updater
Jun 5, 2026
Merged

feat: keep WP Codebox current via subtree-aware plugin updates#189
chubes4 merged 1 commit into
mainfrom
fix-wp-codebox-drift-subtree-updater

Conversation

@chubes4
Copy link
Copy Markdown
Member

@chubes4 chubes4 commented Jun 4, 2026

Summary

upgrade.sh never updated WP Codebox, so installs silently drift behind upstream. Observed in the field: a WP Codebox install pinned at 0.1.0 while upstream had shipped 0.5.0 — four minor versions of browser-probe runtime behind, which broke the WordPress extension's PHPUnit-via-WP-Codebox test harness until the plugin was manually synced.

Root cause

WP Codebox is packaged as the packages/wordpress-plugin/ subtree of a Node monorepo (Automattic/wp-codebox), not a standalone single-repo plugin. The generic update_plugin_to_latest_tag() helper clones a whole repo into wp-content/plugins/<slug> and checks out a tag — which cannot work for a subtree-packaged plugin (it would deposit the entire monorepo). So a WP Codebox install made from the packaged subtree is not a git checkout, the tagged-release path skips it ("…is not a git checkout — skipping tagged release update"), and it never advances.

The fix

New lib/wp-codebox.sh::update_wp_codebox_plugin_subtree(), wired into the plugins phase right after the Data Machine plugin update:

  • Resolves the latest version tag via git ls-remote (no full clone).
  • When the install is behind, sparse-checks-out the packages/wordpress-plugin subtree at that tag and syncs src/, assets/, wp-codebox.php, README.md, package.json into wp-content/plugins/wp-codebox, preserving the artifact-install shape (no .git in the plugin dir).
  • No-op when WP Codebox is not installed — installation stays the setup interview's job.
  • Delegates to update_plugin_to_latest_tag() when the install is a real git checkout.
  • Honors --dry-run, --skip-plugins, and --no-data-machine like the existing plugin phase.

Verified against the live site in dry-run: WP Codebox already at latest tag (v0.5.0).

Tests

tests/wp-codebox-subtree.sh (network-free; stubbed git ls-remote) covers:

  1. not-installed → clean skip
  2. already-at-latest → no-op, records no update
  3. real git checkout → delegates to update_plugin_to_latest_tag
  4. behind + dry-run → reports 0.4.0 → 0.5.0, performs no write
  5. INSTALL_DATA_MACHINE=false → clean skip

Registered in .github/workflows/shell.yml. All passing locally.

WP Codebox is packaged as the packages/wordpress-plugin/ subtree of a Node
monorepo, not a standalone single-repo plugin. The generic
update_plugin_to_latest_tag() helper clones a whole repo into
wp-content/plugins/<slug> and checks out a tag, which cannot work for a
subtree-packaged plugin — so a WP Codebox install made from the packaged subtree
is not a git checkout, gets skipped by the tagged-release path, and silently
drifts behind upstream (observed in the field at 0.1.0 while upstream shipped
0.5.0, four minor versions of browser-probe runtime behind).

Add update_wp_codebox_plugin_subtree(): resolves the latest version tag via
git ls-remote (no full clone), and when the installed plugin is behind, sparse-
checks-out the wordpress-plugin subtree at that tag and syncs it into
wp-content/plugins/wp-codebox, preserving the artifact-install shape. It is a
no-op when WP Codebox is not installed (install remains the setup interview's
job), delegates to update_plugin_to_latest_tag() when the install is a real git
checkout, and honors --dry-run / --skip-plugins / --no-data-machine like the
existing plugin phase. Wired into the plugins phase after the Data Machine
plugin update.

Add tests/wp-codebox-subtree.sh (network-free, stubbed git ls-remote) covering
not-installed skip, already-at-latest no-op, git-checkout delegation, dry-run
reporting, and the Data-Machine-disabled skip; registered in shell.yml CI.
@chubes4 chubes4 merged commit e189315 into main Jun 5, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant