Skip to content

Tooling: Fix the test:php, php-install, lint:css and docGen npm scripts - #632

Open
huzaifaalmesbah wants to merge 2 commits into
WordPress:developfrom
huzaifaalmesbah:fix/629-npm-scripts
Open

huzaifaalmesbah wants to merge 2 commits into
WordPress:developfrom
huzaifaalmesbah:fix/629-npm-scripts

Conversation

@huzaifaalmesbah

Copy link
Copy Markdown
Member

What?

Fixes the test:php, php-install, lint:css and docGen npm scripts, which fail on develop.

Why?

Fixes #629.

  • test:php and php-install use the phpunit and composer containers, which current versions of @wordpress/env no longer provide.
  • lint:css lints the .ts/.tsx files in ./src as CSS and reports 38 CssSyntaxError errors.
  • docGen points to src/scripts/wp-notifications.js, which doesn't exist.

How?

  • test:php → wp-env run tests-cli --env-cwd=wp-content/plugins/wp-feature-notifications vendor/bin/phpunit. Extra PHPUnit arguments can be passed after --.
  • php-install → wp-env run cli --env-cwd=wp-content/plugins/wp-feature-notifications composer install --ignore-platform-req=php.
  • lint:css → wp-scripts lint-style \"src/**/*.scss\" (escaped quotes so the glob works on Windows), and the stylelint config now extends @wordpress/stylelint-config/scss.
  • Removed docGen.
  • .gitignore: split .phpunit.result.cache and cghooks.lock, which had been merged onto one line, so neither was ignored.
  • README.md: added a short "Testing and linting" section.

lint:pkg-json and lint:md:docs are fixed separately in #631. Both PRs edit the scripts block in package.json, so whichever merges second will need a small rebase.

Testing Instructions

  1. Run npm install and npx wp-env start.
  2. Run npm run php-install. Composer installs the dependencies in the cli container.
  3. Run npm run test:php. PHPUnit runs in tests-cli (currently 62 tests, 24 skipped, no failures).
  4. Run npm run test:php -- --filter Test_Model_Message to check that extra arguments are passed through.
  5. Run npm run lint:css. It lints only the .scss files and exits 0.
  6. Run npm run docGen. npm reports that the script is missing.

Screenshots or screencast

N/A

Use of AI Tools
  • AI assistance: Yes
  • Tool(s): Claude Code
  • Model(s): Claude Opus 5.5
  • Used for: Finding why the scripts fail, updating them for the current @wordpress/env containers and the SCSS stylelint config, and running each script to confirm the fix. I reviewed and tested all changes.

- test:php and php-install used the phpunit and composer containers,
  which current versions of @wordpress/env no longer provide. Run them
  in tests-cli and cli instead.
- lint:css linted the .ts/.tsx files in src as CSS. Lint only the .scss
  files, using the SCSS variant of the WordPress stylelint config.
- Remove docGen, which pointed at a file that does not exist.
- Split two .gitignore entries that had been merged onto one line.
- Document the test and lint scripts in the README.

Fixes WordPress#629.

This branch has not been deployed

No deployments
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.

npm scripts test:php, php-install, lint:css and docGen are broken

1 participant