Skip to content

When building a new plugin with LaunchPad, PHPCS rules & CI must be validated by the automatically generated code #30

@MathieuLamiot

Description

@MathieuLamiot

Context
I am working on a new plugin from scratch, using WP-Launchpad: wordpressfan/wordpress-debug-hooks#1
Doing so, a CI is automatically added to GitHub. However, the generated code does not pass the CI.

For instance, the linter complains:

  • Missing spaces around parenthesis in the main plugin file for : boot(__FILE__);
  • (Not sure if I changed this manually or not) In the ServiceProvider, { must be on the same line as the class declaration.
  • Missing docstring for get_common_subscribers (maybe to add to the doc code snippet?)
  • (Not sure if I changed this manually or not) Space used instead of tab.
  • Global variables without the plugin prefix in parameters.php
  • Alignment issues in parameters.php

Also, the tests GH actions fail:

  • The install-wp-tests.sh seems missing?
  • There are composer errors before running the tests in the CI because of version mismatch. It looks like Launchpad requires PHP 7.4 through the zip dependency? But we are testing 7.3?
  Problem 1
    - nelexa/zip[4.0.0, ..., 4.0.2] require php ^7.4 || ^8.0 -> your php version (7.3.33) does not satisfy that requirement.
    - wp-launchpad/build v0.0.8 requires nelexa/zip ^4.0 -> satisfiable by nelexa/zip[4.0.0, 4.0.1, 4.0.2].
    - Root composer.json requires wp-launchpad/build ^0.0.8 -> satisfiable by wp-launchpad/build[v0.0.8].
  • After fixing the above issues manually, some errors remain:
Run composer run-tests
> "vendor/bin/phpunit" --testsuite unit --colors=always --configuration tests/Unit/phpunit.xml.dist
PHPUnit 9.6.20 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.4.33
Configuration: tests/Unit/phpunit.xml.dist

No tests executed!
> "vendor/bin/phpunit" --testsuite integration --colors=always --configuration tests/Integration/phpunit.xml.dist --exclude-group AdminOnly
Installing...
Running as single site... To run multisite, use -c tests/phpunit/multisite.xml
Warning: PHP Warning:  fopen(/home/runner/work/wordpress-debug-hooks/wordpress-debug-hooks/vendor-prefixed/wp-launchpad/core/inc/boot.php): failed to open stream: No such file or directory in /home/runner/work/wordpress-debug-hooks/wordpress-debug-hooks/vendor/antecedent/patchwork/src/CodeManipulation/Stream.php on line [15](https://github.com/wordpressfan/wordpress-debug-hooks/actions/runs/9891170201/job/27321024460#step:12:16)1
Warning: PHP Warning:  require(/home/runner/work/wordpress-debug-hooks/wordpress-debug-hooks/vendor-prefixed/wp-launchpad/core/inc/boot.php): failed to open stream: "Patchwork\CodeManipulation\Stream::stream_open" call failed in /home/runner/work/wordpress-debug-hooks/wordpress-debug-hooks/debug-hooks.php on line [17](https://github.com/wordpressfan/wordpress-debug-hooks/actions/runs/9891170201/job/27321024460#step:12:18)
Error: PHP Fatal error:  require(): Failed opening required '/home/runner/work/wordpress-debug-hooks/wordpress-debug-hooks/vendor-prefixed/wp-launchpad/core/inc/boot.php' (include_path='.:/usr/share/php') in /home/runner/work/wordpress-debug-hooks/wordpress-debug-hooks/debug-hooks.php on line 17
;\Patchwork\CodeManipulation\Stream::reinstateWrapper();
Warning: fopen(/home/runner/work/wordpress-debug-hooks/wordpress-debug-hooks/vendor-prefixed/wp-launchpad/core/inc/boot.php): failed to open stream: No such file or directory in /home/runner/work/wordpress-debug-hooks/wordpress-debug-hooks/vendor/antecedent/patchwork/src/CodeManipulation/Stream.php on line 151

Warning: require(/home/runner/work/wordpress-debug-hooks/wordpress-debug-hooks/vendor-prefixed/wp-launchpad/core/inc/boot.php): failed to open stream: "Patchwork\CodeManipulation\Stream::stream_open" call failed in /home/runner/work/wordpress-debug-hooks/wordpress-debug-hooks/debug-hooks.php on line 17

Fatal error: require(): Failed opening required '/home/runner/work/wordpress-debug-hooks/wordpress-debug-hooks/vendor-prefixed/wp-launchpad/core/inc/boot.php' (include_path='.:/usr/share/php') in /home/runner/work/wordpress-debug-hooks/wordpress-debug-hooks/debug-hooks.php on line 17
Script "vendor/bin/phpunit" --testsuite integration --colors=always --configuration tests/Integration/phpunit.xml.dist --exclude-group AdminOnly handling the test-integration event returned with error code 255
Script @test-integration was called via run-tests
Error: Process completed with exit code [25](https://github.com/wordpressfan/wordpress-debug-hooks/actions/runs/9891170201/job/27321024460#step:12:26)5.
  • composer.lock is not excluded from git in .gitignore

Locally, with PHPCS:
When manually running phpcs, many errors are comming from vendor-prefixed. I added

<exclude-pattern>/vendor-prefixed/*</exclude-pattern>

in phpcs.xml to avoid this. Could this be made automatically?

Expected behavior
After initializing a plugin from scratch with composer:

  • Running PHPCS locally must pass.
  • The CI must be running on Github.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions