Skip to content

GH#951: add bin/check-env.sh prerequisite check script#952

Merged
superdav42 merged 2 commits intomainfrom
feature/auto-20260426-051736-gh951
Apr 26, 2026
Merged

GH#951: add bin/check-env.sh prerequisite check script#952
superdav42 merged 2 commits intomainfrom
feature/auto-20260426-051736-gh951

Conversation

@superdav42
Copy link
Copy Markdown
Collaborator

@superdav42 superdav42 commented Apr 26, 2026

Summary

Adds bin/check-env.sh — a single runnable script that verifies all development prerequisites (PHP, composer vendor, node_modules, wp-cli, WordPress dev env, WP test suite, xdebug) in one pass and prints actionable fix instructions for anything missing.

Updates AGENTS.md Quick Session Checklist item 4 to surface bash bin/check-env.sh as the recommended first step before any lint/test/WP-CLI command.

Why

Issue #951 (and predecessors #919, #928, #932, #940, #943, #948) report 4 recurring error patterns: webfetch:other (39x), read:file_not_found (35x), bash:other (34x), and edit:not_read_first (32x) from contributor superdav42's sessions.

Five documentation-only PRs have already addressed the written guidance for all four patterns. The remaining gap for bash:other is that prerequisite checks are documented as prose across multiple AGENTS.md sections — agents must read and mentally track several individual checks. Converting these into a runnable script with exit codes makes the check mechanical and unambiguous.

What changed

  • bin/check-env.sh (new): checks PHP, vendor/autoload.php, node_modules/.bin/eslint, wp in PATH, ../wordpress/wp-config.php, /tmp/wordpress-tests-lib, and xdebug. Exits 0 on all-pass, 1 on any required-check failure. xdebug is optional and shown as [--] rather than [!!].
  • AGENTS.md Quick Session Checklist item 4: adds bash bin/check-env.sh as the first recommended check, with the existing individual checks kept as the fallback.

Testing

bash bin/check-env.sh       # run from repo root; verify output matches actual state
bash -n bin/check-env.sh    # syntax check passes

Resolves #951


aidevops.sh v3.11.7 plugin for OpenCode v1.3.17 with claude-sonnet-4-6 spent 9m and 24,117 tokens on this as a headless worker.

Summary by CodeRabbit

  • New Features

    • Added a unified environment checker that verifies all required components in a single command and provides specific fix instructions for missing items.
  • Documentation

    • Updated setup guidance to highlight the consolidated environment check option while maintaining manual verification alternatives.

…list

Adds a runnable bash script that checks all development prerequisites
in one pass (PHP, composer, npm, wp-cli, WordPress dev env, WP test
suite, xdebug) and prints actionable fix instructions for anything
missing.

Updates AGENTS.md Quick Session Checklist item 4 to surface this
script as the first thing to run, consolidating the individual inline
checks that were scattered across the section.

