-
Notifications
You must be signed in to change notification settings - Fork 78
Add support for simplecov's new expected JSON output #441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! Tests look great 👏 I left a really small comment, feel free to ignore it if you feel it's not worth it.
formatters/simplecov/simplecov.go
Outdated
if err != nil { | ||
return legacyFormat(r, rep) | ||
} else { | ||
logrus.Debugf("Analyzing simplecov json output from latest format %s", r.Path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: would it be possible to move this logic into its own file similar to legacyFormat
to keep the same structure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I liked the suggestion thanks, addressed. Just couldn't find a more clever name to the new formatter than jsonFormatter
although it makes sense since it has been designed to read output from the SimpleCov's JsonFormatter.
@filipesperandio can I get your review here please ? I'm posting here since I cannot add you as a reviewer, I think it's due to the repo's permissions settings |
@fede-moya: You and @noelia-lencina should have write access to the repo now. 🤦 |
formatters/simplecov/simplecov.go
Outdated
var searchPaths = []string{"coverage/.resultset.json"} | ||
var simpleCovJsonFormatterPath, legacyPath string = "coverage/coverage.json", "coverage/.resultset.json" | ||
|
||
var searchPaths = []string{simpleCovJsonFormatterPath, legacyPath} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be inlined? Doesn't look like we use those vars anywhere else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍🏼
if err != nil { | ||
return rep, errors.WithStack(errors.Errorf("could not open coverage file %s", r.Path)) | ||
} | ||
rep, err = jsonFormat(r,rep) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused. Does this override what line 34 does?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind taking a new look ? I don't think I'm following the the question sorry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might have something confused in my head, not seeing a problem here anymore 🤦
Coverage map[string]formatters.Coverage `json:"coverage"` | ||
} | ||
|
||
func legacyFormat(r Formatter, rep formatters.Report) (formatters.Report, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like we always return rep
, can we avoid that and only return error
?
And the caller deal with the return it needs to pass? Like return rep, legacyFormat(r, rep)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might not be a go
thing, though... let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I liked your suggestion so I tested it out, but for some unknown reason to me tests just started to fail without a clear explanation. Check dacd033 , then I reverted the commit and tests passed again. So ...
rep, err := f.Format() | ||
r.NoError(err) | ||
|
||
r.Len(rep.SourceFiles, 7) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The single char vars here are making my eye itchy 🤨
Can we make the names a bit more descriptive? Like, 4 lines down and I don't recall what r
is anymore 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hahah, yeah I know sorry, I kinda follow the pattern that was already in place, but I have just update all the tests to use better namings.
Hey @filipesperandio just addressed your comments, thanks for your, as usual, detailed review. I'm just pinging you again in this comment to make some noise on your notifications so it became the first thing you see on Monday and luckily if you have further comments we can address them tomorrow 💪🏼 |
Worked. 😂 |
if err != nil { | ||
return rep, errors.WithStack(errors.Errorf("could not open coverage file %s", r.Path)) | ||
} | ||
rep, err = jsonFormat(r,rep) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might have something confused in my head, not seeing a problem here anymore 🤦
@@ -18,21 +18,21 @@ func Test_ParseLegacy(t *testing.T) { | |||
return s, nil | |||
} | |||
|
|||
r := require.New(t) | |||
assert := require.New(t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! thanks!
.circleci/config.yml
Outdated
@@ -24,7 +24,7 @@ jobs: | |||
|
|||
test_macos: | |||
macos: | |||
xcode: "9.0" | |||
xcode: "11.3.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any chance we can do this in a separate PR? Feel free to tag me.
Just want to isolate infra/tooling changes from other things, makes it easier to revert in case we need to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeap, I think that makes sense. Will do that now
This reverts commit dacd033.
Following #413, this PR attempts to add support to simplecov
0.20.0
+. As discussed in the issue shared before, the main idea is that simplecov will natively incorporate a JSON formatter, which we will be triggered by default when running simplecov within an environment that has theCC_TEST_REPORTER_ID
variable present.Accordingly, the simplecov formatter will now try to read coverage information from the output of the new simplecov's JSON formatter. This new report will contain more information reporting as "ignored" those lines marked with
:nocov:
.The current implementation pretends to maintain support for previous versions, therefore there are two different paths for looking up the json report, the old
.resultset.json
and the newcoverage.json
, a priority in order has been given tocoverage.json
. When a path is given, like when usingtest-reporter format-coverate -t simplecov -p /some-path
the formatter will try to read the indicated information as if was outputted by the new JSON formatter, in case of that not being the case it will fallback to reading as if it has the same format as.resultset.json
. The idea is that no one gets affected by this changes.As a final note, Until simplecov-ruby/simplecov#923 get's merged or a variation of it, It wouldn't make much sense to merge this work, though in theory it wouldn't cause problems to anyone.
Addresses:
:nocov:
is ignored with simplecov #246Bonus track