Skip to content

Commit 55976ee

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

File tree

3 files changed

+84
-59
lines changed

3 files changed

+84
-59
lines changed

.github/workflows/coding-standards.yml

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -9,65 +9,6 @@ env:
99
DRIVER_VERSION: "stable"
1010

1111
jobs:
12-
phpcs:
13-
name: "phpcs"
14-
runs-on: "ubuntu-22.04"
15-
16-
permissions:
17-
# Give the default GITHUB_TOKEN write permission to commit and push the
18-
# added or changed files to the repository.
19-
contents: write
20-
21-
steps:
22-
- name: "Checkout"
23-
uses: "actions/checkout@v4"
24-
25-
- name: "Setup cache environment"
26-
id: "extcache"
27-
uses: "shivammathur/cache-extensions@v1"
28-
with:
29-
php-version: ${{ env.PHP_VERSION }}
30-
extensions: "mongodb-${{ env.DRIVER_VERSION }}"
31-
key: "extcache-v1"
32-
33-
- name: "Cache extensions"
34-
uses: "actions/cache@v4"
35-
with:
36-
path: ${{ steps.extcache.outputs.dir }}
37-
key: ${{ steps.extcache.outputs.key }}
38-
restore-keys: ${{ steps.extcache.outputs.key }}
39-
40-
- name: "Install PHP"
41-
uses: "shivammathur/setup-php@v2"
42-
with:
43-
coverage: "none"
44-
extensions: "mongodb-${{ env.DRIVER_VERSION }}"
45-
php-version: ${{ env.PHP_VERSION }}
46-
tools: "cs2pr"
47-
48-
- name: "Show driver information"
49-
run: "php --ri mongodb"
50-
51-
- name: "Install dependencies with Composer"
52-
uses: "ramsey/composer-install@3.0.0"
53-
with:
54-
composer-options: "--no-suggest"
55-
56-
- name: "Format the code"
57-
continue-on-error: true
58-
run: |
59-
mkdir .cache
60-
./vendor/bin/phpcbf
61-
62-
# The -q option is required until phpcs v4 is released
63-
- name: "Run PHP_CodeSniffer"
64-
run: "vendor/bin/phpcs -q --no-colors --report=checkstyle | cs2pr"
65-
66-
- name: "Commit the changes"
67-
uses: stefanzweifel/git-auto-commit-action@v5
68-
with:
69-
commit_message: "apply phpcbf formatting"
70-
7112
analysis:
7213
runs-on: "ubuntu-22.04"
7314
continue-on-error: true

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