Add check on headers #4237
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PHP tests | |
on: [push, pull_request] | |
concurrency: | |
group: ${{ github.event_name }}-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
# Check there is no syntax errors in the project | |
php-linter: | |
name: PHP Syntax check 7.1 => 8.1 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4.1.3 | |
- name: PHP syntax checker 7.1 | |
uses: prestashop/github-action-php-lint/7.1@master | |
with: | |
folder-to-exclude: "! -path \"./.github/*\"" | |
- name: PHP syntax checker 7.2 | |
uses: prestashop/github-action-php-lint/7.2@master | |
with: | |
folder-to-exclude: "! -path \"./.github/*\"" | |
- name: PHP syntax checker 7.3 | |
uses: prestashop/github-action-php-lint/7.3@master | |
with: | |
folder-to-exclude: "! -path \"./.github/*\"" | |
- name: PHP syntax checker 7.4 | |
uses: prestashop/github-action-php-lint/7.4@master | |
with: | |
folder-to-exclude: "! -path \"./.github/*\"" | |
- name: PHP syntax checker 8.0 | |
uses: prestashop/github-action-php-lint/8.0@master | |
with: | |
folder-to-exclude: "! -path \"./.github/*\"" | |
- name: PHP syntax checker 8.1 | |
uses: prestashop/github-action-php-lint/8.1@master | |
with: | |
folder-to-exclude: "! -path \"./.github/*\"" | |
# 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.1' | |
- name: Checkout | |
uses: actions/checkout@v4.1.3 | |
- name: Cache dependencies | |
uses: actions/cache@v4.0.2 | |
with: | |
path: vendor | |
key: php-${{ hashFiles('composer.lock') }} | |
- name: Composer Install | |
run: composer install --prefer-dist | |
- name: Run PHP-CS-Fixer | |
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff --using-cache=no | |
php-unit: | |
strategy: | |
matrix: | |
php-versions: ['7.1', '7.2','7.4','8.1'] | |
runs-on: ubuntu-latest | |
name: PHP Unit | |
steps: | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-versions }} | |
extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv, ext-zip | |
- uses: actions/checkout@v4.1.3 | |
with: | |
fetch-depth: 0 | |
- run: composer install --prefer-dist | |
- run: ./vendor/phpunit/phpunit/phpunit tests | |
# Run PHPStan against the module and a PrestaShop release | |
phpstan: | |
name: PHPStan | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
presta-versions: ['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', '8.0.0', 'latest'] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4.1.3 | |
- run: composer install | |
- run: composer install | |
working-directory: ./tests | |
- name: Execute PHPStan on PrestaShop (Tag ${{ matrix.presta-versions }}) | |
run: bash tests/phpstan/phpstan.sh ${{ matrix.presta-versions }} --error-format=github | |
# Some scripts must be compatible with PHP 5.6 to display that the PHP version is incompatible | |
check-php5-scripts: | |
runs-on: ubuntu-latest | |
name: PHP 5.6 Syntax Check | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4.1.3 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 5.6 | |
- name: Check files syntax | |
run: | | |
for file in autoupgrade.php controllers/admin/AdminSelfUpgradeController.php classes/VersionUtils.php classes/UpgradeTools/Translator.php; do | |
php -l $file; | |
done | |
header-stamp: | |
name: Check license headers | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup PHP 8.3 | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.3' | |
- run: composer install | |
- name: Run Header Stamp in Dry Run mode | |
run: | | |
php vendor/bin/header-stamp --license=tests/vendor/prestashop/header-stamp/assets/afl.txt --exclude=vendor,tests,_dev --dry-run || { | |
echo "::error::Some headers are missing or incorrect. Run 'vendor/bin/header-stamp --license=tests/vendor/prestashop/header-stamp/assets/afl.txt --exclude=vendor,tests,_dev' to autofix them." | |
exit 1 | |
} |