diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 7ea972e..fd086b5 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -1,13 +1,13 @@ 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 => 8.1 + name: PHP Syntax check 5.6|7.2|7.3|7.4|8.0|8.1 runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3.1.0 + uses: actions/checkout@v5 - name: PHP syntax checker 5.6 uses: prestashop/github-action-php-lint/5.6@master @@ -27,38 +27,43 @@ jobs: - 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 + - uses: PrestaShop/.github/.github/actions/php-ci/php-cs@master with: php-version: '7.4' - - name: Checkout - uses: actions/checkout@v3.1.0 - - - name: Cache dependencies - uses: actions/cache@v3 + phpstan: + name: PHPStan + runs-on: ubuntu-latest + strategy: + matrix: + presta-version: ['1.7.7.x', '1.7.8.x'] + steps: + - name: Checkout repository + uses: actions/checkout@v5 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 + path: ${{ github.event.repository.name }} + + - uses: Quetzacoalt91/.github/.github/actions/php-ci/phpstan@cache + with: + php-version: '7.4' + presta-version: ${{ matrix.presta-version }} + module-name: ${{ github.event.repository.name }} + phpstan-level: '5' + phpstan-config: 'tests/phpstan/phpstan-${{ matrix.presta-version }}.neon' + phpstan-version: '^0.12' + composer-version: '2' # Run PHPStan against the module and a PrestaShop release - phpstan: + phpstan-legacy: 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'] + 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'] steps: - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -66,21 +71,7 @@ jobs: php-version: '7.4' - name: Checkout - uses: actions/checkout@v3.1.0 - - # Add vendor folder in cache to make next builds faster - - name: Cache vendor folder - uses: actions/cache@v3 - 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@v3 - with: - path: ~/.composer/cache - key: php-composer-cache + uses: actions/checkout@v5 - run: composer install diff --git a/tests/phpstan.sh b/tests/phpstan.sh index 4a94362..f91f0dd 100755 --- a/tests/phpstan.sh +++ b/tests/phpstan.sh @@ -11,11 +11,6 @@ docker volume rm -f ps-volume || true docker run -tid --rm -v ps-volume:/var/www/html --name temp-ps prestashop/prestashop:$PS_VERSION -# Clear previous instance of the module in the PrestaShop volume -echo "Clear previous module" - -docker exec -t temp-ps rm -rf /var/www/html/modules/ps_mainmenu - # Run a container for PHPStan, having access to the module content and PrestaShop sources. # This tool is outside the composer.json because of the compatibility with PHP 5.6 echo "Run PHPStan using phpstan-${PS_VERSION}.neon file" diff --git a/tests/phpstan/phpstan-1.7.7.neon b/tests/phpstan/phpstan-1.7.7.neon deleted file mode 100644 index 8daaf0a..0000000 --- a/tests/phpstan/phpstan-1.7.7.neon +++ /dev/null @@ -1,9 +0,0 @@ -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 given.#' diff --git a/tests/phpstan/phpstan-1.7.8.neon b/tests/phpstan/phpstan-1.7.8.neon deleted file mode 100644 index 8180fd3..0000000 --- a/tests/phpstan/phpstan-1.7.8.neon +++ /dev/null @@ -1,10 +0,0 @@ -includes: - - %currentWorkingDirectory%/tests/phpstan/phpstan.neon - -parameters: - ignoreErrors: - - '#Access to an undefined property HelperList\:\:\$shopLinkType.#' - - '#Binary operation "\." between string and array results in an error.#' - - '#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 given.#' diff --git a/tests/phpstan/phpstan-latest.neon b/tests/phpstan/phpstan-latest.neon deleted file mode 100644 index 3e0e93c..0000000 --- a/tests/phpstan/phpstan-latest.neon +++ /dev/null @@ -1,2 +0,0 @@ -includes: - - %currentWorkingDirectory%/tests/phpstan/phpstan.neon