Skip to content

Commit

Permalink
Improved Github Action PHP
Browse files Browse the repository at this point in the history
  • Loading branch information
Progi1984 committed Feb 11, 2022
1 parent fa6e998 commit 52e4395
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 93 deletions.
163 changes: 86 additions & 77 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -1,80 +1,89 @@
name: PHP tests
on: [push, pull_request]
jobs:
# Check there is no syntax errors in the project
php-linter:
name: PHP Syntax check 5.6|7.2|7.3
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.0.0

- name: PHP syntax checker 5.6
uses: prestashop/github-action-php-lint/5.6@master

- name: PHP syntax checker 7.2
uses: prestashop/github-action-php-lint/7.2@master

- name: PHP syntax checker 7.3
uses: prestashop/github-action-php-lint/7.3@master

# Check the PHP code follow the coding standards
php-cs-fixer:
name: PHP-CS-Fixer
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'

- name: Checkout
uses: actions/checkout@v2.0.0

- name: Cache dependencies
uses: actions/cache@v2
with:
path: vendor
key: php-${{ hashFiles('composer.lock') }}

- name: Install dependencies
run: composer install

- name: Run PHP-CS-Fixer
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff --using-cache=no --diff-format udiff

# Run PHPStan against the module and a PrestaShop release
phpstan:
name: PHPStan
runs-on: ubuntu-latest
strategy:
matrix:
presta-versions: ['1.7.1.2', '1.7.2.5', '1.7.3.4', '1.7.4.4', '1.7.5.1', '1.7.6.9', '1.7.7.4', 'latest']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'

- name: Checkout
uses: actions/checkout@v2.0.0

# Add vendor folder in cache to make next builds faster
- name: Cache vendor folder
uses: actions/cache@v1
with:
path: vendor
key: php-${{ hashFiles('composer.lock') }}

# Add composer local folder in cache to make next builds faster
- name: Cache composer folder
uses: actions/cache@v1
with:
path: ~/.composer/cache
key: php-composer-cache

- run: composer install

# Docker images prestashop/prestashop may be used, even if the shop remains uninstalled
- name: Execute PHPStan on PrestaShop (Tag ${{ matrix.presta-versions }})
run: ./tests/phpstan.sh ${{ matrix.presta-versions }}
# Check there is no syntax errors in the project
php-linter:
name: PHP Syntax check 5.6 => 8.1
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.0.0

- name: PHP syntax checker 5.6
uses: prestashop/github-action-php-lint/5.6@master

- name: PHP syntax checker 7.2
uses: prestashop/github-action-php-lint/7.2@master

- name: PHP syntax checker 7.3
uses: prestashop/github-action-php-lint/7.3@master

- name: PHP syntax checker 7.4
uses: prestashop/github-action-php-lint/7.4@master

- name: PHP syntax checker 8.0
uses: prestashop/github-action-php-lint/8.0@master

- name: PHP syntax checker 8.1
uses: prestashop/github-action-php-lint/8.1@master

# Check the PHP code follow the coding standards
php-cs-fixer:
name: PHP-CS-Fixer
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'

- name: Checkout
uses: actions/checkout@v2.0.0

- name: Cache dependencies
uses: actions/cache@v2
with:
path: vendor
key: php-${{ hashFiles('composer.lock') }}

- name: Install dependencies
run: composer install

- name: Run PHP-CS-Fixer
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff --using-cache=no --diff-format udiff

# Run PHPStan against the module and a PrestaShop release
phpstan:
name: PHPStan
runs-on: ubuntu-latest
strategy:
matrix:
presta-versions: ['1.7.1.2', '1.7.2.5', '1.7.3.4', '1.7.4.4', '1.7.5.1', '1.7.6', '1.7.7', '1.7.8', 'latest']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'

- name: Checkout
uses: actions/checkout@v2.0.0

# Add vendor folder in cache to make next builds faster
- name: Cache vendor folder
uses: actions/cache@v1
with:
path: vendor
key: php-${{ hashFiles('composer.lock') }}

# Add composer local folder in cache to make next builds faster
- name: Cache composer folder
uses: actions/cache@v1
with:
path: ~/.composer/cache
key: php-composer-cache

- run: composer install

# Docker images prestashop/prestashop may be used, even if the shop remains uninstalled
- name: Execute PHPStan on PrestaShop (Tag ${{ matrix.presta-versions }})
run: ./tests/phpstan.sh ${{ matrix.presta-versions }}
2 changes: 1 addition & 1 deletion ps_mainmenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ protected function makeMenuOption()
case 'CMS_CAT':
$category = new CMSCategory((int) $id, (int) $id_lang);
if (Validate::isLoadedObject($category)) {
$html .= '<option selected="selected" value="CMS_CAT' . $id . '">' . $category->name . '</option>' . PHP_EOL;
$html .= '<option selected="selected" value="CMS_CAT' . $id . '">' . (string) $category->name . '</option>' . PHP_EOL;
}
break;

