Skip to content

Commit

Permalink
Enhancement: Run vimeo/psalm on GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Feb 17, 2024
1 parent 42e335e commit f467fce
Show file tree
Hide file tree
Showing 9 changed files with 1,157 additions and 166 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true

[*.xml]
indent_size = 2
indent_style = space

[*.yaml]
indent_size = 2
indent_style = space
Expand Down
28 changes: 27 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,19 @@ about what you're working on, you can contact us via the
```
to automatically fix coding standard issues.
- Run
```shell
make static-code-analysis
```
to run a static code analysis or, if applicable, run
```shell
make static-code-analysis-baseline
```
to regenerate the baseline.
- Review the change once more just before submitting it.
## What happens after submitting contribution?
Expand Down Expand Up @@ -133,7 +146,20 @@ Having said that, here are the organizational rules:
```shell
make coding-standards
```
6. Run
```shell
make static-code-analysis
```
to run a static code analysis or, if applicable, run
```shell
make static-code-analysis-baseline
```
to regenerate the baseline.
6. Use reasonable commit messages.
7. Use reasonable commit messages.
Thank you for contributing to https://www.php.net!
45 changes: 44 additions & 1 deletion .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
extensions: "none, curl, dom, json, mbstring, tokenizer, xml, xmlwriter"
extensions: "none, curl, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter"
php-version: "${{ matrix.php-version }}"

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

static-code-analysis:
name: "Static Code Analysis"

runs-on: "ubuntu-latest"

strategy:
matrix:
php-version:
- "8.2"

dependencies:
- "locked"

steps:
- name: "Checkout"
uses: "actions/checkout@v3"

- name: "Set up PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
extensions: "none, dom, json, mbstring, opcache, pcntl, posix, simplexml, tokenizer"
php-version: "${{ matrix.php-version }}"

- name: "Set up problem matchers for PHP"
run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\""

- name: "Determine composer cache directory"
run: "echo \"COMPOSER_CACHE_DIR=$(composer config cache-dir)\" >> $GITHUB_ENV"

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v3"
with:
path: "${{ env.COMPOSER_CACHE_DIR }}"
key: "php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-"

- name: "Install dependencies with composer"
run: "composer install --ansi --no-interaction --no-progress"

- name: "Run vimeo/psalm"
run: "vendor/bin/psalm --config=psalm.xml --output-format=github --shepherd --show-info=false --stats --threads=4"

tests:
name: "Tests"

Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ code-coverage: vendor ## Collects coverage from running tests with phpunit/phpun
coding-standards: vendor ## Fixes code style issues with friendsofphp/php-cs-fixer
vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff --show-progress=dots --verbose

.PHONY: static-code-analysis
static-code-analysis: vendor ## Runs a static code analysis with vimeo/psalm
vendor/bin/psalm --config=psalm.xml --show-info=true --stats --threads=4

.PHONY: static-code-analysis-baseline
static-code-analysis-baseline: vendor ## Generates a baseline for static code analysis with vimeo/psalm
vendor/bin/psalm --config=psalm.xml --set-baseline=psalm-baseline.xml

.PHONY: tests
tests: vendor ## Runs unit and end-to-end tests with phpunit/phpunit
vendor/bin/phpunit --configuration=tests/phpunit.xml --testsuite=unit
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![Integrate](https://github.com/php/web-php/actions/workflows/integrate.yaml/badge.svg)](https://github.com/php/web-php/actions/workflows/integrate.yaml)
[![Type Coverage](https://shepherd.dev/github/php/web-php/coverage.svg)](https://shepherd.dev/github/php/web-php)

## Local development

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"require-dev": {
"ext-curl": "*",
"friendsofphp/php-cs-fixer": "^3.49.0",
"phpunit/phpunit": "^10.5.10"
"phpunit/phpunit": "^10.5.10",
"vimeo/psalm": "^5.22.1"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit f467fce

Please sign in to comment.