Test-only changes reverts changes to test modules

Created on 23 October 2023, 8 months ago
Updated 20 November 2023, 7 months ago

Problem/Motivation

Before gitlab ci we used to upload test-only patches. Now we have a "Test-only changes" job which reverts changes to non-test files. This also reverts changes to test modules, which means we can't reliable run the tests and expect them to fail.

Steps to reproduce

  • Write a failing test with a test module.
  • Submit a merge request.
  • Click the "Test-only changes" button.

Proposed resolution

Update pipeline configuration to exclude all files in tests/modules directories.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

šŸ› Bug report
Status

Fixed

Version

10.2 āœØ

Component
PHPUnitĀ  ā†’

Last updated less than a minute ago

Created by

šŸ‡¦šŸ‡ŗAustralia mstrelan

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

Merge Requests

Comments & Activities

  • Issue created by @mstrelan
  • šŸ‡ŖšŸ‡øSpain fjgarlin

    The current logic for reverting/deleting files is based on a very simple regex and some git diff filtering options.
    The code is here: https://git.drupalcode.org/project/drupal/-/blob/11.x/.gitlab-ci/pipelin...

          echo "1ļøāƒ£ Reverting non test changes"
          if [[ $(git diff refs/heads/${TARGET_BRANCH} --diff-filter=DM --name-only|grep -Ev "Test.php$"|grep -v .gitlab-ci|grep -v scripts/run-tests.sh) ]]; then
            git diff refs/heads/${TARGET_BRANCH} --diff-filter=DM --name-only|grep -Ev "Test.php$"|grep -v .gitlab-ci|grep -v scripts/run-tests.sh|while read file;do
              echo "ā†©ļø Reverting $file";
              git checkout refs/heads/${TARGET_BRANCH} -- $file;
            done
          fi
          if [[ $(git diff refs/heads/${TARGET_BRANCH} --diff-filter=A --name-only|grep -Ev "Test.php$"|grep -v .gitlab-ci|grep -v scripts/run-tests.sh) ]]; then
            git diff refs/heads/${TARGET_BRANCH} --diff-filter=A --name-only|grep -Ev "Test.php$"|grep -v .gitlab-ci|grep -v scripts/run-tests.sh|while read file;do
              echo "šŸ—‘ļøļø Deleting $file";
              git rm $file;
            done
          fi
    
  • šŸ‡¦šŸ‡ŗAustralia mstrelan

    Can we change the regex to filter on paths matching */tests/* or something like that?

  • šŸ‡®šŸ‡¹Italy mondrake šŸ‡®šŸ‡¹

    If I am not mistaken, another shortcoming is that if you do changes to an abstract test base class, that is reverted too. But you may want to test-only based on the base class changes.

  • šŸ‡ŖšŸ‡øSpain fjgarlin

    We can surely change the regex. We knew from the beginning that it'd be tricky to cover 100% of the cases. The current implementation covers a good percentage but obviously not all.

    We can open an MR and start experimenting with the "test-only" job. We can test changes by modifying additional files in the same MR that will eventually be reverted.

  • šŸ‡ŖšŸ‡øSpain fjgarlin

    I did a first MR showing where the changes would need to happen in the gitlabci file and also changed some other files so we can start debugging whether those files should be part of the test only or not. Right now I didn't force any errors, I just made an example.

    I don't think I can follow up on this task, at least this week, but I'm happy to review or guide if needed to the best of my knowledge.

    That MR is just a starting point.

  • Status changed to Needs review 7 months ago
  • šŸ‡ŖšŸ‡øSpain fjgarlin

    Needs further testing, but some review would be great.

  • Status changed to Needs work 7 months ago
  • šŸ‡ŗšŸ‡øUnited States smustgrave
    .gitlab-ci/pipeline.yml
    core/modules/book/book.module
    core/modules/book/tests/src/Unit/Menu/BookLocalTasksTest.php
    If this list contains more files than what you changed, then you need to rebase your branch.
    1ļøāƒ£ Reverting non test changes
    ā†©ļø Reverting core/modules/book/book.module
    

    But the issue is when a change is made to a module in the test folder right? Could we add a change to see?

  • Status changed to Needs review 7 months ago
  • šŸ‡ŖšŸ‡øSpain fjgarlin

    As I mentioned on #7, I didn't have more time so couldn't follow up because I needed to jump on other things.

    I managed to do changes as requested in #9 and it seems to be working well: https://git.drupalcode.org/issue/drupal-3395977/-/jobs/353569

    Note that I reopened šŸ› Test-only job shouldn't require constant rebases to detect which files were changed. Active so some of the changes seen in the MR are due to that, and of course, all those dummy changes that will be removed :-)

  • šŸ‡ŗšŸ‡øUnited States smustgrave

    This looks good! Once those changes are reverted can RTBC.

  • šŸ‡ŖšŸ‡øSpain fjgarlin

    All the test changes are now reverted and only the actual fix is left in the MR. Ready for final review.

  • Status changed to RTBC 7 months ago
  • šŸ‡ŗšŸ‡øUnited States smustgrave

    Think this is good!

    • catch ā†’ committed da166934 on 10.2.x
      Issue #3395977 by fjgarlin, smustgrave, mstrelan, mondrake: Test-only...
    • catch ā†’ committed 127eccde on 11.x
      Issue #3395977 by fjgarlin, smustgrave, mstrelan, mondrake: Test-only...
  • Status changed to Fixed 7 months ago
  • šŸ‡¬šŸ‡§United Kingdom catch

    Committed/pushed to 11.x and cherry-picked to 10.2.x, thanks!

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

Production build 0.69.0 2024