Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PHP linter and PHP linting in GitHub Actions #109

Merged
merged 17 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
609203b
Add linter for PHP.
eason9487 Apr 18, 2024
4346284
Resolve PHP linting errors can be fixed automatically by `phpcbf`.
eason9487 Apr 18, 2024
01eb6c0
Fix a PHP linting error for rule `Generic.CodeAnalysis.UnusedFunction…
eason9487 Apr 18, 2024
45eb24c
Fix PHP linting errors for rule `WordPress.DateTime.RestrictedFunctio…
eason9487 Apr 18, 2024
22e96d4
Fix PHP linting errors for rule `Squiz.Commenting.FunctionComment.Mis…
eason9487 Apr 18, 2024
3c10f7e
Fix PHP linting errors for rule `Squiz.Commenting.FunctionCommentThro…
eason9487 Apr 18, 2024
0d8aa51
Fix a PHP linting error for rule `Squiz.Commenting.FunctionComment.Th…
eason9487 Apr 18, 2024
d303789
Fix PHP linting errors for rule `WordPress.NamingConventions.ValidVar…
eason9487 Apr 18, 2024
fc678a1
Fix PHP linting errors for rule `WordPress.WP.AlternativeFunctions.fi…
eason9487 Apr 18, 2024
c97006b
Fix a PHP linting error for rule `WordPress.WP.AlternativeFunctions.f…
eason9487 Apr 18, 2024
a291f29
Fix a PHP linting error for rule `Generic.CodeAnalysis.AssignmentInCo…
eason9487 Apr 18, 2024
01ef9a2
Fix a PHP linting error for rule `PSR12.Properties.ConstantVisibility…
eason9487 Apr 18, 2024
03f873a
Fix a PHP linting error for rule `Squiz.Classes.ClassFileName.NoMatch`.
eason9487 Apr 18, 2024
5643ec9
Fix PHP linting errors for rule `Squiz.PHP.CommentedOutCode.Found`.
eason9487 Apr 18, 2024
f2fd792
Fix a PHP linting error for rule `Squiz.Commenting.FunctionComment.Pa…
eason9487 Apr 18, 2024
57bcac4
Fix a PHP linting error for rule `WordPress.NamingConventions.ValidFu…
eason9487 Apr 18, 2024
4673ff7
Add the PHP linting badge to README.
eason9487 Apr 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/php-coding-standards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: PHP Coding Standards

on:
push:
branches:
- "trunk"
paths:
- "**.php"
- .github/workflows/php-coding-standards.yml
pull_request:
paths:
- "**.php"
- .github/workflows/php-coding-standards.yml

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
phpcs:
name: PHP coding standards
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
Copy link
Member

@ianlin ianlin Apr 19, 2024

Choose a reason for hiding this comment

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

Just curious can we use checkout@v4 (using Node.js v20 runtime)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Considering the current .nvmrc is still lts/fermium (v14), I plan to update it along with the work for #108.


- name: Prepare PHP
uses: woocommerce/grow/prepare-php@actions-v1
with:
php-version: 7.4
tools: cs2pr
install-deps: "no"

- name: Install Composer dependencies
run: |
# Skip installing packages from private repos.
composer remove --dev woocommerce/woorelease
composer install --prefer-dist --no-interaction

- name: Log PHPCS information
run: vendor/bin/phpcs -i

- name: Run PHPCS on all files
run: vendor/bin/phpcs -q --report=checkstyle | cs2pr
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Grow Packages

[![JavaScript Linting](https://github.com/woocommerce/grow/actions/workflows/js-linting.yml/badge.svg)](https://github.com/woocommerce/grow/actions/workflows/js-linting.yml)
[![PHP Coding Standards](https://github.com/woocommerce/grow/actions/workflows/php-coding-standards.yml/badge.svg)](https://github.com/woocommerce/grow/actions/workflows/php-coding-standards.yml)

This repository is a container for packages, mostly dev tools to serve the Grow Team.
The packages here are too experimental or too Grow-specific to be shared Woo-wide.
Expand Down
9 changes: 8 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"phpcompatibility/php-compatibility": "^9.0",
"php-parallel-lint/php-parallel-lint": "^1.3.1",
"woocommerce/woorelease": "^2.4",
"yoast/phpunit-polyfills": "^1.0"
"yoast/phpunit-polyfills": "^1.0",
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"wp-coding-standards/wpcs": "^3.0"
},
"repositories": [
{
Expand All @@ -38,5 +40,10 @@
"scripts-descriptions": {
"assumeReleaseUnchanged": "Tell Git to assume that the 'release.txt' file is unchanged. This allows changes in this file to be ignored by Git.",
"noAssumeReleaseUnchanged": "Tell Git to stop assuming that the 'release.txt' file is unchanged, and track it normally."
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
297 changes: 296 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading