Project

General

Profile

Actions

Feature #44345

closed

Use SimpleCov's built-in HTML formatter instead of Redmine's own formatter

Added by Go MAEDA about 1 month ago. Updated 14 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Code cleanup/refactoring
Target version:
Resolution:
Fixed

Description

Redmine uses SimpleCov to measure test coverage. Running bin/rails test:coverage runs the test suite with coverage enabled and generates an HTML report in the coverage directory.

The report is currently generated by Redmine's own formatter, consisting of source:trunk/test/coverage/html_formatter.rb@24890 and two ERB templates (source:trunk/test/coverage/views@24890). I propose replacing it with SimpleCov's built-in HTML formatter.

Before (Redmine's custom formatter):

After (SimpleCov's built-in formatter):

Benefits:
  • We no longer have to maintain the custom formatter.
  • The report can be filtered by file name and coverage rate, and sorted by any column. The current report is a single flat table.
  • The SimpleCov CLI becomes usable. bundle exec simplecov open, report, and uncovered read coverage/coverage.json, which the custom formatter does not generate.
  • Files are grouped into tabs (Controllers, Models, Helpers, Libraries, ...) instead of being listed in a single table.
  • Branch and method coverage can be displayed if enabled later. The current templates support only line coverage.

The Redmine-specific links in the report header are dropped: the revision used to generate the report and the Continuous_integration wiki page. These were intended for reports published at https://www.redmine.org/builds/, which is no longer in operation.


Files

Actions #1

Updated by Marius BĂLTEANU about 1 month ago

  • Status changed from New to Resolved
  • Assignee set to Marius BĂLTEANU
  • Target version changed from Candidate for next major release to 7.1.0
  • Resolution set to Fixed

Nice!

I've committed the changes, thanks!

Actions #2

Updated by Marius BĂLTEANU about 1 month ago

  • File 0001-Add-SimpleCov-coverage-to-Github-Actions-test-workfl.patch added
  • Status changed from Resolved to Closed

Go MAEDA, what do you think if we run one test suite from the matrix with coverage enabled? Another option is to have a nightly run.

Actions #3

Updated by Marius BĂLTEANU about 1 month ago

  • File deleted (0001-Add-SimpleCov-coverage-to-Github-Actions-test-workfl.patch)
Actions #5

Updated by Marius BĂLTEANU about 1 month ago

  • Status changed from Closed to Resolved
Actions #6

Updated by Go MAEDA about 1 month ago

Marius BĂLTEANU wrote in #note-2:

Go MAEDA, what do you think if we run one test suite from the matrix with coverage enabled? Another option is to have a nightly run.

Just to make sure I understand correctly: to view the coverage report, we would need to open the Actions tab, download the artifact as a ZIP file, and extract it locally. Is that right?

If so, I probably wouldn't look at it very often, simply because it takes several steps to get there. That said, I don't object to adding it at all.

Actions #7

Updated by Marius BĂLTEANU about 1 month ago

Because I do not run the whole test suite on my local environment very often, my ultimate goal is to set up a coverage badge displaying the percentage value, as well as a visual breakdown of coverage trends over time.

Based on a quick research, there are two main paths for trend tracking:
  • SaaS Integration (e.g., Codecov / Coveralls): Hooks into GitHub Actions to store test history automatically and generate both the badge and trend graphs out of the box.
  • Self-hosted: Store historical .last_run.json execution data somewhere and then, render a custom dynamic badge via Shields.io. I'm not sure how to deal with trend history.
Actions #8

Updated by Go MAEDA 19 days ago

Now that SimpleCov 1.2 is in trunk (r25065), I propose enabling its cover_views and track_tests options for SimpleCov's HTML formatter.

cover_views:

ERB templates under app/views are now measured and included in the "Views" tab.

track_tests:

The report shows which tests executed each covered line. In the HTML report, every covered line shows a link such as "2 tests"; clicking the link lists the tests that exercised the line.

Actions #9

Updated by Marius BĂLTEANU 19 days ago

Go MAEDA wrote in #note-8:

Now that SimpleCov 1.2 is in trunk (r25065), I propose enabling its cover_views and track_tests options for SimpleCov's HTML formatter.

Looks good!

Actions #10

Updated by Go MAEDA 18 days ago

Marius BĂLTEANU wrote in #note-9:

Go MAEDA wrote in #note-8:

Now that SimpleCov 1.2 is in trunk (r25065), I propose enabling its cover_views and track_tests options for SimpleCov's HTML formatter.

Looks good!

Thank you, I have committed the change in r25069.

Actions #11

Updated by Go MAEDA 14 days ago

Marius BĂLTEANU wrote in #note-7:

Because I do not run the whole test suite on my local environment very often, my ultimate goal is to set up a coverage badge displaying the percentage value, as well as a visual breakdown of coverage trends over time.

The scope of this issue was to replace Redmine's custom HTML formatter with SimpleCov's built-in formatter, and that change has already been committed.

Running coverage in CI, tracking coverage over time, and displaying a badge are worth discussing, but I think these topics are outside the scope of this issue and involve several additional decisions. How about closing this issue and opening a separate one to continue that discussion?

Actions #12

Updated by Marius BĂLTEANU 14 days ago

  • Status changed from Resolved to Closed

Sure, no problem, I will open a new issue once I have some working code.

Actions #13

Updated by Marius BĂLTEANU 14 days ago

  • Assignee changed from Marius BĂLTEANU to Go MAEDA
Actions

Also available in: Atom PDF