Output report paths specified in the configuration file should be relative to that configuration file #3656
Closed
4 tasks done
Labels
area: config
Related to .golangci.yml and/or cli options
area: output
Related to issue output
enhancement
New feature or improvement
Welcome
Description of the problem
The path for the output report specified in a configuration file is apparently relative to the current working directory that golangci-lint is invoked from, rather than relative to the configuration file itself. This is a problem if the configuration file is located in a parent directory.
Steps to reproduce
~/Thumbtack/go/src/github.com/thumbtack/go/.golangci.yml
that includes the following:~/Thumbtack/go/src/github.com/thumbtack/go/reports/junit
that will hold the report output. (The directory creation as a first step is necessary because this has not been implemented: Automatically create output directory for reports #3623)Expected behavior
The linter should write a report file at
~/Thumbtack/go/src/github.com/thumbtack/go/reports/junit/lint.xml
because that is the output path specified in the configuration file (relative to the directory containing the configuration file).Actual behavior
The linter fails with an error, because it tries to write the output in a location relative to the current working directory (
lib/system
sub-directory), and does not find a pre-existing output directory there:In the above logs, note the following:
../../.golangci.yml
relative to the current working directory.reports/junit/lint.xml
-- not../../reports/junit/lint.xml
which would be the path relative to the configuration file.Thoughts on solving this
At the end of the day, all I want to do is write the JUnit output during CI/CD to a subdirectory relative to the base of our repository / relative to the configuration file, while at the same time allow ordinary developers to at least be able to run golangci-lint from any directory without encountering an error.
Whether that is solved by addressing #3623, providing a way to evaluate the output path relative to the configuration file, or some other maintainable solution is relatively inconsequential to me. It is the combination of both of these issues that presents a problem where it's just not practical to put output files in a subdirectory.
Version of golangci-lint
The problem still exists in master branch:
golangci-lint/pkg/commands/run.go
Lines 414 to 425 in 50901e4
printReports
function.golangci-lint/pkg/commands/run.go
Lines 434 to 435 in 50901e4
createWriter
as-is.golangci-lint/pkg/commands/run.go
Lines 462 to 469 in 50901e4
os.OpenFile
as-is.Configuration file
Relevant part cited in problem description, above.
Go environment
Verbose output of running
Relevant verbose output cited in problem description.
Code example or link to a public repository
Enough information should be provided in the problem description to reproduce it.
The text was updated successfully, but these errors were encountered: