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

GH Actions: switch over to parallel linting of PHP files #653

Merged
merged 1 commit into from
Apr 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions .github/workflows/basics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ jobs:
coverage: none
tools: cs2pr

- name: 'Lint PHP against parse errors'
run: ./bin/php-lint

- name: Install xmllint
run: sudo apt-get install --no-install-recommends -y libxml2-utils

Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,45 @@ on:
workflow_dispatch:

jobs:
#### PHP LINT STAGE ####
# Linting against high/low PHP versions should catch everything.
# If needs be, we can always add interim versions at a later point in time.
lint:
runs-on: ubuntu-latest

strategy:
matrix:
php: ['5.4', 'latest']
experimental: [false]

include:
- php: '8.1'
experimental: true

name: "Lint: PHP ${{ matrix.php }}"
continue-on-error: ${{ matrix.experimental }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
tools: cs2pr

- name: Install Composer dependencies
uses: "ramsey/composer-install@v1"

- name: Lint against parse errors
run: ./bin/php-lint --checkstyle | cs2pr

test:
# No use running the tests if there is a linting error somewhere as they would fail anyway.
needs: lint

runs-on: ubuntu-latest

strategy:
Expand Down
14 changes: 1 addition & 13 deletions bin/php-lint
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,9 @@
#
# Lint the PHP files against parse errors.
#
# The find utility recursively descends the directory tree for each path listed.
#
# find . = Start with all files in this package
# -path ./vendor -prune = But remove those in the vendor directory
# -o -path ./bin -prune = And remove those in the bin directory
# -o -path ./.git -prune = And remove those in the .git directory
# -o -name "*.php" = And only consider those with a .php extension
# -exec php -l {} = Run PHP linter on the remaining files
# | grep "^[Parse error|Fatal error]" = Look in the results for any parse or fatal errors.
#
# EXAMPLE TO RUN LOCALLY:
#
# ./bin/php-lint
#

if find . -path ./vendor -prune -o -path ./bin -prune -o -path ./.git -prune -o -name "*.php" -exec php -l -f {} \; | grep "^[Errors parsing]"; then
exit 1;
fi
"$(pwd)/vendor/bin/parallel-lint" . -e php --exclude vendor --exclude .git $@
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"wp-coding-standards/wpcs": "^2.3"
},
"require-dev": {
"php-parallel-lint/php-parallel-lint": "^1.0",
"php-parallel-lint/php-console-highlighter": "^0.5",
"phpcompatibility/php-compatibility": "^9",
"phpunit/phpunit": "^4 || ^5 || ^6 || ^7"
},
Expand Down