Skip to content

Commit 940e9f5

Browse files
committed
add static analysis
1 parent 8100d9d commit 940e9f5

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

.github/workflows/static-analysis.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: "Static Analysis"
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "source/**/*.php"
7+
workflow_call:
8+
inputs:
9+
ref:
10+
description: "The git ref to check"
11+
type: string
12+
required: true
13+
14+
env:
15+
PHP_VERSION: "8.2"
16+
# TODO: change to "stable" once 1.20.0 is released
17+
# DRIVER_VERSION: "stable"
18+
DRIVER_VERSION: "mongodb/mongo-php-driver@master"
19+
20+
jobs:
21+
psalm:
22+
name: "Psalm"
23+
runs-on: "ubuntu-22.04"
24+
25+
steps:
26+
- name: "Checkout"
27+
uses: "actions/checkout@v4"
28+
with:
29+
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || github.ref }}
30+
31+
- name: "Get SHA hash of checked out ref"
32+
if: ${{ github.event_name == 'workflow_dispatch' }}
33+
run: |
34+
echo CHECKED_OUT_SHA=$(git rev-parse HEAD) >> $GITHUB_ENV
35+
36+
- name: "Setup"
37+
uses: "./.github/actions/setup"
38+
with:
39+
php-version: ${{ env.PHP_VERSION }}
40+
driver-version: ${{ env.DRIVER_VERSION }}
41+
42+
- name: "Run Psalm"
43+
run: "vendor/bin/psalm --show-info=false --stats --output-format=github --threads=$(nproc) --report=psalm.sarif"
44+
45+
- name: "Upload SARIF report"
46+
if: ${{ github.event_name != 'workflow_dispatch' }}
47+
uses: "github/codeql-action/upload-sarif@v3"
48+
with:
49+
sarif_file: psalm.sarif
50+
51+
- name: "Upload SARIF report"
52+
if: ${{ github.event_name == 'workflow_dispatch' }}
53+
uses: "github/codeql-action/upload-sarif@v3"
54+
with:
55+
sarif_file: psalm.sarif
56+
ref: ${{ inputs.ref }}
57+
sha: ${{ env.CHECKED_OUT_SHA }}

0 commit comments

Comments
 (0)