Skip to content
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

How to read .golangci.yml from a location other than PROJECT_ROOT #64

Closed
mwittig opened this issue Mar 15, 2021 · 6 comments
Closed

How to read .golangci.yml from a location other than PROJECT_ROOT #64

mwittig opened this issue Mar 15, 2021 · 6 comments

Comments

@mwittig
Copy link

mwittig commented Mar 15, 2021

I have read issues #43 & #41 and as far as I understand this, the file .golangci.yml must be located in PROJECT_ROOT. I am wondering whether or not it is possible though to read .golangci.yml from a different location other than PROJECT_ROOT. If not, I'd like to raise this as a feature request.

Usage scenario: We have multiple go projects under git version control for which we would like to apply a single source of .golangci.yml to all projects. Thus, we keep the config file in a separate git repo where each go project is connected to it by adding the repo as a git submodule to the project. For example, in our case the config file is located at go-linting/.golangci.yml under PROJECT_ROOT.

@xxpxxxxp
Copy link
Owner

I would gladly implement the feature. A few questions for helping me design the functionality and configuration UI:

  • How are you doing CI for those projects? By specifying the config path?
  • Would an alternative way, such as if any .golangci.yml under home path found will be used, help to resolve your scenario?

@mwittig
Copy link
Author

mwittig commented Mar 16, 2021

@xxpxxxxp thanks for the swift reply

  • How are you doing CI for those projects? By specifying the config path?

Yes, we use Gitlab CI/CD. At the QA stage a docker build is performed which runs golangci-lint -c ./go-linting/.golangci.yml run ./... on the project root where go-lint is a git submodule.

  • Would an alternative way, such as if any .golangci.yml under home path found will be used, help to resolve your scenario?

If it is required to have .golangci.yml located directly in $HOME this will not help. Any .golangci.yml found in subdirectories below $HOME may do, however, I am bit worried about having multiple instances of .golangci.yml if we keep the git submodule dependency in our projects (which is what we currently need for our QA builds). Would it be possible to limit the scope by specifying a relative PATH as part of the plugin, e.g. go/src/go-linting/.golangci.yml located in $HOME?

@xxpxxxxp
Copy link
Owner

Got you, I'm considering adding a config file override option, ETA in 2 weeks.

@xxpxxxxp
Copy link
Owner

Publishing support for custom config file, pending JetBrains approval, expected available in one day.

@xxpxxxxp
Copy link
Owner

The latest release should resolve this issue, I'm closing it. Feel feel to reopen it if necessary.

@mwittig
Copy link
Author

mwittig commented Apr 16, 2021

Sorry, for the delay in reply. I have tested the new version and I just wanted to confirm it works as expected. Thank you very much for covering this!

There are two points I'd like to point out which may be useful for future matters on the topic:

  • When I started testing the new version the "with config" button did not show up in the preferences as I expected. The reason was that we copied the yml file to the project root directory as short term work-around solution. After removing the file the button showed up as expected. For me this is not an issue, but perhaps it should be documented
  • As outlined earlier I think it might be desirable to have the possibility of defining a relative config file path for use cases where the yml file is located in a subdirectory below project root. As it is only possibly to provide an absolute path (using "with config") for now, it should be noted in the docs that this setting applies for all projects managed by the IDE. As described earlier the absolute path works for us as we keep the yml file in a git repo of its own which is integrated into our projects via git submodule (which we need to have every thing pulled from a single repo as part of the CI/CD build & QA stages. This way, the solution for us is to create a new IDE project from the git repo containing the yml file and to set the "with config" path to the yml file in that IDE project

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

No branches or pull requests

2 participants