Skip to content

Commit 9d79ad3

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 2d2d7a1 + 777e90e commit 9d79ad3

File tree

4 files changed

+122
-31
lines changed

4 files changed

+122
-31
lines changed

.github/workflows/phan.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Phan
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
pull_request:
9+
10+
jobs:
11+
run:
12+
name: Run Phan
13+
runs-on: 'ubuntu-latest'
14+
steps:
15+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
16+
17+
- name: Setup PHP
18+
uses: shivammathur/setup-php@0f7f1d08e3e32076e51cae65eb0b0c871405b16e # v2.34.1
19+
with:
20+
php-version: '8.4'
21+
tools: phan
22+
coverage: none
23+
24+
- name: Restore cached baseline for Phan
25+
id: cache-baseline-restore
26+
uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
27+
with:
28+
path: |
29+
test/phan-baseline.php
30+
key: phan-baseline-${{ github.run_id }}"
31+
restore-keys: |
32+
phan-baseline-
33+
34+
- name: Run Phan
35+
continue-on-error: true
36+
run: |
37+
if [ -f test/phan-baseline.php ]; then
38+
echo "Cached baseline for Phan is found. Running Phan with baseline."
39+
phan -d ./ -k .phan/config.php --load-baseline test/phan-baseline.php --no-progress-bar
40+
else
41+
echo "Cached baseline for Phan is not found. Running Phan without baseline."
42+
phan -d ./ -k .phan/config.php --no-progress-bar
43+
exit 0
44+
fi

.github/workflows/phpstan.yml

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
name: PHPStan
22

3+
permissions:
4+
contents: read
5+
36
on:
47
push:
5-
branches:
6-
- "*"
78
pull_request:
8-
branches: [ 'master', 'main' ]
9-
pull_request_target:
10-
types:
11-
- closed
129

1310
jobs:
1411
run:
@@ -19,17 +16,16 @@ jobs:
1916
level: [ 1, 2 ]
2017
include:
2118
- current-level: 1
22-
- max-level: 2
2319
steps:
2420
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2521

2622
- name: Setup PHP
27-
uses: shivammathur/setup-php@9e72090525849c5e82e596468b86eb55e9cc5401 # v2.32.0
23+
uses: shivammathur/setup-php@0f7f1d08e3e32076e51cae65eb0b0c871405b16e # v2.34.1
2824
with:
2925
php-version: '8.4'
3026

31-
- name: Remove phpDocumentor temporarily and Install PHPStan
32-
run: composer remove --dev --no-update phpdocumentor/phpdocumentor; composer update
27+
- name: Install PHPStan
28+
run: composer install
3329

3430
- name: Restore cached baseline for PHPStan
3531
id: cache-baseline-restore
@@ -42,30 +38,13 @@ jobs:
4238
phpstan-baseline-
4339
4440
- name: Run PHPStan
45-
if: matrix.level == matrix.current-level
46-
continue-on-error: true
41+
if: matrix.level < matrix.current-level || matrix.level == matrix.current-level
4742
run: |
48-
./vendor/bin/phpstan analyse --memory-limit 1G -c test/phpstan.neon src test -l "${{ matrix.level }}"
43+
./vendor/bin/phpstan analyse --memory-limit 1G -c test/phpstan.neon src test -l "${{ matrix.level }}"
4944
5045
- name: Run PHPStan
5146
if: matrix.level > matrix.current-level
5247
continue-on-error: true
5348
run: |
54-
./vendor/bin/phpstan analyse --memory-limit 1G -c test/phpstan.neon src test -l "${{ matrix.level }}"
55-
exit 0
56-
57-
- name: Generate the baseline for PHPStan
58-
if: matrix.level == matrix.max-level && github.event.pull_request.merged == true
59-
continue-on-error: true
60-
run: |
61-
./vendor/bin/phpstan analyse --memory-limit 1G -c test/phpstan.neon --generate-baseline test/phpstan-baseline.neon src test -vvv --debug -l "${{ matrix.level }}"
62-
exit 0
63-
64-
- name: Save the baseline for PHPStan
65-
id: cache-baseline-save
66-
if: matrix.level == matrix.max-level && github.event.pull_request.merged == true
67-
uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
68-
with:
69-
path: |
70-
test/phpstan-baseline.neon
71-
key: phpstan-baseline-${{ github.run_id }}"
49+
./vendor/bin/phpstan analyse --memory-limit 1G -c test/phpstan.neon src test -l "${{ matrix.level }}"
50+
exit 0
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Save Baseline for Phan and PHPStan
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
pull_request:
8+
types:
9+
- closed
10+
11+
jobs:
12+
run:
13+
name: Save Baseline
14+
runs-on: 'ubuntu-latest'
15+
steps:
16+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17+
18+
- name: Setup PHP
19+
uses: shivammathur/setup-php@0f7f1d08e3e32076e51cae65eb0b0c871405b16e # v2.34.1
20+
with:
21+
php-version: '8.4'
22+
tools: phan
23+
coverage: none
24+
25+
- name: Install PHPStan
26+
run: composer install
27+
28+
- name: Generate the baseline for Phan
29+
continue-on-error: true
30+
run: |
31+
phan -d ./ -k .phan/config.php --save-baseline test/phan-baseline.php --no-progress-bar
32+
exit 0
33+
34+
- name: Generate the baseline for PHPStan
35+
continue-on-error: true
36+
run: |
37+
./vendor/bin/phpstan analyse --memory-limit 1G -c test/phpstan.neon --generate-baseline test/phpstan-baseline.neon src test -vvv --debug -l 2
38+
exit 0
39+
40+
- name: Save the baseline for Phan
41+
id: save-the-baseline-for-phan
42+
uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
43+
with:
44+
path: |
45+
test/phan-baseline.php
46+
key: phan-baseline-${{ github.run_id }}"
47+
48+
- name: Save the baseline for PHPStan
49+
id: cache-baseline-save
50+
uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
51+
with:
52+
path: |
53+
test/phpstan-baseline.neon
54+
key: phpstan-baseline-${{ github.run_id }}"

.phan/config.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
return [
5+
'target_php_version' => '8.4',
6+
7+
'directory_list' => [
8+
'src',
9+
],
10+
11+
'exclude_analysis_directory_list' => [
12+
'vendor/'
13+
],
14+
];

0 commit comments

Comments
 (0)