Skip to content

Commit a233747

Browse files
authored
Merge pull request #51 from greg0ire/split-sa-workflow
Split static analysis workflow
2 parents 86f67a2 + c5b75c1 commit a233747

File tree

4 files changed

+60
-34
lines changed

4 files changed

+60
-34
lines changed

.github/workflows/phpstan.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
name: "Static Analysis with PHPStan"
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
php-version:
8+
description: "The PHP version to use when running the job"
9+
default: "8.3"
10+
required: false
11+
type: "string"
12+
composer-root-version:
13+
description: "The version of the package being tested, in case of circular dependencies."
14+
required: false
15+
type: "string"
16+
composer-options:
17+
description: "Additional flags for the composer install command."
18+
default: "--prefer-dist"
19+
required: false
20+
type: "string"
21+
22+
jobs:
23+
phpstan:
24+
name: "PHPStan (PHP: ${{ inputs.php-version }})"
25+
runs-on: "ubuntu-22.04"
26+
27+
steps:
28+
- name: "Checkout code"
29+
uses: "actions/checkout@v4"
30+
31+
- name: "Install PHP"
32+
uses: "shivammathur/setup-php@v2"
33+
with:
34+
coverage: "none"
35+
php-version: "${{ inputs.php-version }}"
36+
37+
- name: "Set COMPOSER_ROOT_VERSION"
38+
run: |
39+
echo "COMPOSER_ROOT_VERSION=${{ inputs.composer-root-version }}" >> $GITHUB_ENV
40+
if: "${{ inputs.composer-root-version }}"
41+
42+
- name: "Install dependencies with Composer"
43+
uses: "ramsey/composer-install@v3"
44+
with:
45+
dependency-versions: "highest"
46+
composer-options: "${{ inputs.composer-options }}"
47+
48+
- name: "Run a static analysis with phpstan/phpstan"
49+
run: "vendor/bin/phpstan analyse -v"

.github/workflows/static-analysis.yml

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,15 @@ on:
2121

2222
jobs:
2323
phpstan:
24-
name: "PHPStan (PHP: ${{ inputs.php-version }})"
25-
runs-on: "ubuntu-22.04"
26-
27-
steps:
28-
- name: "Checkout code"
29-
uses: "actions/checkout@v4"
30-
31-
- name: "Install PHP"
32-
uses: "shivammathur/setup-php@v2"
33-
with:
34-
coverage: "none"
35-
php-version: "${{ inputs.php-version }}"
36-
37-
- name: "Set COMPOSER_ROOT_VERSION"
38-
run: |
39-
echo "COMPOSER_ROOT_VERSION=${{ inputs.composer-root-version }}" >> $GITHUB_ENV
40-
if: "${{ inputs.composer-root-version }}"
41-
42-
- name: "Install dependencies with Composer"
43-
uses: "ramsey/composer-install@v3"
44-
with:
45-
dependency-versions: "highest"
46-
composer-options: "${{ inputs.composer-options }}"
47-
48-
- name: "Run a static analysis with phpstan/phpstan"
49-
run: "vendor/bin/phpstan analyse -v"
24+
name: "PHPStan (deprecated in favor of phpstan.yml)"
25+
uses: "./.github/workflows/phpstan.yml"
26+
with:
27+
php-version: "${{ inputs.php-version }}"
28+
composer-root-version: "${{ inputs.composer-root-version }}"
29+
composer-options: "${{ inputs.composer-options }}"
5030

5131
psalm:
52-
name: "Psalm (PHP: ${{ inputs.php-version }})"
32+
name: "Psalm (PHP: ${{ inputs.php-version }}, deprecated without a replacement)"
5333
runs-on: "ubuntu-22.04"
5434

5535
steps:
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
{
2-
"name": "Static analysis",
2+
"name": "Static analysis with PHPStan",
33
"description": "Perform static analysis on the source code and tests",
44
"iconName": "doctrine-logo",
55
"categories": [
66
"PHP"
77
],
88
"filePatterns": [
9-
"^phpstan\\.neon(?:\\.dist)$",
10-
"^psalm\\.xml$"
9+
"^phpstan\\.neon(?:\\.dist)$"
1110
]
1211
}

workflow-templates/static-analysis.yml renamed to workflow-templates/phpstan.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,19 @@ on:
66
branches:
77
- "*.x"
88
paths:
9-
- ".github/workflows/static-analysis.yml"
9+
- ".github/workflows/phpstan.yml"
1010
- "composer.*"
1111
- "src/**"
1212
- "phpstan*"
13-
- "psalm*"
1413
- "tests/**"
1514
push:
1615
branches:
1716
- "*.x"
1817
paths:
19-
- ".github/workflows/static-analysis.yml"
18+
- ".github/workflows/phpstan.yml"
2019
- "composer.*"
2120
- "src/**"
2221
- "phpstan*"
23-
- "psalm*"
2422
- "tests/**"
2523

2624
jobs:

0 commit comments

Comments
 (0)