Skip to content

Conversation

@mtojek
Copy link
Contributor

@mtojek mtojek commented Jul 21, 2021

@mtojek mtojek self-assigned this Jul 21, 2021
@elasticmachine
Copy link
Collaborator

elasticmachine commented Jul 21, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2021-07-22T11:44:51.497+0000

  • Duration: 24 min 47 sec

  • Commit: 9b52a65

Test stats 🧪

Test Results
Failed 0
Passed 316
Skipped 4
Total 320

Trends 🧪

Image of Build Times

Image of Tests

@mtojek mtojek force-pushed the 755-generate-coverage-report branch from 92e7d56 to d3ddcd4 Compare July 21, 2021 14:17
@mtojek mtojek requested a review from jsoriano July 21, 2021 15:45
@mtojek mtojek marked this pull request as ready for review July 21, 2021 15:45
Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! added only some non-blocking comments.

// FindBuildDirectory locates the target build directory.
func FindBuildDirectory() (string, bool, error) {
// MustFindBuildDirectory function locates the target build directory. If the directory doesn't exist, it will create it.
func MustFindBuildDirectory() (string, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit. Must* functions use to imply that no error handling needs to be done but they panic if something fails, this one returns an error, and never panics.
If you want to indicate that the function finds or creates the directory, it could be called FindOrCreateBuildDirectory.
If it is a public method to obtain the build directory no matter what, it might be just called BuildDirectory().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, I can rename it to just BuildDirectory(). This will fit too! Thanks for this feedback!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -0,0 +1,248 @@
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit. Underscores shouldn't be used in go file names, unless they mean something for go build. This file could be named coverageoutput.go.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid we're overusing them here. I will adjust this file unit.

Do you know if there is any official recommendation written down? I must have missed reading it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is not, but for packages (and then for directories), there is a recommendation to don't use underscores. And for files, some suffixes have special meanings for go build, as the ones for architectures or operating systems, so in general I think that is a good idea to avoid them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion, fixed!

for i, tc := range testCases {
methods = append(methods, &coberturaMethod{
Name: tc,
Lines: []*coberturaLine{{Number: i + 1, Hits: 1}},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts for a possible future improvement. Coverage is at the data stream level now, right? Maybe in the future we can do it at least at the file level, e.g. saying that pipeline tests add coverage for pipelines, but not for the manifest or other config files, and system tests add coverage for all the files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I know what you mean... We shouldn't mark a missing pipeline test if there are no pipelines at all. Sounds like a follow up.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this would be for the future for sure, no need to do anything else by now 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return cobraext.FlagParsingError(err, cobraext.ReportOutputFlagName)
}

testCoverage, err := cmd.Flags().GetBool(cobraext.TestCoverageFlagName)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this flag only be allowed if --report-output file is also used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --report-output refers to test results, so I assumed it's something else. I don't see a value in printing the coverage to STDOUT, so I didn't bind these flags together.

Do you think we should introduce additional flag for --coverage-output file (or stdout) or is there low gain?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking that it may be weird to have files created even when there is only stdout output by default. But improving this, if needed, sounds like something for the future. For example we might show coverage info in the normal test reports, this could be nice, then --report-output would control the output of both features.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, let's keep it for further improvement if there is feature need for this feature.

@mtojek mtojek merged commit a8f6d9e into elastic:master Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants