Add a "Validatable config" tests job to GitLab CI to help core evolve towards 100% validatability

Created on 20 February 2024, 4 months ago
Updated 16 April 2024, 2 months ago

Problem/Motivation

This is inspired by πŸ“Œ Add a performance tests job to gitlab and send data to OpenTelemetry Needs review .

This will help 🌱 [meta] Add constraints to all config entity types Active + 🌱 [meta] Add constraints to all simple configuration Active reach their goals, to eventually reach 🌱 [META] Untie config validation from form validation β€” enables validatable Recipes, decoupled admin UIs … Active :

I’ve already automated the high-level monitoring outside of core, through a scheduled CI pipeline in the config_inspector module, which results in a nightly update of https://project.pages.drupalcode.org/config_inspector/ (raw output for generating that chart is also available, which is interpreted by a script to transform all that into a single .csv file, plus an R script to generate the chart). It’s all powered by drush config:inspector --statistics.

Of course, that chart is kinda hard to discover. Ideally, whenever a config/schema/*.schema.yml file is modified (or a .module file containing a hook_config_schema_info_alter()), I want a new Config validatability CI job in Drupal core’s CI to both visualize + diff, to inform the core contributor of this MR’s impact using:

  1. a subset of the chart at https://project.pages.drupalcode.org/config_inspector/ to visualizes the impact
  2. a plain text git diff-like output that shows % decrease/increase, lists specifically which config types/objects are now less/more validatable

This would make the impact of πŸ“Œ Allow vocabularies to be validated via the API, not just during form submissions RTBC , πŸ“Œ Add validation constraints to announcements_feed.settings RTBC and ✨ New config schema data type: bytes Needs review (the three currently RTBC "config schema + validation" issues, one targeting all config entities of a certain type, one targeting a simple config object, one targeting a single config schema type) much easier to understand.

This would be very helpful for the core contributor DX IMHO.

Steps to reproduce

N/A

Proposed resolution

  1. When a MR makes NO CHANGES wrt config schema, do not bother running the new job, but allow it to be triggered manually: works βœ…
  2. When a MR makes MORE config validatable, the job must PASS: works βœ…
  3. When a MR makes FEWER config validatable, the job must FAIL: works βœ…
  4. Per feedback from @longwave, this was made resilient against the scenario where either https://github.com/drush-ops/drush or https://www.drupal.org/project/config_inspector β†’ does not have a core-compatible release: in that case the CI job is allowed to fail πŸ‘
  5. Per feedback from @alexpott, this was expanded to not just verify this for the config schema + default config when installing the Standard install profile, but also that of all core modules. When removing a validation constraint from a module not installed by Standard, the new CI job also fails now πŸ‘.

Remaining tasks

TBD

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

None.

✨ Feature request
Status

Fixed

Version

10.3 ✨

Component
ConfigurationΒ  β†’

Last updated 42 minutes ago

Created by

πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @Wim Leers
  • Pipeline finished with Failed
    4 months ago
    #99424
  • Merge request !6700New "Config validatability" GitLab CI job β†’ (Closed) created by Wim Leers
  • Pipeline finished with Failed
    4 months ago
    #99426
  • Pipeline finished with Canceled
    4 months ago
    Total: 76s
    #99432
  • Pipeline finished with Canceled
    4 months ago
    #99436
  • Pipeline finished with Canceled
    4 months ago
    #99445
  • Pipeline finished with Failed
    4 months ago
    Total: 161s
    #99451
  • Pipeline finished with Failed
    4 months ago
    Total: 160s
    #99459
  • Issue was unassigned.
  • Status changed to Needs review 4 months ago
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    To my own surprise, this pretty much worked on the first try 🀯

    (Then again, I did already make a superset of all this work in config_inspector in πŸ“Œ Automated report on core config validatability Needs review , and that was much harder. So all the necessary pieces already existed.)

    Impact

    This would make the impact of πŸ“Œ Allow vocabularies to be validated via the API, not just during form submissions RTBC , πŸ“Œ Add validation constraints to announcements_feed.settings RTBC and ✨ New config schema data type: bytes Needs review (the three currently RTBC "config schema + validation" issues, one targeting all config entities of a certain type, one targeting a simple config object, one targeting a single config schema type) much easier to understand.

    Reviews/likely concerns

    I think there are a few obvious things to disagree with here:

    1. πŸ€” Is it okay for this job to install drush/drush? I could work around this, although there's no trivial way to install modules from the command line then.
    2. πŸ€” Is it okay for this job to install drupal/config_inspector? I could move the drush config:inspect --statistics logic into Drupal core, but that seems far worse, because it increases the maintenance burden of Drupal core?

    But … the complexity here is entirely isolated to this single new core CI job. At any point in time can we easily remove this job. In fact, once the linked meta/plan issues are complete, I'd vote to remove this CI job. It's only a tool to help core's velocity and improve both contributor and committer DX.

  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    This would also help make the Recipes initiative more likely to succeed, because more validatable config leads to more reliable recipes, which should lead to a stronger Recipes ecosystem.

  • Pipeline finished with Success
    4 months ago
    #99470
  • Status changed to Needs work 4 months ago
  • πŸ‡ͺπŸ‡ΈSpain fjgarlin

    I added some feedback to the MR. All minor, some of them are questions.

  • Pipeline finished with Success
    4 months ago
    Total: 483s
    #99537
  • Status changed to Needs review 4 months ago
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Feedback addressed!

  • πŸ‡ͺπŸ‡ΈSpain fjgarlin

    It looks good from my end. I like that it is self-contained, as you intended from the beginning.
    I'd mark it as RTBC but I think issues like bringing "drush" need to be reviewed by a core maintainer to see the feasibility of this (temporary) job, so I'll leave it as Needs Review.

    Great work!

  • Pipeline finished with Success
    4 months ago
    Total: 547s
    #99579
  • πŸ‡¬πŸ‡§United Kingdom longwave UK

    The one issue I see is that when we switch to main or open a new branch for core development, what happens when composer require drush/drush drupal/config_inspector starts failing because there is no compatible package yet? Given this runs on any change to a .module file then this is likely to make MRs on a new branch fail even if they are nothing to do with config schema.

    But, perhaps we just deal with that when it happens by altering the job?

  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    The one issue I see is that when we switch to main or open a new branch for core development, what happens when composer require drush/drush drupal/config_inspector starts failing because there is no compatible package yet?

    1. config_inspector is already declaring 11.x compatibility and is explicitly testing daily with OPT_IN_TEST_NEXT_MAJOR.
    2. Drush is a different matter indeed.

    But, perhaps we just deal with that when it happens by altering the job?

    +1 to this.

    How about this for a pragmatic balance:

    1. composer require … today exits with code 1 upon failure β€” we can append || exit 99
    2. … then we could use allow_failure:exit_codes (docs) to specifically allow failure only for 99, but not for anything else

    Tada, graceful degradation! πŸ˜„

  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    @longwave Implemented what I proposed in #9 (but more explicitly/clearly) to address your concerns in #8: https://git.drupalcode.org/project/drupal/-/merge_requests/6700/diffs?co...

    So now it should not even be necessary anymore to "just deal with it whenever that [Drush not compatible with next major Drupal version] happens".

  • Pipeline finished with Success
    4 months ago
    Total: 1434s
    #100184
  • Status changed to Needs work 4 months ago
  • The Needs Review Queue Bot β†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

  • Pipeline finished with Success
    4 months ago
    Total: 635s
    #106846
  • Status changed to Needs review 4 months ago
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Merged in upstream, addressed feedback from @longwave & @alexpott.

  • Pipeline finished with Success
    4 months ago
    Total: 500s
    #106858
  • Pipeline finished with Failed
    4 months ago
    #106877
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Issue summary updated to reflect the crucial changes made to the original CI job to make it:

    • more resilient (@longwave review)
    • more complete (@alexpott review)
  • Pipeline finished with Success
    4 months ago
    #106886
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Neat!

    Am seeing additional modules are being installed

    [success] Successfully enabled: action, ban, basic_auth, book, config_translation, content_moderation, content_translation, datetime_range, field_layout, forum, help_topics, inline_form_errors, jsonapi, language, layout_builder, layout_discovery, locale, media, media_library, migrate, migrate_drupal, migrate_drupal_ui, mysql, pgsql, phpass, responsive_image, rest, sdc, serialization, settings_tray, statistics, syslog, telephone, tour, tracker, workflows, workspaces

    Seems like a neat feature but would this eventually be a failing check when we reach 100%? Is there a way to have certain things skipped? Example deprecated modules

  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Seems like a neat feature but would this eventually be a failing check when we reach 100%?

    How's that? We'd have to stay at 100%, then there'd be no failure. Status quo is proven to also not trigger test failures β€” see point 1 in the proposed resolution for an example.

    Is there a way to have certain things skipped? Example deprecated modules

    Sure, we can do that. When the need arises. Again: if this ever gets in the way of core development, we can just delete it!

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    In that case +1 but will leave in review for other eyes. Not sure I can mark it

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Is there any additional testing I can do to mark this RTBC?

  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    @smustgrave You can try marking more/fewer things as fully validatable and re-confirm that it all works as expected, like I did for the issue summary πŸ˜„

  • Status changed to Needs work 4 months ago
  • The Needs Review Queue Bot β†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

  • Status changed to Needs review 4 months ago
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί
    $ git merge origin/11.x
    Auto-merging .gitlab-ci.yml
    Merge made by the 'ort' strategy.
    <snip>
    

    πŸ‘

  • Pipeline finished with Failed
    4 months ago
    Total: 205s
    #112962
  • Status changed to Needs work 4 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave
    In install.core.inc line 964:
                                                                                   
      The submitted value <em class="placeholder">sqlite</em> in the <em class="p  
      laceholder">Database type</em> element is not allowed. 
    

    Not seen that one yet

  • Status changed to Needs review 4 months ago
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    #21: This MR cannot cause that. This must be a regression relating to switching to PHP 8.3 for all testing, or a random failure.

  • Assigned to Wim Leers
  • Status changed to Needs work 4 months ago
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Ah, this is in the new CI job! Then obviously it is possible πŸ˜… Though I have no idea what could've caused that… will investigate.

  • Issue was unassigned.
  • Status changed to Postponed 4 months ago
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Looks like this is no longer working because of a core regression: πŸ› Regression: Error installing standard profile with sqlite Active .

  • Pipeline finished with Success
    4 months ago
    Total: 622s
    #113931
  • Status changed to Needs review 4 months ago
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Okay, switching from drush site-install to core/scripts/drupal install unblocked this. πŸ˜„ (I'd remove drush altogether, but there's no way to install modules using core/scripts/drupal today, that's being proposed in #3089277: Provide core CLI commands for the most common features of drush β†’ .)

    That means this is unblocked! πŸ₯³

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Don't mind marking if you want to remove that one change in core/config/schema/core.data_types.schema.yml

    And question but do you want to lock down the version of config_inspector it pulls or fine with grabbing the latest?

  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Don't mind marking if you want to remove that one change in core/config/schema/core.data_types.schema.yml

    Done.

    And question but do you want to lock down the version of config_inspector it pulls or fine with grabbing the latest?

    Grabbing latest is best. Let composer figure out the appropriate version for whichever core version. Because then we won't have to update the .gitlab-ci.yml to update to a newer version.

  • Pipeline finished with Success
    4 months ago
    Total: 631s
    #114008
  • Status changed to RTBC 4 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Makes sense!

  • Merge request !6974Core committer test β†’ (Closed) created by longwave
  • Pipeline finished with Canceled
    4 months ago
    Total: 340s
    #114688
  • Status changed to Needs work 4 months ago
  • πŸ‡¬πŸ‡§United Kingdom longwave UK

    I thought that we would need a similar check as per the cspell job where we take one SHA over another in some cases. But as that seems to work here maybe we can simplify that job as well? A task for another issue anyway.

    I was also concerned about these steps:

    git checkout $CI_MERGE_REQUEST_DIFF_BASE_SHA
    composer require drush/drush drupal/config_inspector || exit 100
    ...
    git checkout $CI_COMMIT_SHA
    

    The composer require modifies the following files:

    M	composer.json
    M	composer.lock
    M	composer/Metapackage/CoreRecommended/composer.json
    M	composer/Metapackage/PinnedDevDependencies/composer.json
    M	core/lib/Drupal/Component/Diff/composer.json
    

    If any of these are different between the branches, the second git checkout may fail due to conflicts, as proven in this job: https://git.drupalcode.org/project/drupal/-/jobs/1023410

    As we don't need Composer after installing Drush and Config Inspector maybe it is safe to git reset --hard before the second git checkout? Technically composer.json will be out of sync but it doesn't matter for the remainder of the job.

  • Pipeline finished with Success
    4 months ago
    Total: 554s
    #114701
  • Status changed to RTBC 4 months ago
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    I was also concerned about these steps:
    …
    As we don't need Composer after installing Drush and Config Inspector maybe it is safe to use git checkout -f here?

    Good suggestion! πŸ‘ Implemented: https://git.drupalcode.org/project/drupal/-/merge_requests/6700/diffs?co... β†’ passed βœ…

    Also updated your fork to verify it actually solves that edge case: https://git.drupalcode.org/project/drupal/-/merge_requests/6974/diffs?co... β†’ passed βœ…

  • Pipeline finished with Success
    4 months ago
    Total: 571s
    #114742
  • Pipeline finished with Success
    4 months ago
    Total: 502s
    #114743
  • πŸ‡¬πŸ‡§United Kingdom longwave UK

    Alright, let's give this a shot. Backported to 10.3.x to keep things in sync, I see no need to go back further with this one.

    Committed and pushed 566b7d32e3 to 11.x and b27e31dc01 to 10.3.x. Thanks!

    • longwave β†’ committed b27e31dc on 10.3.x
      Issue #3422641 by Wim Leers, longwave, smustgrave, fjgarlin: Add a "...
    • longwave β†’ committed 566b7d32 on 11.x
      Issue #3422641 by Wim Leers, longwave, smustgrave, fjgarlin: Add a "...
  • Status changed to Fixed 4 months ago
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    YAY!

    This allowed me to close πŸ“Œ Create test that reports % of config entity types (and config schema types) that is validatable Postponed . And … I updated one of the-in-progress config validation issues, and sure enough, it works great: #3422872-10: Add validation constraints to contact.settings β†’ 😊 Similarly, I checked a very important/huge scope issue ( 🌱 [META] Move code from the experimental SDC module to core Active ), I see that the job is running there (because it modified a .module file), and it's passing. So: it's not disrupting anything shortly after introduction at least. I'll be keeping an eye on this. Feel free to ping me directly if this ever gets in the way.

    I'm excited about how this will empower 🌱 [meta] Config validation for a more reliable Drupal + reliable Recipes from the start Active to move faster! πŸš€

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    This seems to be causing issues with MRs that are removing config entities

    https://git.drupalcode.org/issue/drupal-3432874/-/jobs/1126875

  • Status changed to Needs work 3 months ago
  • πŸ‡¬πŸ‡§United Kingdom catch

    Re-opening. Could we potentially count the raw number of validatable and unvalidatable config objects and then the test would need to be updated every time, but if we're removing a validatable config object, it would be easy to keep the test passing.

  • πŸ‡¬πŸ‡§United Kingdom longwave UK

    Or, should we just mark the job as allow_failure, so it still runs but doesn't block anything?

  • πŸ‡·πŸ‡΄Romania claudiu.cristea Arad πŸ‡·πŸ‡΄

    Not sure I've landed in the right place. I have two different MRs from two different issue. Both are changing or add schemas. And both are failing in this job. I have no idea what I'm doing wrong or what should I fix. I think the failure deserves a good error message in the job's log. Now is so opaque...

    My cases:

  • πŸ‡ͺπŸ‡ΈSpain rcodina

    I'm in the same situation of @claudiu.cristea. I have a MR which modifies image field settings to add a property. How can I pass the test if the MR.json will always be different from HEAD.json?

    .gitlab-ci.yml

    # Compute statistics for coverage of validatable config for MR.
    - vendor/bin/drush config:inspect --statistics > MR.json
    # Output diff, but never fail the job.
    - diff -u HEAD.json MR.json || true

    #3325551 ✨ Add "Disable image resize" setting to image fields Needs review > https://git.drupalcode.org/issue/drupal-3325551/-/jobs/1209260

  • Merge request !7275Allow validatable config job to fail β†’ (Open) created by acbramley
  • Status changed to Needs review 3 months ago
  • πŸ‡¦πŸ‡ΊAustralia acbramley

    Re #40 catch agreed we should allow failures until the kinks are ironed out https://drupal.slack.com/archives/C1BMUQ9U6/p1711664511341669?thread_ts=...

    Created an MR to allow that.

  • Pipeline finished with Success
    3 months ago
    Total: 657s
    #134887
  • Status changed to RTBC 3 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Hopefully helps the MRs

    #42 I rebased and the validations least didn’t stop the MR that time.

  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    Whatever happens next should be in a new issue.

    Committed and pushed 722ab9b218 to 11.x and 539e16021f to 10.3.x. Thanks!

    Let's do this and open a follow-up to make this fail again and improve the checking so it doesn't trigger false positives.

    • alexpott β†’ committed 539e1602 on 10.3.x
      Issue follow-up by #3422641 by acbramley, catch: Add a "Validatable...
  • Status changed to Fixed 3 months ago
    • alexpott β†’ committed 722ab9b2 on 11.x
      Issue follow-up by #3422641 by acbramley, catch: Add a "Validatable...
  • πŸ‡¦πŸ‡ΊAustralia acbramley
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024