Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
718a97e6
Verified
Commit
718a97e6
authored
2 weeks ago
by
Dave Long
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3499245
by mondrake, bbrala: [CI] Report PHPStan baseline statistics in job
parent
4364de08
No related branches found
No related tags found
No related merge requests found
Pipeline
#474731
passed with warnings
2 weeks ago
Stage: 🪄 Lint
Stage: 🗜️ Test
Pipeline: drupal
#474745
Pipeline: drupal
#474740
Pipeline: drupal
#474733
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+4
-0
4 additions, 0 deletions
.gitlab-ci.yml
.gitlab-ci/scripts/phpstan-baseline-statistics.php
+38
-0
38 additions, 0 deletions
.gitlab-ci/scripts/phpstan-baseline-statistics.php
with
42 additions
and
0 deletions
.gitlab-ci.yml
+
4
−
0
View file @
718a97e6
...
...
@@ -391,8 +391,11 @@ default:
php vendor/bin/phpstan analyze --configuration=./core/phpstan.neon.dist --no-progress --generate-baseline=$CI_PROJECT_DIR/core/.phpstan-baseline.php || true
sed -i "s/ '\\/\\/build\\/core/ '/g" $CI_PROJECT_DIR/core/.phpstan-baseline.php
sed -i "s/ '\\/\\/build/ '\\/../g" $CI_PROJECT_DIR/core/.phpstan-baseline.php
php $CI_PROJECT_DIR/.gitlab-ci/scripts/phpstan-baseline-statistics.php
exit $EXIT_CODE
fi
# Generate baseline statistics.
-
php $CI_PROJECT_DIR/.gitlab-ci/scripts/phpstan-baseline-statistics.php
artifacts
:
# Only store the baseline if the job fails.
...
...
@@ -400,6 +403,7 @@ default:
reports
:
codequality
:
phpstan-quality-report.json
junit
:
phpstan-junit.xml
metrics
:
phpstan-metrics.txt
paths
:
-
$CI_PROJECT_DIR/core/.phpstan-baseline.php
...
...
This diff is collapsed.
Click to expand it.
.gitlab-ci/scripts/phpstan-baseline-statistics.php
0 → 100644
+
38
−
0
View file @
718a97e6
#!/usr/bin/env php
<?php
/**
* @file
* PHPStan baseline statistics.
*/
if
(
PHP_SAPI
!==
'cli'
)
{
return
;
}
$ignoreErrors
=
[];
require
__DIR__
.
'/../../core/.phpstan-baseline.php'
;
$stats
=
[
'__total'
=>
0
];
foreach
(
$ignoreErrors
as
$ignore
)
{
$identifier
=
$ignore
[
'identifier'
]
??
'* not specified *'
;
$count
=
$ignore
[
'count'
]
??
1
;
$stats
[
'__total'
]
+=
$count
;
$stats
[
$identifier
]
=
isset
(
$stats
[
$identifier
])
?
$stats
[
$identifier
]
+
$count
:
$count
;
}
echo
"----------------------------------------
\n
"
;
echo
"PHPStan baseline statistics
\n
"
;
echo
"----------------------------------------
\n
"
;
echo
sprintf
(
"%6d * Total baselined errors
\n
"
,
$stats
[
'__total'
]);
echo
"----------------------------------------
\n
"
;
echo
"Breakdown by error identifier:
\n
"
;
file_put_contents
(
__DIR__
.
'/../../phpstan-metrics.txt'
,
'phpstan-baseline '
.
$stats
[
'__total'
]
.
PHP_EOL
,
FILE_APPEND
);
unset
(
$stats
[
'__total'
]);
arsort
(
$stats
);
foreach
(
$stats
as
$identifier
=>
$stat
)
{
echo
sprintf
(
"%6d %s
\n
"
,
$stat
,
$identifier
);
file_put_contents
(
__DIR__
.
'/../../phpstan-metrics.txt'
,
'phpstan-baseline.'
.
$identifier
.
' '
.
$stat
.
PHP_EOL
,
FILE_APPEND
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment