diff --git a/.github/workflows/phan.yml b/.github/workflows/phan.yml new file mode 100644 index 0000000..957a3a0 --- /dev/null +++ b/.github/workflows/phan.yml @@ -0,0 +1,66 @@ +name: Phan + +permissions: + contents: read + +on: + push: + branches: + - "*" + pull_request: + branches: [ 'master', 'main' ] + pull_request_target: + types: + - closed + +jobs: + run: + name: Run Phan + runs-on: 'ubuntu-latest' + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup PHP + uses: shivammathur/setup-php@0f7f1d08e3e32076e51cae65eb0b0c871405b16e # v2.34.1 + with: + php-version: '8.4' + tools: phan:5.5.0 + coverage: none + + - name: Restore cached baseline for Phan + id: cache-baseline-restore + uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2 + with: + path: | + test/phan-baseline.php + key: phan-baseline-${{ github.run_id }}" + restore-keys: | + phan-baseline- + + - name: Run Phan + continue-on-error: true + run: | + if [ -f ~/test/phan-baseline.php ]; then + echo "Cached baseline for Phan is found. Running Phan with baseline." + phan -d ./ -k .phan/config.php --load-baseline ~/test/phan-baseline.php --no-progress-bar + else + echo "Cached baseline for Phan is not found. Running Phan without baseline." + phan -d ./ -k .phan/config.php --no-progress-bar + exit 0 + fi + + - name: Generate the baseline for Phan + continue-on-error: true + if: github.event.pull_request.merged == true + run: | + phan -d ./ -k .phan/config.php --save-baseline ~/test/phan-baseline.php --no-progress-bar + exit 0 + + - name: Save the baseline for Phan + id: save-the-baseline-for-phan + if: github.event.pull_request.merged == true + uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2 + with: + path: | + test/phan-baseline.php + key: phan-baseline-${{ github.run_id }}" diff --git a/.phan/config.php b/.phan/config.php new file mode 100644 index 0000000..723cf11 --- /dev/null +++ b/.phan/config.php @@ -0,0 +1,14 @@ + '8.4', + + 'directory_list' => [ + 'src', + ], + + 'exclude_analysis_directory_list' => [ + 'vendor/' + ], +];