Skip to content

Add minimal CI/QA checks#11

Open
jrfnl wants to merge 15 commits into
mainfrom
feature/add-minimal-ci
Open

Add minimal CI/QA checks#11
jrfnl wants to merge 15 commits into
mainfrom
feature/add-minimal-ci

Conversation

@jrfnl
Copy link
Copy Markdown
Contributor

@jrfnl jrfnl commented Feb 3, 2025

.gitignore: use top-level file instead of per-directory

Composer: normalize the file

Command used:

composer-normalize --indent-size=1 --indent-style=tab --profile --no-plugins --no-scripts

Composer: update maintainers list

CI: lint the PHP files against all supported versions

This commit:

  • Adds a new dev dependency on PHP Parallel Lint for linting PHP files.
  • Adds a Composer script documenting how this should be run.
  • Adds a GitHub Actions workflow to run PHP linting against all supported PHP versions.
  • Ensures that no composer.lock file will be created by default.
  • Ensures that a potentially pre-existing composer.lock file and the vendor directory do not get committed to the repo.

Add dependabot configuration

As there is now a GH Actions workflow, it should be kept up to date.

CI: run QA on GHA workflows

[UPDATED] CI: run PHPCS over the code

This commit:

  • Adds new dev dependencies on PHPCompatibility and PHP_CodeSniffer.
  • Adds a PHPCS configuration file to use PSR-12 with some tweaks (tab-indent instead of spaces + a few extra rules).
  • Adds Composer scripts documenting how this should be run.
  • Adds a GitHub Actions job to run PHPCS on all commits.
  • Ensures that local overrides of the PHPCS config do not get committed to the repo.

[UPDATED] CS: consistent whitespace use

CS/QA: use short arrays

CS/QA: always use braces for control structures

CS/QA: multi-statement alignment for readability

CS/QA; use pre-(in|de)crement rather than post

CS/QA: move function to its own file

🆕 Response: rename method to CamelCase

[UPDATED] CS/QA: miscellaneous other fixes

PHP-cross version: ensure same output independently of PHP version

CS/QA: use static closures (not enforced)

CS/QA: strict comparisons (not enforced)

PHPCS: add select ignore annotations

Comment thread .github/dependabot.yml
Comment thread .github/workflows/cs.yml
Comment thread .phpcs.xml.dist Outdated
-->

<!-- Use the WordPress Coding Standards as a basis, but with tweaks. -->
<rule ref="WordPress-Extra">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We discussed keeping the code style consistent across repositories last time, but now that I'm seeing the relative size of the code style rules VS the actual code, I'm wondering whether we shouldn't ignore consistency with the main library here, because:

  • this code is minimal and has very little to do with the actual library
  • we don't expect the same contributors to jump in here as well
  • just sticking with something like PSR-12 would get rid of a lot of the custom style rules AND remove the WPCS dependency

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Happy to change the PR to PSR12 + some extra rules instead. Will need to wait for our next session though as I won't have time to do this now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated now anyway:

  • PR has been rebased after Composer: remove autoload directive #12 was merged.
  • I've created a new PHPCS ruleset based on PSR-12 with a few tweaks (6d5b962693712a14f265b912eebeebb5bee9d1d2)
    The most important tweak is probably enforcing tab indentation instead of space indentation. I did so to keep the code churn lower as otherwise every single line in the code base would have needed to be touched.
  • I've redone the fixes to comply with the new ruleset (+ some extra).
  • I've updated the PR description to match the new commits.

Note: the change which moved the parse_params_rfc() function to a separate file is no longer needed now, so has been removed.

Comment thread composer.json Outdated
Command used:
```bash
composer-normalize --indent-size=1 --indent-style=tab --profile --no-plugins --no-scripts
```
This commit:
* Adds a new `dev` dependency on PHP Parallel Lint for linting PHP files.
* Adds a Composer script documenting how this should be run.
* Adds a GitHub Actions workflow to run PHP linting against all supported PHP versions.
* Ensures that no `composer.lock` file will be created by default.
* Ensures that a potentially pre-existing `composer.lock` file and the `vendor` directory do not get committed to the repo.
As there is now a GH Actions workflow, it should be kept up to date.
This commit:
* Adds new `dev` dependencies on PHPCompatibility and PHP_CodeSniffer.
* Adds a PHPCS configuration file to use PSR-12 with some tweaks (tab-indent instead of spaces + a few extra rules).
* Adds Composer scripts documenting how this should be run.
* Adds a GitHub Actions job to run PHPCS on all commits.
* Ensures that local overrides of the PHPCS config do not get committed to the repo.
@jrfnl jrfnl force-pushed the feature/add-minimal-ci branch from 3084f5e to 17146ac Compare September 20, 2025 03:18
@jrfnl
Copy link
Copy Markdown
Contributor Author

jrfnl commented Sep 20, 2025

Force pushed without changes as I want to see a build against the current PHP 8.5 ;-)

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.

2 participants