Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PHPStan analysis to PRs and mainline pushes #710

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 48 additions & 3 deletions .github/workflows/unit-tests.yml → .github/workflows/ci.yml
@@ -1,4 +1,4 @@
name: Unit Tests
name: CI

on:
push:
Expand All @@ -7,8 +7,8 @@ on:
branches: [ master ]

jobs:
phpunit-tests:
name: PHPUnit tests
phpunit:
name: PHPUnit
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -71,3 +71,48 @@ jobs:
with:
name: Test results
path: test-results

phpstan:
name: PHPStan
runs-on: ubuntu-latest

steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout code
uses: actions/checkout@v2

# Install Composer dependencies
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys:
${{ runner.os }}-composer-

- name: Install dependencies
uses: php-actions/composer@v6
with:
working_dir: PodcastGenerator
php_version: "8.0"
php_extensions: gettext xdebug

# For some reason output from the phpunt step doesn't overwrite the
# output.log from the composer step? Also, for some reason phpunit runs as
# root, which leads to unwanted permissions for the test-results dir, so
# we need to create it ourselves first
- run: |
rm -f PodcastGenerator/output.log
mkdir test-results

# Run PHPStan
- name: PHPStan
uses: php-actions/phpstan@v2
with:
php_version: "8.0"
php_extensions: gettext xdebug
configuration: phpstan.dist.neon
memory_limit: 512M
error_format: github
args: --no-progress
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Expand Up @@ -7,6 +7,7 @@
"neilbrayfield.php-docblocker",
"mehedidracula.php-namespace-resolver",
"obliviousharmony.vscode-php-codesniffer",
"recca0120.vscode-phpunit"
"renandelmonico.vscode-php-test-explorer",
"sanderronde.phpstan-vscode"
]
}
13 changes: 9 additions & 4 deletions .vscode/settings.json
@@ -1,14 +1,19 @@
{
"composer.workingPath": "PodcastGenerator/composer.json",
"cSpell.words": [
"phpcs"
],
"phpCodeSniffer.autoExecutable": true,
"phpCodeSniffer.exclude": [
"**/vendor/**",
"tests/coverage/**"
],
"phpCodeSniffer.standard": "Default",
"phpCodeSniffer.executable": "PodcastGenerator/vendor/bin/phpcs",
"phpunit.logpanel": true
"phpstan.binPath": "PodcastGenerator/vendor/bin/phpstan",
"phpstan.configFile": "phpstan.dist.neon",
"phpunit.logpanel": true,
"spellchecker.ignoreWordsList": [
"phpcs",
"PodcastGenerator",
"analyse",
"excludePaths"
]
}
3 changes: 2 additions & 1 deletion PodcastGenerator/composer.json
Expand Up @@ -59,7 +59,8 @@
"phpunit/phpunit": "^9.5",
"phpunit/php-code-coverage": "^9.2",
"phpcompatibility/php-compatibility": "^9.3",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.2"
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.2",
"phpstan/phpstan": "^1.8"
},
"config": {
"allow-plugins": {
Expand Down
63 changes: 61 additions & 2 deletions PodcastGenerator/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions phpstan.dist.neon
@@ -0,0 +1,14 @@
parameters:
level: 5
paths:
- PodcastGenerator
- tests
excludePaths:
analyse:
- PodcastGenerator/vendor
ignoreErrors:
- '#Variable \$(config|version) might not be defined.#'
-
message: '#Variable \$([a-zA-Z0-9\\_]+) might not be defined.#'
paths:
- PodcastGenerator/themes