Skip to content

Commit 777e90e

Browse files
authored
Merge pull request #120 from matsuo/add-workflow-to-save-baseline-for-phan-and-phpstan
Add CI workflow file to save a baseline for Phan and PHPStan
2 parents b81220b + 435e272 commit 777e90e

File tree

3 files changed

+67
-56
lines changed

3 files changed

+67
-56
lines changed

.github/workflows/phan.yml

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@ permissions:
55

66
on:
77
push:
8-
branches:
9-
- "*"
108
pull_request:
11-
branches: [ 'master', 'main' ]
12-
pull_request_target:
13-
types:
14-
- closed
159

1610
jobs:
1711
run:
@@ -24,7 +18,7 @@ jobs:
2418
uses: shivammathur/setup-php@0f7f1d08e3e32076e51cae65eb0b0c871405b16e # v2.34.1
2519
with:
2620
php-version: '8.4'
27-
tools: phan:5.5.0
21+
tools: phan
2822
coverage: none
2923

3024
- name: Restore cached baseline for Phan
@@ -40,27 +34,11 @@ jobs:
4034
- name: Run Phan
4135
continue-on-error: true
4236
run: |
43-
if [ -f ~/test/phan-baseline.php ]; then
37+
if [ -f test/phan-baseline.php ]; then
4438
echo "Cached baseline for Phan is found. Running Phan with baseline."
45-
phan -d ./ -k .phan/config.php --load-baseline ~/test/phan-baseline.php --no-progress-bar
39+
phan -d ./ -k .phan/config.php --load-baseline test/phan-baseline.php --no-progress-bar
4640
else
4741
echo "Cached baseline for Phan is not found. Running Phan without baseline."
4842
phan -d ./ -k .phan/config.php --no-progress-bar
4943
exit 0
5044
fi
51-
52-
- name: Generate the baseline for Phan
53-
continue-on-error: true
54-
if: github.event.pull_request.merged == true
55-
run: |
56-
phan -d ./ -k .phan/config.php --save-baseline ~/test/phan-baseline.php --no-progress-bar
57-
exit 0
58-
59-
- name: Save the baseline for Phan
60-
id: save-the-baseline-for-phan
61-
if: github.event.pull_request.merged == true
62-
uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
63-
with:
64-
path: |
65-
test/phan-baseline.php
66-
key: phan-baseline-${{ github.run_id }}"

.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 }}"

0 commit comments

Comments
 (0)