Skip to content

Commit 189700f

Browse files
authored
PHPLIB-1435: Integrate static analysis for releases (#1308)
* PHPLIB-1435: Integrate static analysis for releases * Extract setup action and split static analysis job * Use correct capitalisation for acronym * Upgrade to latest rector version
1 parent cd051e2 commit 189700f

File tree

5 files changed

+78
-89
lines changed

5 files changed

+78
-89
lines changed

.github/actions/setup/action.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Setup
2+
description: Sets up the build environment
3+
inputs:
4+
php-version:
5+
description: "PHP version to install"
6+
required: true
7+
driver-version:
8+
description: "MongoDB extension version to install"
9+
required: true
10+
php-ini-values:
11+
description: "INI values to pass along to setup-php action"
12+
required: false
13+
default: ""
14+
15+
runs:
16+
using: composite
17+
steps:
18+
- name: Setup cache environment
19+
id: extcache
20+
uses: shivammathur/cache-extensions@v1
21+
with:
22+
php-version: ${{ env.PHP_VERSION }}
23+
extensions: "mongodb-${{ env.DRIVER_VERSION }}"
24+
key: "extcache-v1"
25+
26+
- name: Cache extensions
27+
uses: actions/cache@v4
28+
with:
29+
path: ${{ steps.extcache.outputs.dir }}
30+
key: ${{ steps.extcache.outputs.key }}
31+
restore-keys: ${{ steps.extcache.outputs.key }}
32+
33+
- name: Install PHP
34+
uses: shivammathur/setup-php@v2
35+
with:
36+
coverage: none
37+
extensions: "mongodb-${{ inputs.driver-version }}"
38+
php-version: "${{ inputs.php-version }}"
39+
tools: cs2pr
40+
ini-values: "${{ inputs.php-ini-values }}"
41+
42+
- name: Show driver information
43+
run: "php --ri mongodb"
44+
shell: bash
45+
46+
- name: Install dependencies with Composer
47+
uses: ramsey/[email protected]
48+
with:
49+
composer-options: "--no-suggest"

.github/workflows/coding-standards.yml

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,36 +26,11 @@ jobs:
2626
- name: "Checkout"
2727
uses: "actions/checkout@v4"
2828

29-
- name: Setup cache environment
30-
id: extcache
31-
uses: shivammathur/cache-extensions@v1
29+
- name: "Setup"
30+
uses: "./.github/actions/setup"
3231
with:
3332
php-version: ${{ env.PHP_VERSION }}
34-
extensions: "mongodb-${{ env.DRIVER_VERSION }}"
35-
key: "extcache-v1"
36-
37-
- name: Cache extensions
38-
uses: actions/cache@v4
39-
with:
40-
path: ${{ steps.extcache.outputs.dir }}
41-
key: ${{ steps.extcache.outputs.key }}
42-
restore-keys: ${{ steps.extcache.outputs.key }}
43-
44-
- name: "Install PHP"
45-
uses: "shivammathur/setup-php@v2"
46-
with:
47-
coverage: "none"
48-
extensions: "mongodb-${{ env.DRIVER_VERSION }}"
49-
php-version: "${{ env.PHP_VERSION }}"
50-
tools: "cs2pr"
51-
52-
- name: "Show driver information"
53-
run: "php --ri mongodb"
54-
55-
- name: "Install dependencies with Composer"
56-
uses: "ramsey/[email protected]"
57-
with:
58-
composer-options: "--no-suggest"
33+
driver-version: ${{ env.DRIVER_VERSION }}
5934

6035
# The -q option is required until phpcs v4 is released
6136
- name: "Run PHP_CodeSniffer"

.github/workflows/static-analysis.yml

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ on:
1212
- "v*.*"
1313
- "master"
1414
- "feature/*"
15+
tags:
16+
- "*"
1517

1618
env:
1719
PHP_VERSION: "8.2"
@@ -26,45 +28,33 @@ jobs:
2628
- name: "Checkout"
2729
uses: "actions/checkout@v4"
2830

29-
- name: Setup cache environment
30-
id: extcache
31-
uses: shivammathur/cache-extensions@v1
31+
- name: "Setup"
32+
uses: "./.github/actions/setup"
3233
with:
3334
php-version: ${{ env.PHP_VERSION }}
34-
extensions: "mongodb-${{ env.DRIVER_VERSION }}"
35-
key: "extcache-v1"
35+
driver-version: ${{ env.DRIVER_VERSION }}
3636

37-
- name: Cache extensions
38-
uses: actions/cache@v4
39-
with:
40-
path: ${{ steps.extcache.outputs.dir }}
41-
key: ${{ steps.extcache.outputs.key }}
42-
restore-keys: ${{ steps.extcache.outputs.key }}
37+
- name: "Run Psalm"
38+
run: "vendor/bin/psalm --show-info=false --stats --output-format=github --threads=$(nproc) --report=psalm.sarif"
4339

44-
- name: "Install PHP"
45-
uses: "shivammathur/setup-php@v2"
40+
- name: "Upload SARIF report"
41+
uses: "github/codeql-action/upload-sarif@v3"
4642
with:
47-
coverage: "none"
48-
extensions: "mongodb-${{ env.DRIVER_VERSION }}"
49-
php-version: "${{ env.PHP_VERSION }}"
50-
tools: "cs2pr"
43+
sarif_file: psalm.sarif
5144

52-
- name: "Show driver information"
53-
run: "php --ri mongodb"
45+
rector:
46+
name: "Rector"
47+
runs-on: "ubuntu-22.04"
5448

55-
- name: "Install dependencies with Composer"
56-
uses: "ramsey/[email protected]"
57-
with:
58-
composer-options: "--no-suggest"
49+
steps:
50+
- name: "Checkout"
51+
uses: "actions/checkout@v4"
5952

60-
- name: "Run Psalm"
61-
run: "vendor/bin/psalm --show-info=false --stats --output-format=github --threads=$(nproc) --report=psalm.sarif"
53+
- name: "Setup"
54+
uses: "./.github/actions/setup"
55+
with:
56+
php-version: ${{ env.PHP_VERSION }}
57+
driver-version: ${{ env.DRIVER_VERSION }}
6258

6359
- name: "Run Rector"
6460
run: "vendor/bin/rector --ansi --dry-run"
65-
66-
- name: "Upload Psalm report"
67-
uses: actions/upload-artifact@v4
68-
with:
69-
name: psalm.sarif
70-
path: psalm.sarif

.github/workflows/tests.yml

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -74,37 +74,12 @@ jobs:
7474
version: ${{ matrix.mongodb-version }}
7575
topology: ${{ matrix.topology }}
7676

77-
- name: Setup cache environment
78-
id: extcache
79-
uses: shivammathur/cache-extensions@v1
77+
- name: "Setup"
78+
uses: "./.github/actions/setup"
8079
with:
8180
php-version: ${{ matrix.php-version }}
82-
extensions: "mongodb-${{ env.DRIVER_VERSION }}"
83-
key: "extcache-v1"
84-
85-
- name: Cache extensions
86-
uses: actions/cache@v4
87-
with:
88-
path: ${{ steps.extcache.outputs.dir }}
89-
key: ${{ steps.extcache.outputs.key }}
90-
restore-keys: ${{ steps.extcache.outputs.key }}
91-
92-
- name: "Install PHP"
93-
uses: "shivammathur/setup-php@v2"
94-
with:
95-
php-version: "${{ matrix.php-version }}"
96-
tools: "pecl"
97-
extensions: "mongodb-${{ env.DRIVER_VERSION }}"
98-
coverage: "none"
99-
ini-values: "zend.assertions=1"
100-
101-
- name: "Show driver information"
102-
run: "php --ri mongodb"
103-
104-
- name: "Install dependencies with Composer"
105-
uses: "ramsey/[email protected]"
106-
with:
107-
composer-options: "--no-suggest"
81+
driver-version: ${{ env.DRIVER_VERSION }}
82+
php-ini-values: "zend.assertions=1"
10883

10984
- name: "Run PHPUnit"
11085
run: "vendor/bin/simple-phpunit -v"

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"require-dev": {
2323
"doctrine/coding-standard": "^12.0",
24-
"rector/rector": "^0.19",
24+
"rector/rector": "^1.1",
2525
"squizlabs/php_codesniffer": "^3.7",
2626
"symfony/phpunit-bridge": "^5.2",
2727
"vimeo/psalm": "^5.13"

0 commit comments

Comments
 (0)