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

Makefile: add faillint to lint target - Issue 2142 #2143

Merged
merged 3 commits into from
Feb 21, 2020

Conversation

kadern0
Copy link
Contributor

@kadern0 kadern0 commented Feb 17, 2020

Fixes #2142

  • I added CHANGELOG entry for this change.
    (I've included a line at the bottom of the Added section)
  • Change is not relevant to the end user.

Changes

Added failint package with the paths specified within the issue description to 'make lint'

Verification

Manual execution of the command and output verification.

@kadern0
Copy link
Contributor Author

kadern0 commented Feb 17, 2020

This is the output of the command:

make lint
>> verifying packages being imported
/home/kaderno/go/src/github.com/improbable-eng/thanos/pkg/block/fetcher.go:9:12: package "errors" shouldn't be imported
/home/kaderno/go/src/github.com/improbable-eng/thanos/pkg/receive/hashring.go:8:2: package "errors" shouldn't be imported
/home/kaderno/go/src/github.com/improbable-eng/thanos/pkg/cacheutil/memcached_client_test.go:8:2: package "errors" shouldn't be imported
/home/kaderno/go/src/github.com/improbable-eng/thanos/pkg/query/api/v1_test.go:22:2: package "errors" shouldn't be imported
/home/kaderno/go/src/github.com/improbable-eng/thanos/pkg/runutil/example_test.go:8:2: package "errors" shouldn't be imported
/home/kaderno/go/src/github.com/improbable-eng/thanos/pkg/store/cache/memcached_test.go:8:2: package "errors" shouldn't be imported
/home/kaderno/go/src/github.com/improbable-eng/thanos/pkg/store/storepb/custom_test.go:7:2: package "errors" shouldn't be imported

All these packages import "errors", so they should be updated before merging this PR or builds will fail.

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Thanks!

Some suggestions.

Makefile Outdated Show resolved Hide resolved
Makefile Outdated
@@ -283,14 +285,18 @@ web: web-pre-process $(HUGO)
# TODO(bwplotka): Make it --gc
@cd $(WEB_DIR) && HUGO_ENV=production $(HUGO) --config hugo.yaml --minify -v -b $(WEBSITE_BASE_URL)

.PHONY: failint
failint:
Copy link
Member

Choose a reason for hiding this comment

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

Please let's add this to lint command. We already have too many commands ;p

Copy link
Member

Choose a reason for hiding this comment

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

I I know you added this as lint dep, but I think it might be more explicit when inlined in lint command.

Copy link
Contributor Author

@kadern0 kadern0 Feb 17, 2020

Choose a reason for hiding this comment

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

It makes sense moving it inside of the lint command although then we would have to wait for the whole linting to complete whenever we want to test (not a huge deal).

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 that's ok (:

Copy link
Member

Choose a reason for hiding this comment

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

You can put it in front of it if you think it's fast.

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 think I've fixed this, please let me know if you were thinking something different when you said to put it in front.

Makefile Outdated Show resolved Hide resolved
Makefile Outdated
.PHONY: failint
failint:
@echo ">> verifying packages being imported"
@faillint -paths $(IMPORTS_TO_AVOID) ./...
Copy link
Member

Choose a reason for hiding this comment

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

Also let's install failint as we do for other Go binaries.

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've followed the "Dependency management" section under the contributing guide. I've realized that if I run make deps it removes the faillint entries from go.sum and go.mod

Copy link
Member

Choose a reason for hiding this comment

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

And that's ok - check the binaries like $(MINIO_SERVER) and how it install it and version. (: Can we mimic that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done (but check it, please)!

go.mod Show resolved Hide resolved
@daixiang0
Copy link
Member

Would it be better to change pr title as "Makefile: add faillint to lint target"?

@kadern0
Copy link
Contributor Author

kadern0 commented Feb 18, 2020

Would it be better to change pr title as "Makefile: add faillint to lint target"?

Yeah, I like it better. Should I keep the reference to the issue No.?

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Overall good, thanks for this! Some comments.

CHANGELOG.md Outdated
@@ -678,3 +678,4 @@ Initial version to have a stable reference before [gossip protocol removal](/doc
- Bucket commands.
- Downsampling support for UI.
- Grafana dashboards for Thanos components.
- Failint for imported packages verification.
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 we should not touch 0.1.0 release ;p

Also this is a tooling, not really relevant for Thanos users, so we don't need changelog entry. (:

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 was following the guide :) Removed!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

About not touching the 0.1.0 version, should I change the PR to a different branch instead of master?

Copy link
Member

Choose a reason for hiding this comment

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

No. Master is fine. Just you put the changelog entry at the bottom, but actually releases goes from newest to oldest.

Anyway, there should be no entry.

@kadern0 kadern0 changed the title Issue 2142: Added failint to Makefile - make lint Makefile: add faillint to lint target - Issue 2142 Feb 18, 2020
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Hm, this should work I believe. But CI and DCO fails. You can click on those to learn why.

Thanks!

Curious, have you tested it? e.g put some not allowed imports and run it?

@kadern0
Copy link
Contributor Author

kadern0 commented Feb 19, 2020

One of the tests was failing because of incorrect signing off of commits. The other test fails because of what I've mentioned in my second comment on this PR. There are 7 packages importing errors, thus, the linting stage fails. Now that the "setup" is working, it might be appropriate, fixing these files, what do you think?

Also, yes, I've tested the correct behavior of the code (with different modules and also placing them under a directory called vendor) and it seems to be working as expected.

@kadern0
Copy link
Contributor Author

kadern0 commented Feb 19, 2020

If I update this line:
MODULES_TO_AVOID ?=errors,prometheus/tsdb,prometheus/prometheus/pkg/testutils
to:
MODULES_TO_AVOID ?=errors=pkg/errors,prometheus/tsdb,prometheus/prometheus/pkg/testutils

Then, in the output we get a suggestion of the correct module to import:
improbable-eng/thanos/pkg/block/fetcher.go:9:12: package "errors" shouldn't be imported, suggested: "pkg/errors"

Should we add the recommended modules for each of the ones to avoid?

@bwplotka
Copy link
Member

That would be amazing! Nice idea @kadern0!

But please let's use the full path for imports if we can?

Looks like we detected errors!

 /go/src/github.com/thanos-io/thanos/pkg/block/fetcher.go:9:12: package "errors" shouldn't be imported
/go/src/github.com/thanos-io/thanos/pkg/receive/hashring.go:8:2: package "errors" shouldn't be imported
/go/src/github.com/thanos-io/thanos/pkg/cacheutil/memcached_client_test.go:8:2: package "errors" shouldn't be imported
/go/src/github.com/thanos-io/thanos/pkg/query/api/v1_test.go:22:2: package "errors" shouldn't be imported
/go/src/github.com/thanos-io/thanos/pkg/runutil/example_test.go:8:2: package "errors" shouldn't be imported
/go/src/github.com/thanos-io/thanos/pkg/store/cache/memcached_test.go:8:2: package "errors" shouldn't be imported
/go/src/github.com/thanos-io/thanos/pkg/store/storepb/custom_test.go:7:2: package "errors" shouldn't be imported

Do you mind changing those?

Good job, can't wait to merge it! (:

@kadern0 kadern0 force-pushed the issue-2142 branch 4 times, most recently from 309c4d1 to 81b27b7 Compare February 19, 2020 11:21
@kadern0
Copy link
Contributor Author

kadern0 commented Feb 19, 2020

I've changed all the imports but now circleci is failing for some reason I don't understand. Could you please have a look?

Makefile Outdated Show resolved Hide resolved
Signed-off-by: Pablo Caderno <[email protected]>
Signed-off-by: kaderno <[email protected]>
Signed-off-by: Pablo Caderno <[email protected]>
Signed-off-by: Pablo Caderno <[email protected]>
Copy link
Contributor

@yeya24 yeya24 left a comment

Choose a reason for hiding this comment

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

Thanks for the great work! @kadern0
CI failed but unrelated.
LGTM

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Thanks!

LGTM! Let's merge on green!

go.mod Show resolved Hide resolved
pkg/block/fetcher.go Show resolved Hide resolved
@bwplotka bwplotka merged commit f278950 into thanos-io:master Feb 21, 2020
vankop pushed a commit to monitoring-tools/thanos that referenced this pull request Feb 28, 2020
* Added faillint

Signed-off-by: Pablo Caderno <[email protected]>

* Added faillint

Signed-off-by: kaderno <[email protected]>
Signed-off-by: Pablo Caderno <[email protected]>

* Added faillint

Signed-off-by: Pablo Caderno <[email protected]>
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.

Incorporate failinit.
5 participants