Skip to content

Commit 43923e1

Browse files
committed
Run static analysis for tag manually from release workflow
1 parent 798a5ba commit 43923e1

File tree

3 files changed

+84
-56
lines changed

3 files changed

+84
-56
lines changed

.github/workflows/coding-standards.yml

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -67,59 +67,3 @@ jobs:
6767
uses: stefanzweifel/git-auto-commit-action@v5
6868
with:
6969
commit_message: "apply phpcbf formatting"
70-
71-
analysis:
72-
runs-on: "ubuntu-22.04"
73-
continue-on-error: true
74-
strategy:
75-
matrix:
76-
php:
77-
- '8.1'
78-
- '8.2'
79-
steps:
80-
- name: Checkout
81-
uses: actions/checkout@v4
82-
83-
- name: Setup PHP
84-
uses: shivammathur/setup-php@v2
85-
with:
86-
php-version: ${{ matrix.php }}
87-
extensions: curl, mbstring
88-
tools: composer:v2
89-
coverage: none
90-
91-
- name: Cache dependencies
92-
id: composer-cache
93-
uses: actions/cache@v4
94-
with:
95-
path: ./vendor
96-
key: composer-${{ hashFiles('**/composer.lock') }}
97-
98-
- name: Install dependencies
99-
run: composer install
100-
101-
- name: Restore cache PHPStan results
102-
id: phpstan-cache-restore
103-
uses: actions/cache/restore@v4
104-
with:
105-
path: .cache
106-
key: "phpstan-result-cache-${{ github.run_id }}"
107-
restore-keys: |
108-
phpstan-result-cache-
109-
110-
- name: Run PHPStan
111-
run: ./vendor/bin/phpstan analyse --no-interaction --no-progress --ansi --error-format=sarif > phpstan.sarif
112-
113-
- name: "Upload SARIF report"
114-
if: always()
115-
uses: "github/codeql-action/upload-sarif@v3"
116-
with:
117-
sarif_file: phpstan.sarif
118-
119-
- name: Save cache PHPStan results
120-
id: phpstan-cache-save
121-
if: always()
122-
uses: actions/cache/save@v4
123-
with:
124-
path: .cache
125-
key: ${{ steps.phpstan-cache-restore.outputs.cache-primary-key }}

.github/workflows/release.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,13 @@ jobs:
9595
run: |
9696
echo '🚀 Created tag and drafted release for version [${{ inputs.version }}](${{ env.RELEASE_URL }})' >> $GITHUB_STEP_SUMMARY
9797
echo '✍️ You may now update the release notes and publish the release when ready' >> $GITHUB_STEP_SUMMARY
98+
99+
static-analysis:
100+
needs: prepare-release
101+
name: "Run Static Analysis"
102+
uses: ./.github/workflows/static-analysis.yml
103+
with:
104+
ref: refs/tags/${{ inputs.version }}
105+
permissions:
106+
security-events: write
107+
id-token: write

.github/workflows/static-analysis.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: "Static Analysis"
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_call:
7+
inputs:
8+
ref:
9+
description: "The git ref to check"
10+
type: string
11+
required: true
12+
13+
env:
14+
PHP_VERSION: "8.2"
15+
DRIVER_VERSION: "stable"
16+
17+
jobs:
18+
phpstan:
19+
runs-on: "ubuntu-22.04"
20+
continue-on-error: true
21+
strategy:
22+
matrix:
23+
php:
24+
- '8.1'
25+
- '8.2'
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
with:
30+
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || github.ref }}
31+
32+
- name: Setup PHP
33+
uses: shivammathur/setup-php@v2
34+
with:
35+
php-version: ${{ matrix.php }}
36+
extensions: curl, mbstring
37+
tools: composer:v2
38+
coverage: none
39+
40+
- name: Cache dependencies
41+
id: composer-cache
42+
uses: actions/cache@v4
43+
with:
44+
path: ./vendor
45+
key: composer-${{ hashFiles('**/composer.lock') }}
46+
47+
- name: Install dependencies
48+
run: composer install
49+
50+
- name: Restore cache PHPStan results
51+
id: phpstan-cache-restore
52+
uses: actions/cache/restore@v4
53+
with:
54+
path: .cache
55+
key: "phpstan-result-cache-${{ matrix.php }}-${{ github.run_id }}"
56+
restore-keys: |
57+
phpstan-result-cache-
58+
59+
- name: Run PHPStan
60+
run: ./vendor/bin/phpstan analyse --no-interaction --no-progress --ansi --error-format=sarif > phpstan.sarif
61+
62+
- name: "Upload SARIF report"
63+
if: always()
64+
uses: "github/codeql-action/upload-sarif@v3"
65+
with:
66+
sarif_file: phpstan.sarif
67+
68+
- name: Save cache PHPStan results
69+
id: phpstan-cache-save
70+
if: always()
71+
uses: actions/cache/save@v4
72+
with:
73+
path: .cache
74+
key: ${{ steps.phpstan-cache-restore.outputs.cache-primary-key }}

0 commit comments

Comments
 (0)