Problem/Motivation
We've been trying to reproduce core testing with DrupalCI on GitLab CI in this project: https://www.drupal.org/project/gitlab_ci_testbed_for_drupal_core
There are regular updates on the progress in the #gitlab community slack channel as well as on issues created in that project.
Drupal 10+ is already using GitLab CI based on the suggestion made here #3386076: GitLab CI integration for core.
It is time now to do the same for Drupal 7.
Steps to reproduce
Drupal 7 core is not currently configured to run tests in GitLab CI.
Proposed resolution
Add the GitLab CI related files, and start testing DrupalCI and GitLab CI in parallel. Then consider turning off some DrupalCI tasks when GitLab CI seems stable enough to make the switch.
---------------
The MR currently contains the base settings for D7 testing according to the D10 committed code (pipeline.yml, .gitlab-ci.yml, run-tests.sh), with these changes:
- tests combinations are according to the comment #4 (the current status in DrupalCI) -with the exception of
PHP 7.2/MySQL 5.6, where thePHP 7.2/MySQL 5.7is used instead (MySQL 5.6 was not working) andPHP 8.2/pgsql-13.5, wherePHP 8.2/pgsql-14.1is used instead (PostgreSQL 14 was not working in DrupalCI) .htaccess-parentpart is needed for D7 to work correctly in the CI in subdirectory- it includes this issue: #3387959: Document new arguments in run-tests.sh
it includes this issue: #3386566: Add support for 'test only' changes to gitlab CI(already committed in D10 as well)it includes this issue: #3387339: Integrate codequality reports into Gitlab(already committed in D10 as well)- SQLite testing is working unlike in the D10 setup
- default testing is against PHP 8.1 (as we have in DrupalCI currently)
- there is no linting in D7 currently, so the patch adds only PHP compatibility check via PHPCS and only on changed files (we cannot run Drupal standards check, as it was not possible to restrict PHP version to PHP 5.6)
- Drupal 7 is installed via
drush si, so it needed to use different MySQL database name (not the systemmysqldatabase)
Remaining tasks
MR.
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
Drupal core now runs tests in GitLab CI.
Issue fork drupal-3387052
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3387052-d7-gitlab-ci
changes, plain diff MR !4765
Comments
Comment #2
longwavePerhaps worth postponing on #3387055: Configure GitLabCI matrix testing as matrix testing of different PHP versions and database drivers is also important to D7.
Comment #4
poker10 commentedNot sure about the matrix testing and how exactly it will work in GitlabCI, but currently the testing in DrupalCI is set as follows:
So I think this is a bit easier in comparission with D10, also given the fact that we have only phpcs (no other linting, etc). So if this could be set with the current config, I think we do not need to wait. But if the matrix testing will help here somehow, then OK.
But I think that we need to wait at least for the fix for test-only patches (#3386566: Add support for 'test only' changes to gitlab CI) + one additional blocker would be to add
ymlfiles to.htaccess, as D7.htaccessis not blocking these currently (will create an issue for this).Comment #5
fjgarlin commentedHappy to wait. I will leave everything ready and follow up on that issue, then apply here.
Comment #6
fjgarlin commentedWe were typing at the same time :-)
1. Would be achieved with easy tweaking from this proposal.
2. Can be easily achieved too.
3. No action needed.
So I will continue working based on the actions needed for 1 and 2 and will watch the "test-only" issue closely.
Comment #7
longwaveComment #8
fjgarlin commentedWhat's in the MR already is almost the equivalent of what landed in D10+ today.
I will work tomorrow on the changes suggested in #4.
Comment #9
poker10 commentedThanks @fjgarlin!
I have created a child issue to prevent access to YAML files, but this needs more discussion whether it is worth a change: #3387134: [D7] Prevent access to YAML files using .htaccess and web.config. So this is probably not a hard blocker (and it is possible that it will not be introduced).
Comment #10
fjgarlin commentedUpdate:
- The matrix and the rules for it mentioned in #4 are all in place now.
- I also took the coding standards task out of each matrix combination as this only needs to be run once.
The only remaining task is the "test-only" job, which I am going to address next.
Run with all the matrix in place: https://git.drupalcode.org/issue/drupal-3387052/-/pipelines/19980
Comment #11
fjgarlin commentedTaking test-only approach from #3386566: Add support for 'test only' changes to gitlab CI. WIP.
Comment #12
fjgarlin commentedSuccessful test-only run: https://git.drupalcode.org/issue/drupal-3387052/-/jobs/90810
Comment #13
fjgarlin commentedThis is now ready to review. All feedback from #4 was addressed (except the matrix combo that included MySQL 5.6 as agreed via slack).
MR: https://git.drupalcode.org/project/drupal/-/merge_requests/4765
- The pipeline with the whole matrix can be seen here: https://git.drupalcode.org/issue/drupal-3387052/-/pipelines/20447
- The test-only job can be seen here: https://git.drupalcode.org/issue/drupal-3387052/-/jobs/90810 (see also related Drupal 10+ issue #3386566: Add support for 'test only' changes to gitlab CI)
- The code already has many of the follow-ups that were created for D10+ in it.
Comment #14
poker10 commentedAdded some initial comments to the MR.
I am curious, if we should consider updating
run-tests.shas in D10:Can we benefit from it in D7 as well?
---------
If I checked the MR correctly, we are currently waiting for the test-only issue to get in to D10 (#3386566: Add support for 'test only' changes to gitlab CI), but other that that, it seems like the files does not contain anything special we need to wait for D10 issues? Is this correct?
Thanks!
Comment #15
fjgarlin commentedI'll see about the options for "run-tests.sh". Good suggestion.
We have no dependency on the other issue as I implemented the suggestion from it here. They might divert a bit but the core functionality is and will be the same.
I'll work on your feedback above today. Thanks!
Comment #16
fjgarlin commentedAll feedback from the above comments and MR has been addressed.
This is ready for review again.
Comment #17
poker10 commentedNice, the paralell runs looks good. Thanks for the great work here!
I was thinking, can we implement suggestions from these two issues/MRs as well?
#3387339: Integrate codequality reports into Gitlab - just for the PHPCS (if possible)
#3387959: Document new arguments in run-tests.sh - not sure about the wording, as it is not committed yet (we can keep an eye on the D10 issue), but just not to be forgotten
Other than that, I think this looks great and probably has all features/tweaks from D10 issue, which we need for the initial commit.
Comment #18
fjgarlin commentedGood suggestions, both of them are implemented now. I took the text from the D10 issue.
See a forced phpcs error code quality report here: https://git.drupalcode.org/issue/drupal-3387052/-/pipelines/21428/codequ...
Comment #19
poker10 commentedJust to summarize for reviewers:
The MR currently contains the base settings for D7 testing according to the D10 committed code (pipeline.yml, .gitlab-ci.yml, run-tests.sh), with these changes:
PHP 7.2/MySQL 5.6, where thePHP 7.2/MySQL 5.7is used instead (MySQL 5.6 was not working) andPHP 8.2/pgsql-13.5, wherePHP 8.2/pgsql-14.1is used instead (PostgreSQL 14 was not working in DrupalCI).htaccess-parentpart is needed for D7 to work correctly in the CI in subdirectorydrush si, so it needed to use different MySQL database name (not the systemmysqldatabase)Other than that I think the code is pretty much the same as in the D10 (hopefully have not forgotten to mention anything).
We need to decide here: #3387134: [D7] Prevent access to YAML files using .htaccess and web.config, but then the idea is to get this in, so that we can start testing the GitlabCI integration.
Thanks!
Comment #20
poker10 commentedUpdated the IS with the summary.
Comment #21
fjgarlin commentedThanks so much for updating the IS, it's so much easier to know everything that happened in this issue.
Do we need to tag some specific people so they can RTBC + feedback/commit this MR?
Core D10+ is already turning off some DrupalCI activity in favor of GitlabCI and it'd be great if we can start testing things here too.
Comment #22
poker10 commented@fjgarlin as these two issues are already committed in D10, do we need to update something in this MR?
#3386566: Add support for 'test only' changes to gitlab CI
#3387339: Integrate codequality reports into Gitlab
We need to go thru this with @mcdruid, so will update here if anything else is needed. Thanks!
Comment #23
fjgarlin commented#3386566: Add support for 'test only' changes to gitlab CI is in place already.
#3387339: Integrate codequality reports into Gitlab is in place already too.
Comment #24
mcdruid commentedJust getting up to speed with this issue - please forgive any silly questions :)
Does this mean we lose core's main .htaccess ?
If so, I'd think we want to append to core's file (or make replacements within it) rather than replace it?
Comment #25
poker10 commentedNo, we are not loosing the Drupal
.htaccess, because Drupal is installed in a subdirectory/var/www/html/subdirectoryand this special.htaccessis copied to the/var/www/html, so one level above it.Comment #26
mcdruid commentedOk, makes sense - thanks.
How about:
Not sure we need the MINK related env variable(s) for D7? Can we remove them?
Comment #27
fjgarlin commentedBased on DrupalCI. It's used here: https://git.drupalcode.org/project/drupalci_testbot/-/blob/dev/src/Drupa...
And the method is not overriden in https://git.drupalcode.org/project/drupalci_testbot/-/blob/dev/src/Drupa....
That doesn't mean we shouldn't remove it, but that's why I decide it to leave it. We can try without it and see if everything still works tho.
Comment #28
poker10 commentedIt seems like all tests are green even with MINK variables removed, see: https://git.drupalcode.org/project/drupal/-/pipelines/34972
So this indicate, that they were not used.
Comment #29
mcdruid commentedNothing else jumping out at me.
IIUC committing these changes should not affect anything other than the gitlab ci set up (i.e. are unlikely to cause any regressions on running D7 sites - apart from if individual sites have set up their own gitlab-ci integrations and the new files here clash..?).
I'm happy for this to be committed.
Thanks for all the work that's gone into getting this all set up!
Comment #30
fjgarlin commentedAdded something really small but really useful that was added here #3390658: GitLab should retry jobs that fail outside test failures.. Sometimes the gitlab runners have some hiccups that might make the job fail but a simple retry fixes it, so this small addition does that automatically.
Comment #31
poker10 commentedYes, I think this is correct. I do not think the small change in
run-tests.sh(to introduce paralell runs) could be somehow disruptible and other from that there are only new files being added.Comment #32
mcdruid commentedThanks for confirming re. risk of regressions.
The latest change to configure retries looks good.
Happy for this to be committed - @poker10 let me know if you'd prefer that I did so, but I don't think you'd be "committing your own patch" here much.
Comment #35
poker10 commentedCommitted. Thanks everyone for working hard here to get this done!
Comment #37
ilessing commentedas @mcdruid anticipated in #29 on Oct 23, 2023
the addition of Gitlab automation does clash with our use of Gitlab with Pantheon.