Skip to content

Commit f467fce

Browse files
committed
Enhancement: Run vimeo/psalm on GitHub Actions
1 parent 42e335e commit f467fce

File tree

9 files changed

+1157
-166
lines changed

9 files changed

+1157
-166
lines changed

.editorconfig

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ charset = utf-8
55
insert_final_newline = true
66
trim_trailing_whitespace = true
77

8+
[*.xml]
9+
indent_size = 2
10+
indent_style = space
11+
812
[*.yaml]
913
indent_size = 2
1014
indent_style = space

.github/CONTRIBUTING.md

+27-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,19 @@ about what you're working on, you can contact us via the
7474
```
7575

7676
to automatically fix coding standard issues.
77+
- Run
78+
79+
```shell
80+
make static-code-analysis
81+
```
82+
83+
to run a static code analysis or, if applicable, run
84+
85+
```shell
86+
make static-code-analysis-baseline
87+
```
88+
89+
to regenerate the baseline.
7790
- Review the change once more just before submitting it.
7891

7992
## What happens after submitting contribution?
@@ -133,7 +146,20 @@ Having said that, here are the organizational rules:
133146
```shell
134147
make coding-standards
135148
```
149+
6. Run
150+
151+
```shell
152+
make static-code-analysis
153+
```
154+
155+
to run a static code analysis or, if applicable, run
156+
157+
```shell
158+
make static-code-analysis-baseline
159+
```
160+
161+
to regenerate the baseline.
136162

137-
6. Use reasonable commit messages.
163+
7. Use reasonable commit messages.
138164

139165
Thank you for contributing to https://www.php.net!

.github/workflows/integrate.yaml

+44-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ jobs:
7777
uses: "shivammathur/setup-php@v2"
7878
with:
7979
coverage: "none"
80-
extensions: "none, curl, dom, json, mbstring, tokenizer, xml, xmlwriter"
80+
extensions: "none, curl, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter"
8181
php-version: "${{ matrix.php-version }}"
8282

8383
- name: "Set up problem matchers for PHP"
@@ -102,6 +102,49 @@ jobs:
102102
- name: "Run friendsofphp/php-cs-fixer"
103103
run: "vendor/bin/php-cs-fixer fix --ansi --config=.php-cs-fixer.php --diff --dry-run --show-progress=dots --verbose"
104104

105+
static-code-analysis:
106+
name: "Static Code Analysis"
107+
108+
runs-on: "ubuntu-latest"
109+
110+
strategy:
111+
matrix:
112+
php-version:
113+
- "8.2"
114+
115+
dependencies:
116+
- "locked"
117+
118+
steps:
119+
- name: "Checkout"
120+
uses: "actions/checkout@v3"
121+
122+
- name: "Set up PHP"
123+
uses: "shivammathur/setup-php@v2"
124+
with:
125+
coverage: "none"
126+
extensions: "none, dom, json, mbstring, opcache, pcntl, posix, simplexml, tokenizer"
127+
php-version: "${{ matrix.php-version }}"
128+
129+
- name: "Set up problem matchers for PHP"
130+
run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\""
131+
132+
- name: "Determine composer cache directory"
133+
run: "echo \"COMPOSER_CACHE_DIR=$(composer config cache-dir)\" >> $GITHUB_ENV"
134+
135+
- name: "Cache dependencies installed with composer"
136+
uses: "actions/cache@v3"
137+
with:
138+
path: "${{ env.COMPOSER_CACHE_DIR }}"
139+
key: "php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.lock') }}"
140+
restore-keys: "php-${{ matrix.php-version }}-composer-"
141+
142+
- name: "Install dependencies with composer"
143+
run: "composer install --ansi --no-interaction --no-progress"
144+
145+
- name: "Run vimeo/psalm"
146+
run: "vendor/bin/psalm --config=psalm.xml --output-format=github --shepherd --show-info=false --stats --threads=4"
147+
105148
tests:
106149
name: "Tests"
107150

Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ code-coverage: vendor ## Collects coverage from running tests with phpunit/phpun
2121
coding-standards: vendor ## Fixes code style issues with friendsofphp/php-cs-fixer
2222
vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff --show-progress=dots --verbose
2323

24+
.PHONY: static-code-analysis
25+
static-code-analysis: vendor ## Runs a static code analysis with vimeo/psalm
26+
vendor/bin/psalm --config=psalm.xml --show-info=true --stats --threads=4
27+
28+
.PHONY: static-code-analysis-baseline
29+
static-code-analysis-baseline: vendor ## Generates a baseline for static code analysis with vimeo/psalm
30+
vendor/bin/psalm --config=psalm.xml --set-baseline=psalm-baseline.xml
31+
2432
.PHONY: tests
2533
tests: vendor ## Runs unit and end-to-end tests with phpunit/phpunit
2634
vendor/bin/phpunit --configuration=tests/phpunit.xml --testsuite=unit

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[![Integrate](https://github.com/php/web-php/actions/workflows/integrate.yaml/badge.svg)](https://github.com/php/web-php/actions/workflows/integrate.yaml)
2+
[![Type Coverage](https://shepherd.dev/github/php/web-php/coverage.svg)](https://shepherd.dev/github/php/web-php)
23

34
## Local development
45

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"require-dev": {
1414
"ext-curl": "*",
1515
"friendsofphp/php-cs-fixer": "^3.49.0",
16-
"phpunit/phpunit": "^10.5.10"
16+
"phpunit/phpunit": "^10.5.10",
17+
"vimeo/psalm": "^5.22.1"
1718
},
1819
"autoload": {
1920
"psr-4": {

0 commit comments

Comments
 (0)