Expand Down
2 changes: 0 additions & 2 deletions tests/phpstan/phpstan-1.7.1.2.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ includes:
parameters:
ignoreErrors:
- '#Access to an undefined property HelperList\:\:\$shopLinkType.#'
- '#Access to protected property HelperForm\:\:\$fields_form.#'
- '#Call to method assign\(\) on an unknown class Smarty_Data.#'
- '#Parameter \#1 \$id of class Supplier constructor expects null, int given.#'
- '#Parameter \#1 \$idCategory of class Category constructor expects null, int given.#'
- '#Parameter \#2 \$idLang of class Category constructor expects null, int given.#'
- '#Parameter \#2 \$idLang of class Supplier constructor expects null, int given.#'
- '#Parameter \#2 \$selection of static method CMSCore\:\:getLinks\(\) expects null, array<int, int> given.#'
- '#Parameter \#2 \$value of static method CacheCore\:\:store\(\) expects string, array<int\|string, mixed> given.#'
2 changes: 0 additions & 2 deletions tests/phpstan/phpstan-1.7.2.5.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ includes:
parameters:
ignoreErrors:
- '#Access to an undefined property HelperList\:\:\$shopLinkType.#'
- '#Access to protected property HelperForm\:\:\$fields_form.#'
- '#Call to method assign\(\) on an unknown class Smarty_Data.#'
- '#Parameter \#1 \$id of class Supplier constructor expects null, int given.#'
- '#Parameter \#1 \$idCategory of class Category constructor expects null, int given.#'
- '#Parameter \#2 \$idLang of class Category constructor expects null, int given.#'
- '#Parameter \#2 \$idLang of class Supplier constructor expects null, int given.#'
- '#Parameter \#2 \$selection of static method CMSCore\:\:getLinks\(\) expects null, array<int, int> given.#'
- '#Parameter \#2 \$value of static method CacheCore\:\:store\(\) expects string, array<int\|string, mixed> given.#'
1 change: 0 additions & 1 deletion tests/phpstan/phpstan-1.7.3.4.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ includes:
parameters:
ignoreErrors:
- '#Access to an undefined property HelperList\:\:\$shopLinkType.#'
- '#Access to protected property HelperForm\:\:\$fields_form.#'
- '#Call to method assign\(\) on an unknown class Smarty_Data.#'
- '#Parameter \#1 \$id of class Supplier constructor expects null, int given.#'
- '#Parameter \#1 \$idCategory of class Category constructor expects null, int given.#'
Expand Down
2 changes: 0 additions & 2 deletions tests/phpstan/phpstan-1.7.4.4.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ includes:
parameters:
ignoreErrors:
- '#Access to an undefined property HelperList\:\:\$shopLinkType.#'
- '#Access to protected property HelperForm\:\:\$fields_form.#'
- '#Call to method assign\(\) on an unknown class Smarty_Data.#'
- '#Parameter \#1 \$id of class Supplier constructor expects null, int given.#'
- '#Parameter \#1 \$idCategory of class Category constructor expects null, int given.#'
- '#Parameter \#2 \$idLang of class Category constructor expects null, int given.#'
Expand Down
1 change: 0 additions & 1 deletion tests/phpstan/phpstan-1.7.5.1.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ includes:
parameters:
ignoreErrors:
- '#Access to an undefined property HelperList\:\:\$shopLinkType.#'
- '#Access to protected property HelperForm\:\:\$fields_form.#'
- '#Parameter \#1 \$id of class Supplier constructor expects null, int given.#'
- '#Parameter \#1 \$idCategory of class Category constructor expects null, int given.#'
- '#Parameter \#2 \$idLang of class Category constructor expects null, int given.#'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ includes:
parameters:
ignoreErrors:
- '#Access to an undefined property HelperList\:\:\$shopLinkType.#'
- '#Access to protected property HelperForm\:\:\$fields_form.#'
- '#Parameter \#1 \$id of class Supplier constructor expects null, int given.#'
- '#Parameter \#1 \$idCategory of class Category constructor expects null, int given.#'
- '#Parameter \#2 \$idLang of class Category constructor expects null, int given.#'
- '#Parameter \#2 \$idLang of class Supplier constructor expects null, int given.#'
- '#Parameter \#2 \$selection of static method CMSCore\:\:getLinks\(\) expects null, array<int, int> given.#'
- '#Parameter \#2 \$value of static method CacheCore\:\:store\(\) expects string, array<int\|string, mixed> given.#'
- '#Parameter \#2 \$value of static method CacheCore\:\:store\(\) expects string, array<int\|string, mixed> given.#'
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ includes:
parameters:
ignoreErrors:
- '#Access to an undefined property HelperList\:\:\$shopLinkType.#'
- '#Access to protected property HelperForm\:\:\$fields_form.#'
- '#Parameter \#1 \$id of class Supplier constructor expects null, int given.#'
- '#Parameter \#2 \$idLang of class Supplier constructor expects null, int given.#'
- '#Parameter \#2 \$selection of static method CMSCore\:\:getLinks\(\) expects null, array<int, int> given.#'
9 changes: 9 additions & 0 deletions tests/phpstan/phpstan-1.7.8.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
includes:
- %currentWorkingDirectory%/tests/phpstan/phpstan.neon

parameters:
ignoreErrors:
- '#Access to an undefined property HelperList\:\:\$shopLinkType.#'
- '#Parameter \#1 \$id of class Supplier constructor expects null, int given.#'
- '#Parameter \#2 \$idLang of class Supplier constructor expects null, int given.#'
- '#Parameter \#2 \$selection of static method CMSCore\:\:getLinks\(\) expects null, array<int, int> given.#'
2 changes: 0 additions & 2 deletions tests/phpstan/phpstan-latest.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ includes:
parameters:
ignoreErrors:
- '#Access to an undefined property HelperList\:\:\$shopLinkType.#'
- '#Access to protected property HelperForm\:\:\$fields_form.#'
- '#Parameter \#1 \$id of class Supplier constructor expects null, int given.#'
- '#Parameter \#2 \$idLang of class Supplier constructor expects null, int given.#'
- '#Parameter \#2 \$selection of static method CMSCore\:\:getLinks\(\) expects null, array<int, int> given.#'
- '~^Binary operation "\." between string and array<string> results in an error\.$~'
2 changes: 0 additions & 2 deletions tests/phpstan/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ parameters:
- ../../ps_menutoplinks.class.php
- ../../translations/
- ../../views/
reportUnmatchedIgnoredErrors: false
level: 5

0 comments on commit 52e4395

Please sign in to comment.