Skip to content

Commit

Permalink
[github-actions] [static-analysis] [CI] Add static analysis & phpcs t…
Browse files Browse the repository at this point in the history
…ools for supported PHP versions 5.6-8.0+. (#646)

* [github-actions] [static-analysis] [CI] Add static analysis & phpcs tools for supported PHP versions 5.6-8.0+.

* [github-actions] Remove specific branch actions test.

---------

Co-authored-by: Laurence Bahiirwa <[email protected]>
  • Loading branch information
bahiirwa and bahiirwa authored Jul 19, 2023
1 parent cae9b55 commit 55045c9
Show file tree
Hide file tree
Showing 15 changed files with 678 additions and 103 deletions.
19 changes: 0 additions & 19 deletions .codeclimate.yml

This file was deleted.

9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*.yml]
indent_style = space
indent_size = 2

[*.neon]
indent_style = space
indent_size = 4
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ composer.lock export-ignore
/assets/scss/ export-ignore
*.css.map export-ignore
phpcs.xml export-ignore
.phpstan export-ignore

# Declare files that will always have CRLF line endings on checkout.
#*.php text eol=crlf
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Run CI tests via Github.
name: PHPCS and Static Analysis.

on:
pull_request:
branches:
- develop
- master

jobs:
run:
runs-on: ubuntu-latest
name: PHPCS
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
php: [ '7.4', '8.0', '8.1', '8.2' ]
experimental: [false]

steps:
- name: Checkout
uses: actions/checkout@v3

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

- name: Install dependencies
uses: ramsey/composer-install@v2
with:
composer-options: "--no-progress --no-ansi --no-interaction"
dependency-versions: "lowest"

- name: Log debug information
run: |
php --version
composer --version
- name: PHP Static Analysis
run: composer phpstan

- name: Run PHPCS
run: composer phpcs:ci
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ transifex-config.json
npm-debug.log
package-lock.json
vendor
.DS_Store
.DS_Store
error-phpstan.xml
error-phpcs.log
16 changes: 16 additions & 0 deletions .phpstan/exceptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* Hold classes and constants to be ignored in PHPStan checks.
*
* @see: https://phpstan.org/user-guide/discovering-symbols
*/

// Constants.
define( 'WP_FS__SCRIPT_START_TIME', 1 );
define( 'WP_PLUGIN_DIR', dirname( __FILE__, 2) );
define( 'WP_FS__SDK_VERSION', 1 );
define( 'WP_LANG_DIR', dirname( __FILE__, 2) . 'languages' );
define( 'WP_FS__REMOTE_ADDR', 1 );
define( 'WP_CONTENT_DIR', dirname( __FILE__, 3) );

// Classes.
24 changes: 18 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,31 @@
"homepage": "https://freemius.com",
"license": "GPL-3.0-only",
"scripts": {
"lint": ["Composer\\Config::disableProcessTimeout", "phpcs -p -s --colors"],
"lint-fix": ["Composer\\Config::disableProcessTimeout", "phpcbf -p -s --colors"]
"phpcs": ["Composer\\Config::disableProcessTimeout", "phpcs -p -s --colors"],
"phpcs:ci": ["Composer\\Config::disableProcessTimeout", "phpcs --standard=phpcompat.xml -p -s --colors"],
"phpstan": "./vendor/bin/phpstan analyse phpstan.neon --memory-limit 2G",
"phpstan:log": "./vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 2G > error-phpstan.xml"
},
"require": {
"php": ">=5.2"
},
"php": ">=5.6"
},
"require-dev": {
"wp-coding-standards/wpcs": "^2.3",
"dealerdirect/phpcodesniffer-composer-installer": "^1.0"
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"squizlabs/php_codesniffer": "^3.7",
"phpcompatibility/php-compatibility": "^9.3",
"phpcompatibility/phpcompatibility-wp": "^2.1",
"szepeviktor/phpstan-wordpress": "^1.3",
"phpstan/extension-installer": "^1.3"
},
"prefer-stable": true,
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpstan/extension-installer": true
},
"platform": {
"php": "8.0"
}
}
}
Loading

0 comments on commit 55045c9

Please sign in to comment.