Skip to content
This repository was archived by the owner on Feb 5, 2020. It is now read-only.

cli: add gometalinter support#3115

Closed
enxebre wants to merge 3 commits intocoreos:masterfrom
enxebre:gometalinter
Closed

cli: add gometalinter support#3115
enxebre wants to merge 3 commits intocoreos:masterfrom
enxebre:gometalinter

Conversation

@enxebre
Copy link
Contributor

@enxebre enxebre commented Mar 15, 2018

Bazel support for gometalinter

@coreosbot
Copy link

Can one of the admins verify this patch?

@enxebre
Copy link
Contributor Author

enxebre commented Mar 15, 2018

cc @mxinden @cpanato @squat

Copy link
Contributor

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

This is very cool, I was not aware of gometalinter.

visibility = ["//visibility:public"],
)

filegroup(
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be added to every sub-package, or could it be a top level definition?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Afaik it's needed. I can't find a way to filegroup crossing target boundaries, but my knowledge here is limited, would love to hear any ideas.

testonly = 1,
)

sh_test(
Copy link
Contributor

Choose a reason for hiding this comment

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

You could use our custom gen_test here, instead of generating a shell script via a genrule. gen_test is in no way perfect, but might be a bit less verbose.


sh_test(
name = "cli_gometalinter",
size = "large",
Copy link
Contributor

Choose a reason for hiding this comment

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

large is a bit exaggerated, resulting in: There were tests whose specified size is too big. Use the --test_verbose_timeout_warnings command line option to see which ones these are.. Would you mind adjusting it to a more reasonable level? (See Bazel level docs: https://docs.bazel.build/versions/master/test-encyclopedia.html#role-of-the-test-runner)

installer/pkg/config/vmware \
installer/pkg/config-generator \
installer/pkg/terraform-generator \
installer/pkg/workflow",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add the validate package? it is newly created to be used in the CLi for valdation: https://github.com/coreos/tectonic-installer/tree/master/installer/pkg/validate

)

sh_test(
name = "cli_gometalinter",
Copy link
Contributor

Choose a reason for hiding this comment

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

can we remove the cli_ prefix from these tests? I think it is clear enough with bazel test installer:gometalinter or even just bazel test installer:lint

@enxebre enxebre force-pushed the gometalinter branch 2 times, most recently from d1da3ff to 04fd8e7 Compare March 21, 2018 10:55
@enxebre
Copy link
Contributor Author

enxebre commented Mar 21, 2018

@squat @mxinden PTAL

@mxinden
Copy link
Contributor

mxinden commented Mar 21, 2018

@enxebre Is there a way to include the go smoke test code in the linting process as well?

@enxebre
Copy link
Contributor Author

enxebre commented Mar 22, 2018

thanks for the suggestion @mxinden, added a new commit with it and dupl improvements

@enxebre
Copy link
Contributor Author

enxebre commented Mar 22, 2018

ok to test

@enxebre enxebre force-pushed the gometalinter branch 3 times, most recently from ef58ae9 to 68f73bf Compare March 23, 2018 16:22
--enable=gocyclo \
--enable=misspell \
--enable=dupl \
installer/cmd/tectonic \
Copy link
Contributor

Choose a reason for hiding this comment

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

I worry that this is not flexible enough. Next time somebody adds a new package that has broken linting but forgets to add it here we will never know. We should use go list to grab all the packages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I don't really like it much either...
A new package would need to add the filegroup
filegroup( name = "go_files", visibility = ["//visibility:public"], srcs = glob([ "*.go", ]), )
And then it has to be referenced here.
However I couldn't find nicer way to collect all the go files crossing target boundaries with Bazel.
For using something like go lint, wouldn't the packages need to be made available for it during bazel run time? so wouldn't it still require manual static reference of the packages?
I can't see a way in bazel to "collect all the files" without adding static targets

@sym3tri
Copy link
Contributor

sym3tri commented May 16, 2018

needs rebase

@enxebre enxebre mentioned this pull request Jun 7, 2018
@paulfantom paulfantom self-assigned this Jun 7, 2018
@sym3tri
Copy link
Contributor

sym3tri commented Jun 12, 2018

@enxebre still doing this? If not please close.

@enxebre enxebre closed this Jun 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants