Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
config_inspector
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
config_inspector
Merge requests
!6
Issue
#3391990
: Automated report on core config validatability
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue
#3391990
: Automated report on core config validatability
issue/config_inspector-3391990:3391990-automated-report-core
into
2.1.x
Overview
0
Commits
75
Pipelines
62
Changes
6
Merged
Wim Leers
requested to merge
issue/config_inspector-3391990:3391990-automated-report-core
into
2.1.x
1 year ago
Overview
0
Commits
75
Pipelines
62
Changes
6
Expand
0
0
Merge request reports
Compare
2.1.x
version 58
938c6155
1 year ago
version 57
938c6155
1 year ago
version 56
8ba05fb7
1 year ago
version 55
9cee77de
1 year ago
version 54
eb5c7426
1 year ago
version 53
dcffb1aa
1 year ago
version 52
4447efe2
1 year ago
version 51
d03af27c
1 year ago
version 50
4890c528
1 year ago
version 49
01f7826d
1 year ago
version 48
0dc0ccd5
1 year ago
version 47
e4bbd022
1 year ago
version 46
a4907591
1 year ago
version 45
d8401972
1 year ago
version 44
33619441
1 year ago
version 43
828677e0
1 year ago
version 42
37f6418c
1 year ago
version 41
976f5065
1 year ago
version 40
dfc2bb61
1 year ago
version 39
cfd7badd
1 year ago
version 38
2e17ef1e
1 year ago
version 37
ec291d22
1 year ago
version 36
b4b2ab95
1 year ago
version 35
71b6d407
1 year ago
version 34
5f1faadc
1 year ago
version 33
cf13c113
1 year ago
version 32
d57d1aa3
1 year ago
version 31
5413f9fe
1 year ago
version 30
323ac859
1 year ago
version 29
d5ebff2e
1 year ago
version 28
94a81527
1 year ago
version 27
972e1d51
1 year ago
version 26
9d9f5833
1 year ago
version 25
155b7220
1 year ago
version 24
3c5a3032
1 year ago
version 23
25980c44
1 year ago
version 22
e8b24cf6
1 year ago
version 21
7ccd45a4
1 year ago
version 20
4d3f9e25
1 year ago
version 19
94080982
1 year ago
version 18
0a0b9bd0
1 year ago
version 17
128e4870
1 year ago
version 16
40948f1d
1 year ago
version 15
f4d8c60c
1 year ago
version 14
83fe3b81
1 year ago
version 13
52a49a98
1 year ago
version 12
26110992
1 year ago
version 11
4b469062
1 year ago
version 10
feb3ddfc
1 year ago
version 9
1b9680d5
1 year ago
version 8
aa93beeb
1 year ago
version 7
bd5309da
1 year ago
version 6
83cbad47
1 year ago
version 5
3f0f6581
1 year ago
version 4
df112c3f
1 year ago
version 3
2b295ec1
1 year ago
version 2
6c337f43
1 year ago
version 1
b5e40073
1 year ago
2.1.x (base)
and
latest version
latest version
938c6155
75 commits,
1 year ago
version 58
938c6155
75 commits,
1 year ago
version 57
938c6155
75 commits,
1 year ago
version 56
8ba05fb7
74 commits,
1 year ago
version 55
9cee77de
72 commits,
1 year ago
version 54
eb5c7426
72 commits,
1 year ago
version 53
dcffb1aa
70 commits,
1 year ago
version 52
4447efe2
69 commits,
1 year ago
version 51
d03af27c
67 commits,
1 year ago
version 50
4890c528
65 commits,
1 year ago
version 49
01f7826d
62 commits,
1 year ago
version 48
0dc0ccd5
60 commits,
1 year ago
version 47
e4bbd022
59 commits,
1 year ago
version 46
a4907591
58 commits,
1 year ago
version 45
d8401972
57 commits,
1 year ago
version 44
33619441
56 commits,
1 year ago
version 43
828677e0
54 commits,
1 year ago
version 42
37f6418c
50 commits,
1 year ago
version 41
976f5065
47 commits,
1 year ago
version 40
dfc2bb61
46 commits,
1 year ago
version 39
cfd7badd
43 commits,
1 year ago
version 38
2e17ef1e
42 commits,
1 year ago
version 37
ec291d22
41 commits,
1 year ago
version 36
b4b2ab95
40 commits,
1 year ago
version 35
71b6d407
39 commits,
1 year ago
version 34
5f1faadc
38 commits,
1 year ago
version 33
cf13c113
37 commits,
1 year ago
version 32
d57d1aa3
36 commits,
1 year ago
version 31
5413f9fe
35 commits,
1 year ago
version 30
323ac859
33 commits,
1 year ago
version 29
d5ebff2e
32 commits,
1 year ago
version 28
94a81527
31 commits,
1 year ago
version 27
972e1d51
30 commits,
1 year ago
version 26
9d9f5833
28 commits,
1 year ago
version 25
155b7220
27 commits,
1 year ago
version 24
3c5a3032
26 commits,
1 year ago
version 23
25980c44
24 commits,
1 year ago
version 22
e8b24cf6
23 commits,
1 year ago
version 21
7ccd45a4
22 commits,
1 year ago
version 20
4d3f9e25
21 commits,
1 year ago
version 19
94080982
20 commits,
1 year ago
version 18
0a0b9bd0
19 commits,
1 year ago
version 17
128e4870
18 commits,
1 year ago
version 16
40948f1d
17 commits,
1 year ago
version 15
f4d8c60c
16 commits,
1 year ago
version 14
83fe3b81
15 commits,
1 year ago
version 13
52a49a98
14 commits,
1 year ago
version 12
26110992
13 commits,
1 year ago
version 11
4b469062
12 commits,
1 year ago
version 10
feb3ddfc
11 commits,
1 year ago
version 9
1b9680d5
10 commits,
1 year ago
version 8
aa93beeb
9 commits,
1 year ago
version 7
bd5309da
8 commits,
1 year ago
version 6
83cbad47
7 commits,
1 year ago
version 5
3f0f6581
6 commits,
1 year ago
version 4
df112c3f
5 commits,
1 year ago
version 3
2b295ec1
4 commits,
1 year ago
version 2
6c337f43
3 commits,
1 year ago
version 1
b5e40073
2 commits,
1 year ago
6 files
+
412
−
3
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
6
Search (e.g. *.vue) (Ctrl+P)
scripts/config-validatability-report.php
0 → 100644
+
189
−
0
Options
<?php
/**
* @file
* Script to analyze the last core commit of every day since a start date.
*/
declare
(
strict_types
=
1
);
// phpcs:disable
// To run this repeatedly while developing: git tag | grep 10.99 | xargs -n 1 git tag -d && php config-validatability-report.php
// phpcs:enable
$branch
=
'11.x'
;
$utc
=
new
DateTimeZone
(
"UTC"
);
$start
=
new
DateTime
(
$argv
[
1
]
??
"2023-01-01 00:00:00"
,
$utc
);
$now
=
new
DateTimeImmutable
(
"now"
,
$utc
);
$interval
=
$now
->
diff
(
$start
);
print
sprintf
(
"🚀 Analyzing
\e
[1;37;44m%d days
\e
[0m (from %s to %s)…
\n
"
,
$interval
->
days
,
$start
->
format
(
"Y-m-d H:i:s P"
),
$now
->
format
(
"Y-m-d H:i:s P"
),
);
$rev_original
=
@
shell_exec
(
'git rev-list -n 1 HEAD'
);
$rev_previous
=
$result_previous
=
NULL
;
$statistics
=
fopen
(
'statistics.csv'
,
'w'
);
fputcsv
(
$statistics
,
[
'date'
,
'when'
,
'overall'
,
'objectPropertyPathsValidatable'
,
'objectPropertyPathsFullyValidatable'
,
'typesInUsePartiallyValidatable'
,
'typesInUseFullyValidatable'
,
'typesFullyValidatable'
,
]);
$index
=
1
;
$day
=
$start
;
do
{
// Gather all info about this day.
$when
=
$day
->
format
(
"Y-m-d H:i:s P"
);
$date
=
$day
->
format
(
"Y-m-d"
);
$rev_current
=
@
shell_exec
(
"git rev-list -n 1 --before='
$when
' origin/
$branch
"
);
$rev_current_info
=
@
shell_exec
(
"git log --oneline -n 1
$rev_current
"
);
// Jump to next day.
$day
->
modify
(
'+24 hours'
);
// Analyze this day.
if
(
$rev_current
==
$rev_previous
)
{
$assessment
=
$assessment_previous
;
}
else
{
$assessment
=
assess_revision
(
$rev_current
,
$index
++
,
$date
);
}
$result
=
compute_result
(
$assessment
);
$progress
=
match
(
TRUE
)
{
$result_previous
===
NULL
=>
'same'
,
$result
>
$result_previous
=>
'better'
,
$result
<
$result_previous
=>
'worse'
,
default
=>
'same'
,
};
foreach
(
$assessment
->
prep_output
as
$prep_output_line
)
{
print
$prep_output_line
;
}
print
sprintf
(
"🕰️
\e
[1;37;44m%s
\e
[0m → %s%03.2f%%
\e
[0m %s
\n
"
,
$when
,
match
(
$progress
)
{
'same'
=>
"
\e
[1;37;40m"
,
'better'
=>
"
\e
[1;37;42m"
,
'worse'
=>
"
\e
[1;37;41m"
,
},
$result
,
$rev_current
==
$rev_previous
?
"⏩ No commits this day."
// Limit each line to 200 columns.
:
'('
.
mb_strimwidth
(
rtrim
(
$rev_current_info
),
0
,
154
,
'…'
)
.
')'
,
);
fputcsv
(
$statistics
,
[
$date
,
$when
,
$result
,
$assessment
->
objectPropertyPathsValidatable
,
$assessment
->
objectPropertyPathsFullyValidatable
,
$assessment
->
typesInUsePartiallyValidatable
,
$assessment
->
typesInUseFullyValidatable
,
$assessment
->
typesFullyValidatable
,
]);
// Prepare for tomorrow.
$rev_previous
=
$rev_current
;
$result_previous
=
$result
;
$assessment_previous
=
$assessment
;
}
while
(
$day
<
$now
);
print
"📊 Analysis complete. See statistics.csv (raw data in statistics/*.json).
\n
"
;
fclose
(
$statistics
);
/**
* Computes a detailed assessment for the given revision.
*
* @param string $revision
* A revision, which must be newer than the previously assessed revision.
* @param int $day
* A monotonically increasing integer (representing the Nth day).
* @param string $date
* A `Y-m-d` string: a calendar date representation corresponding to $day.
*
* @return \stdClass
* A detailed assessment.
*/
function
assess_revision
(
string
$revision
,
int
$day
,
string
$date
):
\stdClass
{
static
$installed
;
$prep_output
=
[];
// Forceful checkout because the composer.lock file was modified due to
// requiring Drush.
// TRICKY: checkouts result in detached states, which in turn results in
// Composer not being able to deduce a version.
$dbg_git_checkout
=
shell_exec
(
"git reset --hard --quiet
$revision
"
);
// TRICKY:
// 1. Work around composer deciding we're at version 1.0.0 (if we do a
// checkout of the rev)
// 2. Branches require more I/O (slower).
// 3. So pretend there is a Drupal 10.99 minor, and tag a "patch release" per
// day.
// 4. This also aids in debugging: if the script crashes, just do
// `git diff TAG1 TAG2`.
@
shell_exec
(
"git tag 10.99.
$day
"
);
if
(
!
isset
(
$installed
))
{
print
"🤖 Installing Drupal's standard install profile…
\n
"
;
@
shell_exec
(
"composer require drush/drush --quiet"
);
@
shell_exec
(
"php core/scripts/drupal install standard --quiet"
);
@
shell_exec
(
"vendor/bin/drush pm:install config_inspector --yes --quiet"
);
$installed
=
TRUE
;
}
$prev
=
$day
>
1
?
$day
-
1
:
$day
;
// Composer install if lock file changed, and reinstall drush.
$prep_output
[]
=
@
shell_exec
(
"git diff 10.99.
$prev
10.99.
$day
--name-only | grep -q composer\.lock && echo '🤖 Reinstalling Composer packages (including Drush) because composer.lock has changed…' && composer require drush/drush --quiet"
);
// Ensure `drush config:inspect --statistics` keeps working.
$prep_output
[]
=
@
shell_exec
(
"git diff 10.99.
$prev
10.99.
$day
--name-only | grep -q '.install$\|.post_update\.php$' && echo '🤖 Installing DB updates…' && vendor/bin/drush updatedb --yes --quiet"
);
$prep_output
[]
=
@
shell_exec
(
"git diff 10.99.
$prev
10.99.
$day
--name-only | grep -q '.schema\.yml$' && echo '🤖 Erasing discovery cache because config schema changed…' && vendor/bin/drush cc bin discovery --quiet"
);
$prep_output
[]
=
@
shell_exec
(
"git diff 10.99.
$prev
10.99.
$day
--name-only | grep -q '\/Validation\/' && echo '🤖 Rebuilding container because validation constraints were added or modified…' && vendor/bin/drush cr --quiet"
);
// Actually gather statistics.
@
shell_exec
(
"vendor/bin/drush config:inspect --statistics > statistics/
$date
.json"
);
$assessment_json
=
@
shell_exec
(
"jq -r .assessment statistics/
$date
.json"
);
$assessment
=
json_decode
(
$assessment_json
);
$assessment
->
prep_output
=
$prep_output
;
return
$assessment
;
}
/**
* Computes a single percentage "result" based on the detailed assessment.
*
* @param \stdClass $assessment
* A detailed assessment.
*
* @return float
* A percentage, >=0 and <=100.
*/
function
compute_result
(
\stdClass
$assessment
)
:
float
{
// ⚠️ When this reaches 100%, it only means the types in use in THIS INSTALL
// are fully validatable!
return
(
// 50% of the impact: types in use fully validatable?
(
// The percentage that is ready.
$assessment
->
objectPropertyPathsFullyValidatable
+
// Assume that the percentage that is partially ready is only half ready.
(
$assessment
->
objectPropertyPathsValidatable
-
$assessment
->
objectPropertyPathsFullyValidatable
)
*
0.5
)
+
// The other 50% of the impact: object property paths fully validatable?
(
// The percentage that is ready.
$assessment
->
typesInUseFullyValidatable
+
// Assume that the percentage that is partially ready is only 1/3rd ready.
(
$assessment
->
typesInUsePartiallyValidatable
-
$assessment
->
typesInUseFullyValidatable
)
*
0.33
)
)
// The above summed two percentages that both must reach 100%.
/
2
// Convert to number in the [0, 100] range.
*
100
;
}
Loading