Skip to content
Snippets Groups Projects
Verified Commit 8bc6f68f authored by Bartek Jaskulski's avatar Bartek Jaskulski
Browse files

feat: block pipelines on static analysis errors


For now, phpstan is running on level 5 to ease the misconfiguration or
too much errors on projects, which just set up the static analysis.

Signed-off-by: default avatarBart Jaskulski <bjaskulski@protonmail.com>
parent 355711dd
Branches
Tags
No related merge requests found
.static-analysis: .static-analysis:
image: gitlab.wpdesk.dev:5050/wpdesk/docker-tests/php-box:8.3.2 image: gitlab.wpdesk.dev:5050/wpdesk/docker-tests/php-box:8.4.1
needs: needs:
- prepare prefixed vendor - prepare prefixed vendor
stage: tests stage: tests
# Run phpstan in strict mode (failing pipeline) only if we have baseline, otherwise allow to fail with a warning, suggesting to create one. This behavior will change at the end of the year, when any PHPStan failure will be considered fatal
phpstan: phpstan:
extends: .static-analysis extends: .static-analysis
script: script:
- | - |
if [ -f "vendor/bin/phpstan" ]; then if [ -f "vendor/bin/phpstan" ]; then
vendor/bin/phpstan analyse --error-format=gitlab --memory-limit=2G > phpstan-codequality.json || true vendor/bin/phpstan analyse --level 5 --error-format=gitlab --memory-limit=2G > phpstan-codequality.json || true
vendor/bin/phpstan analyse --error-format=junit --memory-limit=2G > phpstan-junit.xml vendor/bin/phpstan analyse --level 5 --error-format=junit --memory-limit=2G > phpstan-junit.xml
elif [ -f "vendor/wpdesk/wp-wpdesk-composer/director/vendor/bin/phpstan" ]; then elif [ -f "vendor/wpdesk/wp-wpdesk-composer/director/vendor/bin/phpstan" ]; then
# PHPStan installed by director # PHPStan installed by director
vendor/wpdesk/wp-wpdesk-composer/director/vendor/bin/phpstan analyse --error-format=gitlab --memory-limit=2G > phpstan-codequality.json || true vendor/wpdesk/wp-wpdesk-composer/director/vendor/bin/phpstan analyse --level 5 --error-format=gitlab --memory-limit=2G > phpstan-codequality.json || true
vendor/wpdesk/wp-wpdesk-composer/director/vendor/bin/phpstan analyse --error-format=junit --memory-limit=2G > phpstan-junit.xml vendor/wpdesk/wp-wpdesk-composer/director/vendor/bin/phpstan analyse --level 5 --error-format=junit --memory-limit=2G > phpstan-junit.xml
else else
echo "PHPStan not found! Install it with 'composer require --dev wpdesk/phpstan-rules'." echo "PHPStan not found! Install it with 'composer require --dev wpdesk/phpstan-rules'."
# We will be able to handle custom exit after removing rules.allow_failure part
exit 125 exit 125
fi fi
allow_failure: true
artifacts: artifacts:
paths: paths:
- phpstan-codequality.json - phpstan-codequality.json
...@@ -34,16 +31,11 @@ phpstan: ...@@ -34,16 +31,11 @@ phpstan:
- !reference [.skip-mr, rules] - !reference [.skip-mr, rules]
- exists: - exists:
- phpstan.neon.dist - phpstan.neon.dist
- exists:
- .phpstan-baseline.php
- .phpstan-baseline.neon
allow_failure: false
phpcs: phpcs:
extends: .static-analysis extends: .static-analysis
script: script:
- vendor/bin/phpcs --warning-severity=0 --report-junit=phpcs-junit.xml --report-full - vendor/bin/phpcs --warning-severity=0 --report-junit=phpcs-junit.xml --report-full
allow_failure: true
rules: rules:
- !reference [.skip-mr, rules] - !reference [.skip-mr, rules]
- exists: - exists:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment