Fix composer job to allow cspell and phpstan to run

Created on 15 January 2025, 3 months ago

Problem/Motivation

When testing this module with a Gitlab Templates MR I noticed that it has a customized "composer" job. It has one extra line

composer config platform.ext-sodium $_TARGET_PHP --file=composer.json

in the middle of the job script, but it also has lots of other things missing. This is causing the cspell and PHPStan jobs to fail.

The file has the variables to opt in to testing "max php version", "previous minor" and "next minor" but these variants do not have the same customization.

Proposed resolution

Investigate if the additional composer config command could be executed in after_script which would allow the entire customized script section to be deleted, thus return back to the gitlab templates original. This would mean that cspell and phpstan could run as required.

Remaining tasks

📌 Task
Status

Active

Version

2.0

Component

Code

Created by

🇬🇧United Kingdom jonathan1055

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

Merge Requests

Comments & Activities

  • Issue created by @jonathan1055
  • Merge request !38#3499969 composer script customizations → (Merged) created by jonathan1055
  • Pipeline finished with Failed
    3 months ago
    Total: 285s
    #396839
  • Pipeline finished with Success
    3 months ago
    Total: 163s
    #396856
  • Pipeline finished with Success
    3 months ago
    Total: 160s
    #396867
  • 🇬🇧United Kingdom jonathan1055

    As a first attempt I have moved the line into after_script and added composer update. This might be correct, but I don't know enough about how the Sodium extension to verify it.

    But this change has had the intended result that phpstan and phpcs run and pass green, and cpsell is actually running instead of crashing at the start.
    Compare this new pipeline https://git.drupalcode.org/issue/openid_connect_windows_aad-3499969/-/pi...
    with the previous latest one https://git.drupalcode.org/project/openid_connect_windows_aad/-/pipeline...

    There was a custom 'show-environment-variables' which is identical to the gitlab templates version except that it exposes the users personal email and other PID. Is there a specific reason why you can't use the version provided by gitlab. I have added _SHOW_ENVIRONMENT_VARIABLES: 1 so that these are displayed in each of the composer jobs.

  • Pipeline finished with Success
    3 months ago
    Total: 162s
    #396885
  • 🇬🇧United Kingdom jonathan1055

    Also I have removed

    SKIP_STYLELINT: 1
    SKIP_ESLINT: 1
    

    There is no need to skip stylelint because the project has no .css files, so the job is never added (that fix was implemented in gitlab templates maybe after you added this variable)

    The project does not have any .js files, but eslint does check the validity of all *.yml so it is worth having this job enabled. By default .yml are all ignored for 'prettier' formatting, so you will not be getting warning about that. This was also a later fix in gitlab templates. The job passes green.

  • 🇬🇧United Kingdom jonathan1055

    Update title and I.S.

  • 🇮🇳India akulsaxena

    The changes LGTM
    PHPCS, CSPELL and PHPSTAN are now running and not crashing at start
    Moving to RTBC+

  • 🇬🇧United Kingdom jonathan1055

    Excellent, thank you. As the custom .show-environment-variables is no longer used or required I will remove that from the file.

  • 🇮🇳India akulsaxena

    Cool, Since it isn't required, it can be removed! go ahead!

  • Pipeline finished with Canceled
    3 months ago
    Total: 88s
    #397590
  • Pipeline finished with Success
    3 months ago
    Total: 151s
    #397593
  • 🇬🇧United Kingdom jonathan1055

    Done.

    I have also replaced $_TARGET_PHP with $PHP_VERSION in the single line in the after_script. The reason is that $_TARGET_PHP is the same for all variants but $PHP_VERSION varies and is derived correctly for the variant being run. If you decided that you did need this step for the 'max php' variant then you will now have the correct max php value.

  • 🇮🇳India akulsaxena

    Great

    The deprecated $_TARGET_PHP has been replaced with $PHP_VERSION
    unrequired .show-environment-variables has been removed
    PHPCS, CSPELL and PHPSTAN are now running and not crashing at start

    All pipelines are passing except cspell, for which an issue 📌 Make code pass cspell Active has already been created.

    The status is already RTBC, i dont think we need to change that! This MR can be merged!
    Thanks!

  • 🇳🇱Netherlands batigolix Utrecht
  • 🇳🇱Netherlands batigolix Utrecht
  • Pipeline finished with Skipped
    about 1 month ago
    #436685
  • 🇳🇱Netherlands batigolix Utrecht

    Thanks for the help with this one.

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

Production build 0.71.5 2024