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