|
1 | | -# When a PR is opened or a push is made, perform |
2 | | -# a static analysis check on the code using PHPStan. |
3 | 1 | name: PHPStan |
4 | 2 |
|
5 | 3 | on: |
6 | 4 | pull_request: |
7 | 5 | branches: |
8 | | - - 'develop' |
| 6 | + - develop |
9 | 7 | paths: |
10 | | - - 'src/**' |
11 | | - - 'tests/**' |
12 | | - - 'composer.**' |
| 8 | + - '**.php' |
| 9 | + - 'composer.*' |
13 | 10 | - 'phpstan*' |
14 | | - - '.github/workflows/analyze.yml' |
| 11 | + - '.github/workflows/phpstan.yml' |
15 | 12 | push: |
16 | 13 | branches: |
17 | | - - 'develop' |
| 14 | + - develop |
18 | 15 | paths: |
19 | | - - 'src/**' |
20 | | - - 'tests/**' |
21 | | - - 'composer.**' |
| 16 | + - '**.php' |
| 17 | + - 'composer.*' |
22 | 18 | - 'phpstan*' |
23 | | - - '.github/workflows/analyze.yml' |
| 19 | + - '.github/workflows/phpstan.yml' |
24 | 20 |
|
25 | 21 | jobs: |
26 | 22 | build: |
27 | 23 | name: PHP ${{ matrix.php-versions }} Static Analysis |
28 | 24 | runs-on: ubuntu-latest |
| 25 | + if: "!contains(github.event.head_commit.message, '[ci skip]')" |
29 | 26 | strategy: |
30 | 27 | fail-fast: false |
31 | 28 | matrix: |
32 | | - php-versions: ['7.3', '7.4', '8.0'] |
| 29 | + php-versions: ['7.4', '8.0', '8.1'] |
| 30 | + |
33 | 31 | steps: |
34 | 32 | - name: Checkout |
35 | | - uses: actions/checkout@v2 |
| 33 | + uses: actions/checkout@v3 |
36 | 34 |
|
37 | 35 | - name: Setup PHP |
38 | 36 | uses: shivammathur/setup-php@v2 |
39 | 37 | with: |
40 | 38 | php-version: ${{ matrix.php-versions }} |
41 | | - tools: composer, pecl, phpunit |
42 | | - extensions: intl, json, mbstring, gd, mysqlnd, xdebug, xml, sqlite3 |
| 39 | + tools: phpstan, phpunit |
| 40 | + extensions: intl, json, mbstring, xml |
| 41 | + coverage: none |
| 42 | + env: |
| 43 | + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
43 | 44 |
|
44 | 45 | - name: Get composer cache directory |
45 | 46 | id: composer-cache |
46 | 47 | run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
47 | 48 |
|
48 | | - - name: Create composer cache directory |
49 | | - run: mkdir -p ${{ steps.composer-cache.outputs.dir }} |
50 | | - |
51 | 49 | - name: Cache composer dependencies |
52 | | - uses: actions/cache@v2 |
| 50 | + uses: actions/cache@v3 |
53 | 51 | with: |
54 | 52 | path: ${{ steps.composer-cache.outputs.dir }} |
55 | | - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} |
| 53 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }} |
56 | 54 | restore-keys: ${{ runner.os }}-composer- |
57 | 55 |
|
58 | 56 | - name: Create PHPStan cache directory |
59 | 57 | run: mkdir -p build/phpstan |
60 | 58 |
|
61 | 59 | - name: Cache PHPStan results |
62 | | - uses: actions/cache@v2 |
| 60 | + uses: actions/cache@v3 |
63 | 61 | with: |
64 | 62 | path: build/phpstan |
65 | 63 | key: ${{ runner.os }}-phpstan-${{ github.sha }} |
66 | 64 | restore-keys: ${{ runner.os }}-phpstan- |
67 | 65 |
|
68 | 66 | - name: Install dependencies |
69 | | - run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader |
70 | | - env: |
71 | | - COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }} |
| 67 | + run: | |
| 68 | + if [ -f composer.lock ]; then |
| 69 | + composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader |
| 70 | + else |
| 71 | + composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader |
| 72 | + fi |
72 | 73 |
|
73 | 74 | - name: Run static analysis |
74 | 75 | run: vendor/bin/phpstan analyze |
0 commit comments