Fix GitLab CI configuration causing jobs to fail with warnings

Created on 21 February 2025, about 2 months ago

Problem/Motivation

Module's build pipelines on GitLab CI keep coming back with warnings for several jobs, in particular CSPELL and PHPSTAN, with what appears to be error messages caused by the CI build scripts.

See latest build:
https://git.drupalcode.org/project/admin_toolbar/-/pipelines/427983

Which prompted me to reach for help from the GitLab Templates project maintainers by creating the issue:
🐛 Help fixing jobs for Admin Toolbar Active

It appears the problem is caused by the CI template being pinned to version 1.5.10 introduced in commit:
https://git.drupalcode.org/project/admin_toolbar/-/commit/a25d54fe56935b...
corresponding to issue 🐛 Remove the now defunct menu items for Drupal 11 sites Needs review

Steps to reproduce

Run build pipeline on branch 3.x.

Proposed resolution

I'm not sure exactly why the template version had to be pinned when the change was committed, but probably the simplest solution would be to:

  • Revert the change in order to get back to using the latest version of the GitLab CI template scripts.
  • Fix any additional errors prompted by the build.
📌 Task
Status

Active

Version

3.0

Component

Code

Created by

🇫🇷France dydave

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

Merge Requests

Comments & Activities

  • Issue created by @dydave
  • Pipeline finished with Success
    about 2 months ago
    Total: 480s
    #430252
    • dydave committed c7667c63 on 3.x
      Issue #3508173 by dydave: Fixed GitLab CI configuration causing jobs to...
  • 🇫🇷France dydave

    Quick follow-up on this issue:

    Reverted the GitLab CI configuration file to use an exact copy of the current template at:
    https://git.drupalcode.org/project/gitlab_templates/-/blob/main/gitlab-c...
    (copy/pasted)

    After reverting the config file, the following PHPUNIT Tests error appeared, see build:
    https://git.drupalcode.org/issue/admin_toolbar-3466125/-/pipelines/429702

    1) Drupal\Tests\admin_toolbar\Functional\AdminToolbarSettingsFormTest::testAdminToolbarSettingsForm
    Behat\Mink\Exception\ElementNotFoundException: Element matching xpath "//div[@class="toolbar-menu-administration"]//ul[contains(@class, "toolbar-menu")]//li[contains(@class, "menu-item")]//ul[@class="toolbar-menu"]//li[contains(@class, "menu-item") and contains(a, .) and not(contains(ul, .))]" not found.
    /builds/issue/admin_toolbar-3466125/vendor/behat/mink/src/WebAssert.php:465
    /builds/issue/admin_toolbar-3466125/tests/src/Functional/AdminToolbarSettingsFormTest.php:79
    

    Corresponding to the following check with xpath:

        // Check the menu item 'User interface' contains a link but not a menu item.
        $assert->elementExists('xpath', '//div[@class="toolbar-menu-administration"]//ul[contains(@class, "toolbar-menu")]//li[contains(@class, "menu-item")]//ul[@class="toolbar-menu"]//li[contains(@class, "menu-item") and contains(a, .) and not(contains(ul, .))]');
    

    I'm really not sure why this XPath expression works fine (passes) with

    • Previous major: 10.4.2
    • Previous minor: 11.0.8

     
    But fails with:

    • Next minor: 11.x-dev 134af09 (11.2.x)
    • PHP:8.3/8.4, Core stable: 11.1.2

     
    ... very confusing ...

    Maybe something changed with the PHPUnit libraries with different versions, or maybe in Drupal Core from version 11.1.x something changed with the way XPath expressions are evaluated?!
    I don't really know what could have changed and didn't look any further than that...
     

    Instead, I decided to try different XPath combinations and opted to change the expression:

    • from: li node contains a node and not ul
    • to: li node has exactly one child which is an a link tag.

     
    Resulting in the following expression:

        // Check the menu item 'User interface' has a single child 'a' link tag.
        $assert->elementExists('xpath', '//div[@class="toolbar-menu-administration"]//ul[contains(@class, "toolbar-menu")]//li[contains(@class, "menu-item")]//ul[@class="toolbar-menu"]//li[contains(@class, "menu-item") and count(child::*)=1 and child::*=a]');
    

    Which seemed to solve all PHPUnit tests 🥳
     

    At this point, all the jobs came back to passing green 🟢 \o/
    https://git.drupalcode.org/project/admin_toolbar/-/pipelines/430264

    Except the ones we already knew still had warnings:

     
    Since the merge request has absolutely no change impacting the actual module's code, I went ahead and merged the changes at #3.

    The latest 3.x build is now back to where it was before the template version was pinned, with almost all of the build jobs passing 🟢.
    https://git.drupalcode.org/project/admin_toolbar/-/pipelines/430273

    Marking this issue Fixed at this point.
    If any more changes or fixes are needed, they should be addressed in new issues.

    Feel free to let us know if you have any questions or concerns on any aspects of the latest code changes, this issue, or the project in general, we would surely be glad to provide additional information.
    Thanks in advance for your feedback and comments!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024