Skip to content

TWO-24747/feat: Local dev harness targets and env plumbing#322

Open
dgjlindsay wants to merge 8 commits into
doug/TWO-24745-base-brand-seamsfrom
doug/TWO-24747-dev-harness
Open

TWO-24747/feat: Local dev harness targets and env plumbing#322
dgjlindsay wants to merge 8 commits into
doug/TWO-24745-base-brand-seamsfrom
doug/TWO-24747-dev-harness

Conversation

@dgjlindsay

Copy link
Copy Markdown

What

D1 of the plugin parity plan (TWO-24739 → TWO-24747). Ticket premise correction: the compose stack (wordpress + wpcli provisioner + mariadb, product seeding, plugin activation, config JSON) already existed — this PR adds the missing ergonomics, not the environment.

Stacked on #321 (needs the brand layer's TWO_BRAND_CODE handling).

How

  • .env.example → copy to .env (compose's native env file — the ticket's .env.local spelling diverged from the repo's existing .env convention; code wins): TWO_API_BASE_URL, TWO_API_KEY, TWO_BRAND_CODE, WooCommerce knobs.
  • Compose passes TWO_BRAND_CODE into the WordPress container (PHP getenvWC_Twoinc_Brand) and parameterises the provisioning vars with the previous hardcoded values as defaults.
  • dev/configure: idempotent wp-cli script writing TWO_API_KEY/TWO_API_BASE_URL onto the gateway settings; runs at first provision and via make configure.
  • docker/wpcli.sh now derives the settings option key from the gateway id (was hardcoded — a brand-override run would have seeded the wrong option row).
  • Makefile: install / run / configure / logs / logs-wpcli / stop / clean / test-unit / test / format. make test-unit runs the TWO-24744 unit harness in a php:8.2 container — the ticket's "establish PHPUnit baseline" is superseded by that suite (deliberately dependency-free; CI already runs it on 7.4+8.2).

Test plan

  • docker compose config valid; bash -n on both scripts
  • make test-unit green (19/19)
  • Fresh make clean && make install provision on a dev box, checkout loads, make configure round-trips an api-key change

🤖 Generated with Claude Code

The compose stack (wordpress + wpcli provisioner + mariadb) already
existed — the ticket's 'no structured dev environment' premise
predates it. What was actually missing:

- .env.example documenting the TWO_* dev variables; docker compose
  reads .env natively and the WOOCOM_* provisioning knobs are now
  parameterised with their previous values as defaults.
- TWO_BRAND_CODE passthrough to the wordpress and wpcli containers so
  the brand layer's dev override (TWO-24744) works in the harness.
- dev/configure: idempotent wp-cli script applying TWO_API_KEY /
  TWO_API_BASE_URL onto the gateway settings; wired into first
  provision and exposed as 'make configure'.
- wpcli.sh derives the settings option key from the gateway id instead
  of hardcoding it (a brand-override dev run would have written the
  wrong option row).
- Makefile dev targets: install/run/configure/logs/stop/clean/
  test-unit/test/format. test-unit runs the tests/unit harness from
  TWO-24744 in a php:8.2 container (the ticket's 'establish PHPUnit
  baseline' is superseded by that suite).
- README quick-start updated.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown

🖌 Pre-commit success 🏆

Details
Downloading virtualenv (7.2MiB)
 Downloaded virtualenv
Installed 11 packages in 16ms
prettier.................................................................Passed

Exit code: 0

Author ✍️@dgjlindsay

dgjlindsay and others added 7 commits June 11, 2026 00:42
Review findings (single-reviewer round):

- BLOCKER: parameterising WOOCOM_PLUGIN_CONFIG_JSON defaulted CI's
  compose to the local-dev config — the gateway under e2e test would
  seed http://portal.localhost/api with the dummy key while the
  Playwright harness polls staging. The workflow now writes a .env
  pinning the rendered staging config before compose up.
- The wpcli option-key comment overstated brand-following: it's a
  static fallback matching the two brand; overlay runs need
  TWO_GATEWAY_ID set explicitly.
- Prettier on README.

Reviewer empirically verified the load-bearing claims in the pinned
images: mod_php getenv() sees container env (no PassEnv needed), and
wp-cli 2.11 supports 'wp option patch'.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
'get' is not a patch action (insert/update/delete only) — the debug
echo at the end of dev/configure errored and set -e killed the wpcli
bootstrap, which CI's e2e job caught. The getter is 'wp option pluck',
now also guarded so a missing subkey cannot kill provisioning.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Combined-chain round 2 (security + post-fix + coherence + cross-plugin
panels):

- README e2e setup now pins the staging config before compose up — the
  harness PR changed the compose default to the local config and CI got
  the fix but the human instructions didn't (a developer following the
  README would have run staging-keyed tests against a local-config
  store).
- .env.example ships a placeholder API key instead of the real-looking
  committed sandbox key (rotation of the historical key is a separate
  team action — it remains in git history and docker/config/local.json).
- Brand-file loader: filter-supplied paths must be real .php files
  inside the plugins/mu-plugins tree (defence in depth on the require
  sink; co-resident plugins are trusted, this just keeps uploads and
  other writable paths out of reach).
- esc_url on the brand signup link, matching the icon's pattern.
- brands/two.php: merchant_signup_url renamed to the cross-plugin
  canonical sign_up_url (recorded convention; renamed now while the
  file is fresh rather than deferring the agreed rename another cycle).
  The WC_Twoinc::MERCHANT_SIGNUP_URL constant keeps its BC spelling.
- brands/two.php docblock covers the test-asserted 'code' key; README
  compose spelling unified.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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