diff --git a/.github/workflows/basics.yml b/.github/workflows/basics.yml index 84b6d850..30877ebf 100644 --- a/.github/workflows/basics.yml +++ b/.github/workflows/basics.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2ea218da..83ffda75 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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: diff --git a/bin/php-lint b/bin/php-lint index 4da761cf..0528ec77 100755 --- a/bin/php-lint +++ b/bin/php-lint @@ -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 $@ diff --git a/composer.json b/composer.json index 9f6a5daf..cd0606cd 100644 --- a/composer.json +++ b/composer.json @@ -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" },