Skip to content

Commit 87e4e1b

Browse files
committed
Enhancement: Run vimeo/psalm on GitHub Actions
1 parent db5ec41 commit 87e4e1b

File tree

9 files changed

+1253
-107
lines changed

9 files changed

+1253
-107
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

+46-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
uses: "shivammathur/setup-php@v2"
2828
with:
2929
coverage: "xdebug"
30-
extensions: "none, curl, dom, json, mbstring, tokenizer, xml, xmlwriter"
30+
extensions: "none, curl, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter"
3131
php-version: "${{ matrix.php-version }}"
3232

3333
- name: "Set up problem matchers for PHP"
@@ -72,7 +72,7 @@ jobs:
7272
uses: "shivammathur/setup-php@v2"
7373
with:
7474
coverage: "none"
75-
extensions: "none, curl, dom, json, mbstring, tokenizer, xml, xmlwriter"
75+
extensions: "none, curl, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter"
7676
php-version: "${{ matrix.php-version }}"
7777

7878
- name: "Set up problem matchers for PHP"
@@ -97,6 +97,49 @@ jobs:
9797
- name: "Run friendsofphp/php-cs-fixer"
9898
run: "vendor/bin/php-cs-fixer fix --ansi --config=.php-cs-fixer.php --diff --dry-run --show-progress=dots --verbose"
9999

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

@@ -118,7 +161,7 @@ jobs:
118161
uses: "shivammathur/setup-php@v2"
119162
with:
120163
coverage: "none"
121-
extensions: "none, curl, dom, json, mbstring, tokenizer, xml, xmlwriter"
164+
extensions: "none, curl, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter"
122165
php-version: "${{ matrix.php-version }}"
123166

124167
- name: "Set up problem matchers for PHP"

Makefile

+9-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
HTTP_HOST:=localhost:8080
44

55
.PHONY: it
6-
it: coding-standards tests ## Runs all the targets
6+
it: coding-standards static-code-analysis tests ## Runs all the targets
77

88
.PHONY: code-coverage
99
code-coverage: vendor ## Collects code coverage from running unit tests with phpunit/phpunit
@@ -17,6 +17,14 @@ coding-standards: vendor ## Fixes code style issues with friendsofphp/php-cs-fix
1717
help: ## Displays this list of targets with descriptions
1818
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'
1919

20+
.PHONY: static-code-analysis
21+
static-code-analysis: vendor ## Runs a static code analysis with vimeo/psalm
22+
vendor/bin/psalm --config=psalm.xml --show-info=false --stats --threads=4
23+
24+
.PHONY: static-code-analysis-baseline
25+
static-code-analysis-baseline: vendor ## Generates a baseline for static code analysis with vimeo/psalm
26+
vendor/bin/psalm --config=psalm.xml --set-baseline=psalm-baseline.xml
27+
2028
.PHONY: tests
2129
tests: vendor ## Runs unit and end-to-end tests with phpunit/phpunit
2230
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

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
"require-dev": {
1414
"ext-curl": "*",
1515
"friendsofphp/php-cs-fixer": "^3.50.0",
16-
"phpunit/phpunit": "^10.5.11"
16+
"phpunit/phpunit": "^10.5.11",
17+
"psalm/plugin-phpunit": "~0.18.4",
18+
"vimeo/psalm": "^5.22.2"
1719
},
1820
"autoload": {
1921
"psr-4": {

0 commit comments

Comments
 (0)