Skip to content

Commit b81220b

Browse files
authored
Merge pull request msyk#119 from matsuo/run-phan-on-github-actions
Run Phan on GitHub Actions
2 parents 7beed8f + fa9810b commit b81220b

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

.github/workflows/phan.yml

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

.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)