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 the PHP 7.2/MySQL 5.7 is used instead (MySQL 5.6 was not working) and PHP 8.2/pgsql-13.5, where PHP 8.2/pgsql-14.1 is used instead (PostgreSQL 14 was not working in DrupalCI)
  • .htaccess-parent part 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 system mysql database)

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

Command icon 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:

Comments

fjgarlin created an issue. See original summary.

longwave’s picture

Perhaps worth postponing on #3387055: Configure GitLabCI matrix testing as matrix testing of different PHP versions and database drivers is also important to D7.

poker10’s picture

Not sure about the matrix testing and how exactly it will work in GitlabCI, but currently the testing in DrupalCI is set as follows:

PHP 5.6 & MySQL 5.5
PHP 7.2 & MySQL 5.6
PHP 7.4 & MySQL 5.7
PHP 7.4 & PostgreSQL 9.5
PHP 7.4 & SQLite 3.27
PHP 8.0 & MySQL 5.7
PHP 8.1 & MySQL 5.7
PHP 8.2 & MySQL 8
PHP 8.2 & pgsql-13.5
  1. patches (or MRs) - triggers automatically PHP 8.1 + MySQL 5.7 and then we run manually all other combinations before pushed/merged, to verify it is working on all supported combinations
  2. push - all above combinations are run automatically
  3. there is no daily testing in 7.x branch

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 yml files to .htaccess, as D7 .htaccess is not blocking these currently (will create an issue for this).

fjgarlin’s picture

Assigned: Unassigned » fjgarlin
Status: Active » Postponed

Happy to wait. I will leave everything ready and follow up on that issue, then apply here.

fjgarlin’s picture

Status: Postponed » Active

We 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.

longwave’s picture

fjgarlin’s picture

What'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.

poker10’s picture

Thanks @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).

fjgarlin’s picture

Update:
- 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

fjgarlin’s picture

fjgarlin’s picture

fjgarlin’s picture

Status: Active » Needs review

This 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.

poker10’s picture

Status: Needs review » Needs work

Added some initial comments to the MR.

I am curious, if we should consider updating run-tests.sh as in D10:

+  if ((int) $args['ci-parallel-node-total'] > 1) {
+    $tests_per_job = ceil(count($test_list) / $args['ci-parallel-node-total']);
+    $test_list = array_slice($test_list, ($args['ci-parallel-node-index'] - 1) * $tests_per_job, $tests_per_job);
+  }

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!

fjgarlin’s picture

I'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!

fjgarlin’s picture

Status: Needs work » Needs review

All feedback from the above comments and MR has been addressed.
This is ready for review again.

poker10’s picture

Nice, 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.

fjgarlin’s picture

Assigned: fjgarlin » Unassigned

Good 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...

poker10’s picture

Priority: Normal » Major

Just 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:

  • tests combinations are according to the comment #4 (the current status in DrupalCI) -with the exception of PHP 7.2/MySQL 5.6, where the PHP 7.2/MySQL 5.7 is used instead (MySQL 5.6 was not working) and PHP 8.2/pgsql-13.5, where PHP 8.2/pgsql-14.1 is used instead (PostgreSQL 14 was not working in DrupalCI)
  • .htaccess-parent part 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
  • it includes this issue: #3387339: Integrate codequality reports into Gitlab
  • 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 system mysql database)

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!

poker10’s picture

Issue summary: View changes

Updated the IS with the summary.

fjgarlin’s picture

Thanks 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.

poker10’s picture

Issue summary: View changes

@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!

fjgarlin’s picture

mcdruid’s picture

Just getting up to speed with this issue - please forgive any silly questions :)

.setup-webroot: &setup-webserver
  before_script:
    - ln -s $CI_PROJECT_DIR /var/www/html/subdirectory
    - cp $CI_PROJECT_DIR/.gitlab-ci/.htaccess-parent /var/www/html/.htaccess
    - sudo service apache2 start

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?

poker10’s picture

No, we are not loosing the Drupal .htaccess, because Drupal is installed in a subdirectory /var/www/html/subdirectory and this special .htaccess is copied to the /var/www/html, so one level above it.

mcdruid’s picture

Ok, makes sense - thanks.

How about:

    # We need to pass this along directly even though it's set in the environment parameters.
    - sudo MINK_DRIVER_ARGS_WEBDRIVER="$MINK_DRIVER_ARGS_WEBDRIVER" -u www-data php ./scripts/run-tests.sh --color --concurrency "$CONCURRENCY" --url "$SIMPLETEST_BASE_URL" --verbose --fail-only ...snip...

Not sure we need the MINK related env variable(s) for D7? Can we remove them?

fjgarlin’s picture

Based 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.

poker10’s picture

It 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.

mcdruid’s picture

Status: Needs review » Reviewed & tested by the community

Nothing 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!

fjgarlin’s picture

Added 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.

poker10’s picture

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..?).

Yes, 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.

mcdruid’s picture

Issue tags: +RTBM

Thanks 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.

  • poker10 committed f7d135ce on 7.x
    Issue #3387052 by fjgarlin, poker10, mcdruid: [D7] GitLab CI integration...

poker10 credited andypost.

poker10’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -RTBM

Committed. Thanks everyone for working hard here to get this done!

Status: Fixed » Closed (fixed)

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

ilessing’s picture

as @mcdruid anticipated in #29 on Oct 23, 2023

apart from if individual sites have set up their own gitlab-ci integrations and the new files here clash..?)

the addition of Gitlab automation does clash with our use of Gitlab with Pantheon.