- Issue created by @mondrake
- Status changed to Active
about 2 months ago 6:55pm 10 March 2025 - ๐บ๐ธUnited States smustgrave
Unit tests are falling under linting stage now though?
- ๐ฎ๐นItaly mondrake ๐ฎ๐น
#5 yes, but not introduced here. See ๐ [CI] Introduce a separate stage for unit tests Active .
- ๐บ๐ธUnited States smustgrave
Going to go on a limb and say letโs try it
- ๐ช๐ธSpain penyaskito Seville ๐, Spain ๐ช๐ธ, UTC+2 ๐ช๐บ
Should we have a report on coverage with the artifacts generated, aside of the output?
- ๐ฎ๐นItaly mondrake ๐ฎ๐น
#8 I tried to configure coverage reporting, but it does not seem to produce any effect?
- ๐ฎ๐นItaly mondrake ๐ฎ๐น
With regards to #8, we already have had coverage visualization configured in the MR.
This is producing inline display of the covered line in the merge request diffs. It's not visible in this MR as it does include changes to components code, but an example is here: ๐ Introduce a @return-type-will-be-added annotation to indicate return type addition in next major; enforce with a PHPStan rule Active : in the MR visualization of changes https://git.drupalcode.org/project/drupal/-/merge_requests/10111/diffs#7... you can see that the covered code has a green sideline close to the line numbers.When it comes to summary metrics, IMHO the standard GitLab solution with adding a
coverage
key to the job yaml is insufficient, for the following reasons:- trivial but annoying: it is not compatible with color output by PHPUnit's coverage text reporting. If you set
--colors=always
to PHPUnit CLI command, the coverage text report includes ANSI color codes that the regex in coverage cannot cope with. - more importantly: the standard approach is limited to reporting line coverage only and averages results from different jobs - this would lead to meaningless figures if we were later to, say, have code coverage for core too as it will make simple average without any weighting etc.
So I will try to take cue from the work in ๐ [CI] Report PHPStan baseline statistics in job Active , and see if with some postprocessing of the coverage text report, we can get a metrics report that can be more tuned to Drupal.
- trivial but annoying: it is not compatible with color output by PHPUnit's coverage text reporting. If you set
- ๐ฎ๐นItaly mondrake ๐ฎ๐น
Added a small script that processes PHPUnit's coverage text report into an OpenMetrics file with the relevant metrics included.
See file attached with a screenshot of the resulting report in the MR.
- ๐ฎ๐นItaly mondrake ๐ฎ๐น
Added a small script that processes PHPUnit's coverage text report into an OpenMetrics file with the relevant metrics included.
See file attached with a screenshot of the resulting report in the MR.
- ๐บ๐ธUnited States smustgrave
Are the metrics suppose to be clickable?
- ๐ฎ๐นItaly mondrake ๐ฎ๐น
#15: see https://docs.gitlab.com/ci/testing/metrics_reports/
Apparently, not.
- ๐บ๐ธUnited States smustgrave
Guess it's still neat to have that info though it would be cool to know what classes aren't being covered. Maybe would start a new initiative :)
But having the info is a net improvement.
- ๐ฎ๐นItaly mondrake ๐ฎ๐น
#17 thatโs just the summary. All the details are visible in the raw logs https://git.drupalcode.org/issue/drupal-3485069/-/jobs/4674359 and as artifacts.
Obviously a code coverage analisys service (e.g. Codecov or the likes of it) would provide full interactive reporting, trends etc but I suppose itโs well beyond the scope of this issue.
- ๐ฌ๐งUnited Kingdom catch
The code coverage report is really nice to have here!
It looks like even though there's no concurrency, the number of tests here is low enough that the jobs still finish pretty fast.
However, can you confirm why each job needs 8 CPU when they're only running with single concurrency? I would have thought 1-2 CPU each would be enough.
- ๐ฎ๐นItaly mondrake ๐ฎ๐น
Huh, did not even look at that, was just a copypasta exercise. Let's see with 2.
- ๐ฎ๐นItaly mondrake ๐ฎ๐น
No sensible difference, I think the change is small enough to let me self-RTBC this back.
- ๐ฌ๐งUnited Kingdom catch
Yep let's do it. Committed/pushed to 11.x, thanks!
Would be good to open an issue to look into exporting/importing these into a visual code coverage report that we can link from somewhere on the project page, or something like that.