Skip to content

Commit f191e83

Browse files
committed
Enhancement: Run vimeo/psalm on GitHub Actions
1 parent 9482f9b commit f191e83

File tree

9 files changed

+1185
-107
lines changed

9 files changed

+1185
-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

+29-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Anybody who programs in PHP can be a contributing member of the community that
44
develops and deploys www.php.net; the task of deploying the www.php.net website is a never-ending one.
55

66
You don't need any special access to download, debug and begin submitting
7-
code, tests or documentation.
7+
code, tests or documentation.
88

99
## Index
1010

@@ -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?
@@ -93,7 +106,7 @@ bumping. Before doing this think about these questions:
93106

94107
## What happens when your contribution is applied?
95108

96-
Your name will likely be included in the Git commit log.
109+
Your name will likely be included in the Git commit log.
97110

98111
## Git commit rules
99112

@@ -133,7 +146,20 @@ Having said that, here are the organizational rules:
133146
```
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

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

3333
- name: "Set up problem matchers for PHP"
@@ -54,6 +54,52 @@ jobs:
5454
env:
5555
PHP_CS_FIXER_IGNORE_ENV: "1"
5656

57+
static-code-analysis:
58+
name: "Static Code Analysis"
59+
60+
runs-on: "ubuntu-latest"
61+
62+
strategy:
63+
matrix:
64+
php-version:
65+
- "8.2"
66+
67+
dependencies:
68+
- "locked"
69+
70+
steps:
71+
- name: "Checkout"
72+
uses: "actions/checkout@v3"
73+
74+
- name: "Set up PHP"
75+
uses: "shivammathur/setup-php@v2"
76+
with:
77+
coverage: "none"
78+
extensions: "none, dom, json, mbstring, pcntl, posix, simplexml, tokenizer"
79+
php-version: "${{ matrix.php-version }}"
80+
81+
- name: "Set up problem matchers for PHP"
82+
run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\""
83+
84+
- name: "Determine composer cache directory"
85+
run: "echo \"COMPOSER_CACHE_DIR=$(composer config cache-dir)\" >> $GITHUB_ENV"
86+
87+
- name: "Cache dependencies installed with composer"
88+
uses: "actions/cache@v3"
89+
with:
90+
path: "${{ env.COMPOSER_CACHE_DIR }}"
91+
key: "php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.lock') }}"
92+
restore-keys: "php-${{ matrix.php-version }}-composer-"
93+
94+
- name: "Install dependencies with composer"
95+
run: "composer install --ansi --no-interaction --no-progress"
96+
97+
- name: "Create cache directory for vimeo/psalm"
98+
run: "mkdir -p .build/psalm"
99+
100+
- name: "Run vimeo/psalm"
101+
run: "vendor/bin/psalm --config=psalm.xml --output-format=github --shepherd --show-info=false --stats --threads=4"
102+
57103
tests:
58104
name: "Tests"
59105

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/.build/
12
/vendor/
23

34
backend/mirror.gif

Makefile

+12
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ coding-standards: vendor ## Fixes code style issues with friendsofphp/php-cs-fix
1010
tests: ## Runs tests
1111
php tests/run-tests.php -j3 -q
1212

13+
.PHONY: static-code-analysis
14+
static-code-analysis: vendor ## Runs a static code analysis with vimeo/psalm
15+
mkdir -p .build/psalm/
16+
vendor/bin/psalm --config=psalm.xml --clear-cache
17+
vendor/bin/psalm --config=psalm.xml --show-info=true --stats --threads=4
18+
19+
.PHONY: static-code-analysis-baseline
20+
static-code-analysis-baseline: vendor ## Generates a baseline for static code analysis with vimeo/psalm
21+
mkdir -p .build/psalm/
22+
vendor/bin/psalm --config=psalm.xml --clear-cache
23+
vendor/bin/psalm --config=psalm.xml --set-baseline=psalm-baseline.xml
24+
1325
vendor: composer.json composer.lock
1426
composer validate --strict
1527
composer install --no-interaction --no-progress

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"php": "~8.2.0"
1212
},
1313
"require-dev": {
14-
"friendsofphp/php-cs-fixer": "^3.40.2"
14+
"friendsofphp/php-cs-fixer": "^3.40.2",
15+
"vimeo/psalm": "^5.17.0"
1516
},
1617
"autoload": {
1718
"psr-4": {

0 commit comments

Comments
 (0)