Switch to Gitlab CI as test runner

Created on 7 November 2023, 8 months ago
Updated 24 November 2023, 7 months ago

Problem/Motivation

The Drupal project is moving to using Gitlab CI to run tests. This project needs to do that as well. Ideally the project would pass tests without warnings.

Steps to reproduce

On https://git.drupalcode.org/project/genpass it lists the project with tests passing.

Proposed resolution

Currently there is one warning that might need investigation, but it looks like ELC has done most of the work in a few recent commits on the project.

Remaining tasks

  • ✅ File an issue
  • Branch: 2.0.x
    • ✅ Add .gitlab-ci.yml file
    • ✅ Add phpstan.neon
    • ✅ Configure OPT_IN_* vars as needed
    • ✅ Testing to ensure no regression
    • ✅ Fix errors & warnings
    • ✅ Remove Drupal CI testing on branch
  • Branch: 8.x-1.x
    • ✅ Add .gitlab-ci.yml file
    • ✅ Add phpstan.neon
    • ✅ Configure OPT_IN_* vars as needed
    • ✅ Testing to ensure no regression
    • ✅ Fix errors & warnings
    • ✅ Remove Drupal CI testing on branch
  • Branch: 7.x-1.x
    • ✅ Leave as DrupalCI for now
  • ✅ Code review by maintainers
  • ✅ Full testing and approval
  • ✅ Release notes snippet
  • ✅ Release 2.0.2

User interface changes

  • N/A

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

  • Added GitlabCI testing for 2.0.x branch
📌 Task
Status

Fixed

Version

2.0

Component

Code

Created by

🇺🇸United States greggles Denver, Colorado, USA

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

Merge Requests

Comments & Activities

  • Issue created by @greggles
  • 🇺🇸United States greggles Denver, Colorado, USA
  • 🇦🇺Australia ELC

    In the process of adding a phpstan.neon file to deal with the Unsafe usage of new static error.

    Given this is a contrib module, I'm following the same approach of Drupal core and turning off that error given "new static() is a best practice in Drupal, so we cannot fix that."
    https://www.drupal.org/docs/develop/development-tools/phpstan/handling-u...
    https://git.drupalcode.org/project/drupal/-/blob/10.0.x/core/phpstan.neo...

    The OPT_IN_* variables don't seem to be working at all - I thought that would given the opportunity to test Drupal 9, 10, and 11 against the code base to be able to tell when we needed a new branch, but none of them seem to work.

    Next step after get it working is to turn off DrupalCI for all branches.

    I'll add the commits to the 8.x-1.x branch, but I'm not sure it warrants a release there. It's just setting up testing so only if there is a security issue would that branch get a new release at this point.

  • Status changed to Needs review 8 months ago
  • 🇦🇺Australia ELC

    My local phpstan was complaining about being able to find any Drupal classes, and was not showing up the same errors that the GitlabCI was showing. Turns out my environment was missing phpstan/extension-installer despite it being required by 3 of the other requirements.

    For others, some experimenting with the OPT_IN_* variables indicates that the 4 spaces before the variable to indent it to the same level as the project def above it. The DA template doesn't make this apparent because it has the comment block without any indent at all. Added these back in an tests valid without warning on all

    There's a CI linter which is very very useful for making sure the .gitlab-ci.yml is valid, and that all of your variables are correct:
    https://git.drupalcode.org/project/genpass/-/ci/lint ; just replace the project name in that url. It's the "CI link" button, top right of the pipelines page.

    Does GitlabCI work on D7 branches? It doesn't usually run composer which is making me think not. If not it would seem that DrupalCI is going to hang around until D7 is finally closed off.

  • 🇺🇸United States greggles Denver, Colorado, USA

    I appreciate all your work and explanations of what you're doing!

    I am not sure about D7. I think we should focus this issue on the 2.0.x-dev branch and not worry about D7. I guess drupal.org will turn off drupalci when appropriate.

    I see it's passing now. Feel free to mark this as "fixed" whenever you are happy with it.

  • Status changed to Needs work 8 months ago
  • 🇦🇺Australia ELC

    Updated remaining tasks list.

    Switching to NW because of 8.x-1.x branch still needing to have testing switched over.

  • 🇦🇺Australia ELC

    This is "fixed" for the 2.0.x branch.

    The DA template is not going to work with the 8.x-1.x branch as it's testing against D10.1 when it needs to be testing against D9 only. D8 testing is long turned off. Will need to dive into the CI syntax and divert from the template to avoid it always trying D10 tests.

    This won't hold up 2.0.2.

    • ELC committed c794d879 on 8.x-1.x
      [#3399976] Remove phpstan.neon as not needed.
      
    • ELC committed 418ee656 on 8.x-1.x
      [#3399976] Specify core and php precisely.
      
    • ELC committed 393bf049 on 8.x-1.x
      [#3399976] Ignore known phpstan errors.
      
    • ELC committed 4abffc1a on 8.x-1.x
      [#3399976] Update tests for D9.x
      
      Will never be tested against D8 core...
    • ELC committed 8b8b6ed1 on 8.x-1.x
      [#3399976] Unfix core version. Add require-dev for phpstan.
      
  • Issue was unassigned.
  • Status changed to Fixed 8 months ago
  • 🇦🇺Australia ELC

    Sending back to main branch as we're fixed for both.

    Had to force the use of the drupal/core:9.5.x branch as by default it tests against D10. The D9 testing core does not include phpstan? The option was to turn it off with SKIP_PHPSTAN: '1', or add it as a require-dev for the branch of which I chose the latter because it meant actually checking if anything was wrong.

    Had to ignore a number of errors on 8.x-1.x branch:

    • Use of deprecated genpass_password(); The notice was to let others know of the change, not bog down this test
    • Use of deprecated ModuleHandlerInterface::getImplementations() since this test will never be run against D10 because this version is deprecated
    • Updated tests to D9 since they will never be run against D8 core on here again.

    That means we've turned off Drupal CI for all of the D8/9/10 versions.

    There is actually a way to test D7 core with Gitlab CI too; I ran into that while looking at this but lost the page. It would be possible to turn off DrupalCI for that branch too if the need arose. It really depends on any announcement from DA as D7 will be killed off Jan 2025, so whichever comes first.

    I did have the instructions on how to get Gitlab CI working on issue forks but I have lost that page too and can no longer find it. If someone could point me towards that it would be great! At present the issue forks are excluded from the workflow and the pipelines only run when there is a commit to a main branch. It has something to do with adding an array style variable to .gitlab-ci.yml.

  • 🇦🇺Australia ELC

    Just updating summary to tick off the 8.x-1.x branch changes to testing. Seems to be all done for now.

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

  • Status changed to Needs work 7 months ago
  • 🇦🇺Australia ELC

    Switching to NW for some small testing of gitlab config.

    Probably nothing to see here.

  • Merge request !18[#3399976] Fix OPT_IN_* scope. → (Merged) created by ELC
  • Status changed to Fixed 7 months ago
  • 🇦🇺Australia ELC

    Now the OPT_IN_* tests actually work and 2.0.x is being tested against the other versions of Drupal core, major/minor and PHP release.

    The indenting was an issue in .gitlab.yml, it was the missing "variables:" keyword.

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

Production build 0.69.0 2024