Skip to content

Conversation

@tstromberg
Copy link
Contributor

Signed-off-by: Thomas Stromberg t+github@chainguard.dev

Description

Fixes broken behavior with repositories containing multiple go packages. This change ensures that the successive find command are able to locate the path to golangci-lint properly.

Why is this needed

Fixes: #39

How Has This Been Tested?

Ran make golangci-lint-lint in a repo containing ~40 go packages

Signed-off-by: Thomas Stromberg <t+github@chainguard.dev>
}

return fmt.Sprintf(`find . -name go.mod -execdir "$(GOLANGCI_LINT_BIN)" run -c "$(GOLINT_CONFIG)"%s \;`, suffix)
return fmt.Sprintf(`find . -name go.mod -execdir "$(CURDIR)/$(GOLANGCI_LINT_BIN)" run -c "$(GOLINT_CONFIG)"%s \;`, suffix)
Copy link
Contributor

@mmlb mmlb Feb 16, 2022

Choose a reason for hiding this comment

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

We already have LINT_ROOT which I think we should use instead of CURDIR, to avoid having 2 variables with similar values. Also, I think it would be better to update the TOOL_BIN variable(s) in Makefile.tmpl instead of fixing here. That way the Makefiles are where most of the logic lives and the go binary is mostly just dealing with enabling certain functionality. We wouldn't be mixing logic among 2 different processes/times ("buildtime" and "runtime"). We should probably just do this for all the binaries.

Copy link
Member

Choose a reason for hiding this comment

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

@tstromberg thoughts on this?

mmlb added a commit to mmlb/tinkerbell-hook that referenced this pull request May 10, 2022
With fixes from tinkerbell/lint-install#40 applied manually.

Signed-off-by: Manuel Mendez <github@i.m.mmlb.dev>
mmlb added a commit to mmlb/tinkerbell-hook that referenced this pull request May 10, 2022
With fixes from tinkerbell/lint-install#40 applied manually.

Signed-off-by: Manuel Mendez <github@i.m.mmlb.dev>
mmlb added a commit to mmlb/tinkerbell-hook that referenced this pull request May 10, 2022
With fixes from tinkerbell/lint-install#40 applied manually.

Signed-off-by: Manuel Mendez <github@i.m.mmlb.dev>
mmlb added a commit to mmlb/tinkerbell-hook that referenced this pull request May 11, 2022
With fixes from tinkerbell/lint-install#40 applied manually.

Signed-off-by: Manuel Mendez <github@i.m.mmlb.dev>
@mmlb
Copy link
Contributor

mmlb commented May 11, 2022

Hey @tstromberg I've opened up #45 with my version of these fixes. I also noticed that in multi-module mode no config file is actually used so fixed that too. I say lets go with #45 over this one, wdyt?

@mergify mergify bot closed this in #45 May 11, 2022
mergify bot added a commit that referenced this pull request May 11, 2022
## Description

* Uses full paths to executables, so changed dirs don't matter
* Switches to always using `find -execdir` to run golangci-lint to avoid an seldomly used corner case bit rotting
* Uses the correct variable name for the golangci-lint config file

## Why is this needed

Fixes: #39
Closes: #40 

## How Has This Been Tested?

Ran `make lint` a bunch in hook to make sure it works.

## How are existing users impacted? What migration steps/scripts do we need?

golangci-lint will actually run if multiple modules are detected (or added w/o having to re-run lint-install).
mmlb added a commit to mmlb/tinkerbell-hook that referenced this pull request May 11, 2022
With fixes from tinkerbell/lint-install#40 applied manually.

Signed-off-by: Manuel Mendez <github@i.m.mmlb.dev>
mmlb added a commit to mmlb/tinkerbell-hook that referenced this pull request May 16, 2022
With fixes from tinkerbell/lint-install#40 applied manually.

Signed-off-by: Manuel Mendez <github@i.m.mmlb.dev>
mmlb added a commit to mmlb/tinkerbell-hook that referenced this pull request May 16, 2022
With fixes from tinkerbell/lint-install#40 applied manually.

Signed-off-by: Manuel Mendez <github@i.m.mmlb.dev>
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.

multi-module repos: find: ‘out/linters/golangci-lint-v1.43.0-x86_64’: No such file or directory

3 participants