Rationale: five documentation-only PRs (#920, #929, #933, #944, #949)
have already strengthened the written guidance for the four recurring
error patterns in issue #951. The remaining gap for bash:other is
converting the prerequisite check from prose instructions into a
runnable script that exits 1 on failure, so agents can detect missing
tools without reading multiple documentation sections.

Resolves #951
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 26, 2026

Warning

Rate limit exceeded

@superdav42 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 47 minutes and 45 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 47 minutes and 45 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 93f5e245-b62a-4b7f-af2c-7fa332612e38

📥 Commits

Reviewing files that changed from the base of the PR and between 7c9480c and 2391217.

📒 Files selected for processing (1)
  • bin/check-env.sh
📝 Walkthrough

Walkthrough

This PR consolidates environment prerequisites checking by introducing bin/check-env.sh, a bash script that validates all required development components (PHP, Composer, Node.js, WP-CLI, WordPress dev environment, and test suite) in a single pass. The AGENTS.md documentation is updated to reference this consolidated verification approach while maintaining manual per-prerequisite options.

Changes

Cohort / File(s) Summary
Documentation
AGENTS.md
Updated prerequisites checklist to reference consolidated bin/check-env.sh script as primary verification method while preserving manual per-prerequisite checks.
Development Tools
bin/check-env.sh
New bash preflight checker validating PHP, Composer dependencies, Node modules, WP-CLI, WordPress dev installation, test suite, and xdebug availability with standardized status output and exit codes.

Possibly related PRs

  • PR #949: Also modifies AGENTS.md prerequisites checklist for lint/test checks (Composer deps, eslint, WP test bootstrap) alongside similar environment validation guidance.
  • PR #920: Implements preflight environment checks that align with the consolidated verification approach introduced in this PR's new script.
  • PR #941: Updates AGENTS.md with overlapping WordPress test-suite and preflight guidance that connects to the automated checks now provided by bin/check-env.sh.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A rabbit hops through prerequisites with glee,
One script to check them all, as it should be!
No more scattered commands, just one clean pass,
Environment validation—crisp and crass. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: adding a new prerequisite check script at bin/check-env.sh, with the GitHub issue reference providing context.
Linked Issues check ✅ Passed The PR successfully addresses the bash:other error pattern from issue #951 by introducing a mechanical, runnable prerequisite check script that consolidates scattered manual checks, provides clear output on missing tools, and exits nonzero on failure.
Out of Scope Changes check ✅ Passed All changes are directly related to the stated objective: the new bin/check-env.sh script and AGENTS.md updates align with the goal of creating a unified prerequisite verification tool to reduce contributor errors.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/auto-20260426-051736-gh951

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

🔨 Build Complete - Ready for Testing!

📦 Download Build Artifact (Recommended)

Download the zip build, upload to WordPress and test:

🌐 Test in WordPress Playground (Very Experimental)

Click the link below to instantly test this PR in your browser - no installation needed!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
bin/check-env.sh (1)

46-60: Consider downgrading wp and ../wordpress to warnings (or scoping by workflow) rather than hard failures.

WP-CLI and the ../wordpress dev install are only required for wp ... commands and full integration scenarios; PHPUnit, PHPCS/PHPStan, ESLint/Stylelint, and npm run check all run without them. Treating them as [!!] (with exit 1) means a contributor who just wants to run the test suite or lint will see the script declare the environment "not ready" even though every test/lint command would succeed — the same pattern the PR is trying to avoid.

Two options, in order of preference:

  1. Treat them like xdebug — note/info output, no contribution to any_fail. Matches the optional nature documented in AGENTS.md "WP-CLI and Bash Prerequisites" section (line 320+).
  2. Split into "Required for tests/lint" (PHP, vendor, node_modules, WP test suite) and "Required for WP-CLI" (wp, ../wordpress) groups, and only fail when the corresponding group is needed (e.g., via a --wp-cli flag or env var).
♻️ Minimal diff for option 1 (treat as optional notes)
-# 4. WP-CLI
+# 4. WP-CLI (optional — only needed for wp commands)
 if command -v wp >/dev/null 2>&1; then
-	ok "wp-cli found: $(wp --version --allow-root 2>/dev/null || echo "(version unknown)")"
+	note "wp-cli found: $(wp --version --allow-root 2>/dev/null || echo "(version unknown)")"
 else
-	fail "wp-cli not in PATH"
+	note "wp-cli NOT in PATH (optional) — only needed for wp commands"
 	info "Install: https://wp-cli.org/#installing (download wp-cli.phar and add to PATH)"
 fi
 
-# 5. WordPress dev install
+# 5. WordPress dev install (optional — only needed for wp commands)
 if [ -f "../wordpress/wp-config.php" ]; then
-	ok "WordPress dev install found at ../wordpress"
+	note "WordPress dev install found at ../wordpress"
 else
-	fail "WordPress dev install missing at ../wordpress"
+	note "WordPress dev install missing at ../wordpress (optional) — only needed for wp commands"
 	info "Fix: cd ../wordpress && ./reset.sh  (or clone the dev WP install there)"
 fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bin/check-env.sh` around lines 46 - 60, The checks that call command -v wp
and test -f "../wordpress/wp-config.php" currently call fail and thus mark the
environment as unusable; change these to optional checks by converting the
fail/ok logic into informational notes (use info or note) and ensure they do not
update any_fail (or the same failure flag used elsewhere), or alternatively add
a --wp-cli/ENV flag to gate these checks so the wp CLI checks (the command -v wp
block and the ../wordpress/wp-config.php block) only run and can fail when that
flag is set; update the messages around those blocks (wp --version output and
the WordPress dev install message) to reflect optional status when not required.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@bin/check-env.sh`:
- Around line 1-22: The script currently runs relative-path checks from the
caller's CWD and can falsely report missing files; add a working-directory guard
at the top of bin/check-env.sh that resolves the script location and either cd's
to the repo root (parent of bin) before performing checks or prints a clear
error and exits; implement this by computing a SCRIPT_DIR (using the script's
path via $0), deriving REPO_ROOT as the parent directory, and changing to
REPO_ROOT before any calls to ok(), fail(), info(), or note() so all subsequent
path-based checks (e.g., vendor/autoload.php, node_modules/.bin/eslint,
../wordpress/wp-config.php) run from the intended repo root.

---

Nitpick comments:
In `@bin/check-env.sh`:
- Around line 46-60: The checks that call command -v wp and test -f
"../wordpress/wp-config.php" currently call fail and thus mark the environment
as unusable; change these to optional checks by converting the fail/ok logic
into informational notes (use info or note) and ensure they do not update
any_fail (or the same failure flag used elsewhere), or alternatively add a
--wp-cli/ENV flag to gate these checks so the wp CLI checks (the command -v wp
block and the ../wordpress/wp-config.php block) only run and can fail when that
flag is set; update the messages around those blocks (wp --version output and
the WordPress dev install message) to reflect optional status when not required.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ecd1dfc7-803d-4a2a-a707-695eae88562e

📥 Commits

Reviewing files that changed from the base of the PR and between 67f0507 and 7c9480c.

📒 Files selected for processing (2)
  • AGENTS.md
  • bin/check-env.sh

Comment thread bin/check-env.sh
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 26, 2026

Performance Test Results

Performance test results for 0e2f951 are in 🛎️!

Note: the numbers in parentheses show the difference to the previous (baseline) test run. Differences below 2% or 0.5 in absolute values are not shown.

URL: /

Run DB Queries Memory Before Template Template WP Total LCP TTFB LCP - TTFB
0 41 (+1 / +2% ) 37.83 MB 852.00 ms 151.00 ms (-3.50 ms / -2% ) 1093.00 ms (+71.00 ms / +6% ) 1998.00 ms 1916.45 ms 83.30 ms (-4.05 ms / -5% )
1 56 49.03 MB 935.00 ms (-23.00 ms / -2% ) 140.00 ms 1072.50 ms (-25.00 ms / -2% ) 2058.00 ms 1977.00 ms (-41.55 ms / -2% ) 79.90 ms (+2.25 ms / +3% )

Addresses CodeRabbit review: path-based checks (vendor/, node_modules/,
../wordpress/) are relative to CWD, which caused spurious failures if the
script was invoked from a subdirectory or editor task with a non-root CWD.

The guard computes the repo root from the script's own location and cd's
to it before performing any checks, so the output is always correct
regardless of where the caller's working directory was.
@github-actions
Copy link
Copy Markdown

🔨 Build Complete - Ready for Testing!

📦 Download Build Artifact (Recommended)

Download the zip build, upload to WordPress and test:

🌐 Test in WordPress Playground (Very Experimental)

Click the link below to instantly test this PR in your browser - no installation needed!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

@superdav42 superdav42 merged commit bd50004 into main Apr 26, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Contributor insight: 4 recurring error pattern(s) from superdav42

1 participant