|
1 | 1 | name: PHP tests |
2 | 2 | on: [push, pull_request] |
3 | 3 | jobs: |
| 4 | + # Check there is no syntax errors in the project |
4 | 5 | php-linter: |
5 | | - name: PHP Syntax check 5.6|7.2|7.3 |
| 6 | + name: PHP Syntax check 5.6 => 8.1 |
6 | 7 | runs-on: ubuntu-latest |
7 | 8 | steps: |
8 | 9 | - name: Checkout |
9 | 10 | uses: actions/checkout@v2.0.0 |
| 11 | + |
10 | 12 | - name: PHP syntax checker 5.6 |
11 | 13 | uses: prestashop/github-action-php-lint/5.6@master |
| 14 | + |
12 | 15 | - name: PHP syntax checker 7.2 |
13 | 16 | uses: prestashop/github-action-php-lint/7.2@master |
| 17 | + |
14 | 18 | - name: PHP syntax checker 7.3 |
15 | 19 | uses: prestashop/github-action-php-lint/7.3@master |
| 20 | + |
| 21 | + - name: PHP syntax checker 7.4 |
| 22 | + uses: prestashop/github-action-php-lint/7.4@master |
| 23 | + |
| 24 | + - name: PHP syntax checker 8.0 |
| 25 | + uses: prestashop/github-action-php-lint/8.0@master |
| 26 | + |
| 27 | + - name: PHP syntax checker 8.1 |
| 28 | + uses: prestashop/github-action-php-lint/8.1@master |
| 29 | + |
| 30 | + # Check the PHP code follow the coding standards |
16 | 31 | php-cs-fixer: |
17 | 32 | name: PHP-CS-Fixer |
18 | 33 | runs-on: ubuntu-latest |
19 | 34 | steps: |
| 35 | + - name: Setup PHP |
| 36 | + uses: shivammathur/setup-php@v2 |
| 37 | + with: |
| 38 | + php-version: '7.4' |
| 39 | + |
20 | 40 | - name: Checkout |
21 | 41 | uses: actions/checkout@v2.0.0 |
| 42 | + |
| 43 | + - name: Cache dependencies |
| 44 | + uses: actions/cache@v2 |
| 45 | + with: |
| 46 | + path: vendor |
| 47 | + key: php-${{ hashFiles('composer.lock') }} |
| 48 | + |
| 49 | + - name: Install dependencies |
| 50 | + run: composer install |
| 51 | + |
22 | 52 | - name: Run PHP-CS-Fixer |
23 | | - uses: prestashopcorp/github-action-php-cs-fixer@master |
| 53 | + run: ./vendor/bin/php-cs-fixer fix --dry-run --diff --using-cache=no --diff-format udiff |
| 54 | + |
| 55 | + # Run PHPStan against the module and a PrestaShop release |
24 | 56 | phpstan: |
25 | 57 | name: PHPStan |
26 | 58 | runs-on: ubuntu-latest |
27 | 59 | strategy: |
28 | 60 | matrix: |
29 | | - presta-versions: ['latest', '1.7.0.3', '1.6.1.21','1.6.1.0'] |
| 61 | + presta-versions: ['1.6.1.18', '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'] |
30 | 62 | steps: |
| 63 | + - name: Setup PHP |
| 64 | + uses: shivammathur/setup-php@v2 |
| 65 | + with: |
| 66 | + php-version: '7.4' |
| 67 | + |
31 | 68 | - name: Checkout |
32 | 69 | uses: actions/checkout@v2.0.0 |
33 | 70 |
|
| 71 | + # Add vendor folder in cache to make next builds faster |
34 | 72 | - name: Cache vendor folder |
35 | 73 | uses: actions/cache@v1 |
36 | 74 | with: |
37 | 75 | path: vendor |
38 | 76 | key: php-${{ hashFiles('composer.lock') }} |
39 | 77 |
|
| 78 | + # Add composer local folder in cache to make next builds faster |
40 | 79 | - name: Cache composer folder |
41 | 80 | uses: actions/cache@v1 |
42 | 81 | with: |
|
45 | 84 |
|
46 | 85 | - run: composer install |
47 | 86 |
|
48 | | - - name: Pull PrestaShop files (Tag ${{ matrix.presta-versions }}) |
49 | | - run: docker run -tid --rm -v ps-volume:/var/www/html --name temp-ps prestashop/prestashop:${{ matrix.presta-versions }} |
50 | | - |
51 | | - - name: Select .neon file to run with PHPStan |
52 | | - id: neon |
53 | | - run: | |
54 | | - PS_VERSION=$(docker exec temp-ps bash -c 'echo "$PS_VERSION"') |
55 | | - [[ "${PS_VERSION:0:3}" != '1.7' ]] && echo ::set-output name=filename::phpstan-PS-1.6.neon || echo ::set-output name=filename::phpstan-PS-1.7.neon |
56 | | -
|
57 | | - - name : Run PHPStan |
58 | | - run: docker run --rm --volumes-from temp-ps -v $PWD:/web/module -e _PS_ROOT_DIR_=/var/www/html --workdir=/web/module phpstan/phpstan:0.12 analyse --configuration=/web/module/tests/phpstan/${{steps.neon.outputs.filename}} |
| 87 | + # Docker images prestashop/prestashop may be used, even if the shop remains uninstalled |
| 88 | + - name: Execute PHPStan on PrestaShop (Tag ${{ matrix.presta-versions }}) |
| 89 | + run: ./tests/phpstan.sh ${{ matrix.presta-versions }} |
0 commit comments