Problem/Motivation
To be more effecient and fast in developing for Drupal we should find failures in the testsuites as quickly as possible. Currently if i work on jsonapi i need to wait ages to get to jsonapi tests. What if we prioritize the running of tests of changed modules/parts of core and fail on that.
"Fix the system you are working in first, then test integration in the rest of Drupal"
- Check what files have changes
- Identify the subsystem/core/vendor that have changes
- Run tests for those modules first (and stop on failure)
- Then run the rest of the tests
This would surface errors earlier, and make sure we get feedback as fast as possible. This also saves testing minutes since we start with tests that are most likely to break. The chance a change in migrate breaks menu's is rather small.
Source: https://drupal.slack.com/archives/CGKLP028K/p1694092091417259
Comments
Comment #2
bbralaComment #3
fjgarlin commentedComment #4
bbralaComment #5
fjgarlin commentedSince #3386076: GitLab CI integration for core is merged, shouldn't we move this issue to core? Or do you prefer to keep it in this project as "playground"?
I'm going through the issues and closing the ones I can in favour of core follow-ups.
Comment #6
bbralaAgree, but not sure what meta to hang it under
Comment #7
fjgarlin commentedAdded it under #3387107: [meta] GitLab CI feature parity with DrupalCI.
Comment #8
larowlanIn theory we could align labels in MRs with @group annotations on the tests and run those first
Comment #9
catchI think --directory might be broken in run-tests.sh, or at least it seemed to be when I tried to use it, but we could probably figure out core + module directories from the git diff and run those when they're changed using --directory. However that wouldn't help for composer updates so would need to account for that kind of change too.
Comment #10
bbralaDirectory could work, there is also module argument it seems.
But a filter on directory is easy enough for the testlist. We'd also need an negative filter though.
--skip "list of dirs/modules" and
--only "list of dirs/modules"
Comment #11
catchOnly concern I have about this is that after #3386474: [omnibus] Speed up gitlab ci runs we'll have 12-15 minute feedback on all-green tests, if we add an extra stage, green MR runs will take longer to report back and run more jobs, even if failures come back quicker.
Comment #12
catchWe might want to look at https://gitlab.com/gitlab-org/gitlab/-/issues/23605 too (not implemented but lots of demand). With #3387706: Don't make other tests depend on PHPUnit we'd run unit tests parallel to other tests (so all tests run earlier instead of waiting), but if we were able to interrupt and cancel jobs when any of the test fails, that feedback would go onto the overall pipeline status/issue a lot quicker -
i.e. a unit test failure cancels the other tests and reports back. Then you fix the unit tests and the others will go until one type fails and it reports back, and etc.
Comment #13
bbralaIt's a tradeoff. Testing changed stuff first would help getting to green faster from a contributer standpoint. Just if all is fine it might take longer.
Sometimes the suite ran is pretty small if only changes are run but sometimes is might not be. Perhaps a step early, like phpunit, IF the changed testlist is smaller than x tests (let's say 100) is a way to go.
Comment #14
catchThat gives me an idea.
We could put this in the main/parent pipeline with the lint steps, that way the smaller subset of tests would run parallel to the linting jobs. This would address three things - you'd be able to see some test results even if linting fails, you'd see them at the earliest possible point, and because it would run in parallel with linting it's not adding an extra blocking stage to the whole run. Also the pods used for this step would then get re-used by the child/full test runs.
Comment #15
bbralaYapp that's what I was thinking. Only possible hard part;
Are changes in core/lib one set or do we segregate there also ;) that might be a challenge.
Comment #16
catchMaybe for core/lib we could run only unit + kernel from core/tests and not functional/functional javascript? That'd be quick enough, then if you're unlucky enough that you only get a failure in a functional test, you just have to wait for the full run.
Otherwise it's either the MR tags idea or completely re-organising core components to ship their own test coverage etc., which... maybe in five years or so?
Comment #17
bbralaSo basically:
Create a list based on module, matching /modules/module/ in the path, or core with core/lib in the path. Unique that list and either filter the testlist or inverse filter the testlist.
That would be an easy poc.