This repository was archived by the owner on Feb 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 262
cli: add gometalinter support #3115
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,3 +7,137 @@ test_suite( | |
| "//installer/pkg/workflow:go_default_test", | ||
| ], | ||
| ) | ||
|
|
||
| genrule( | ||
| name = "gometalinter_runtime", | ||
| srcs = select({ | ||
| "//:darwin": ["@gometalinter_runtime_darwin//:gometalinter"], | ||
| "//:linux": ["@gometalinter_runtime_linux//:gometalinter"], | ||
| }), | ||
| outs = ["bin/gometalinter"], | ||
| cmd = "cp $(<) $(@)", | ||
| executable = True, | ||
| output_to_bindir = 1, | ||
| ) | ||
|
|
||
| genrule( | ||
| name = "golint_runtime", | ||
| srcs = select({ | ||
| "//:darwin": ["@gometalinter_runtime_darwin//:golint"], | ||
| "//:linux": ["@gometalinter_runtime_linux//:golint"], | ||
| }), | ||
| outs = ["bin/golint"], | ||
| cmd = "cp $(<) $(@)", | ||
| executable = True, | ||
| output_to_bindir = 1, | ||
| ) | ||
|
|
||
| genrule( | ||
| name = "govet_runtime", | ||
| srcs = select({ | ||
| "//:darwin": ["@gometalinter_runtime_darwin//:govet"], | ||
| "//:linux": ["@gometalinter_runtime_linux//:govet"], | ||
| }), | ||
| outs = ["bin/govet"], | ||
| cmd = "cp $(<) $(@)", | ||
| executable = True, | ||
| output_to_bindir = 1, | ||
| ) | ||
|
|
||
| genrule( | ||
| name = "gocyclo_runtime", | ||
| srcs = select({ | ||
| "//:darwin": ["@gometalinter_runtime_darwin//:gocyclo"], | ||
| "//:linux": ["@gometalinter_runtime_linux//:gocyclo"], | ||
| }), | ||
| outs = ["bin/gocyclo"], | ||
| cmd = "cp $(<) $(@)", | ||
| executable = True, | ||
| output_to_bindir = 1, | ||
| ) | ||
|
|
||
| genrule( | ||
| name = "misspell_runtime", | ||
| srcs = select({ | ||
| "//:darwin": ["@gometalinter_runtime_darwin//:misspell"], | ||
| "//:linux": ["@gometalinter_runtime_linux//:misspell"], | ||
| }), | ||
| outs = ["bin/misspell"], | ||
| cmd = "cp $(<) $(@)", | ||
| executable = True, | ||
| output_to_bindir = 1, | ||
| ) | ||
|
|
||
| genrule( | ||
| name = "dupl_runtime", | ||
| srcs = select({ | ||
| "//:darwin": ["@gometalinter_runtime_darwin//:dupl"], | ||
| "//:linux": ["@gometalinter_runtime_linux//:dupl"], | ||
| }), | ||
| outs = ["bin/dupl"], | ||
| cmd = "cp $(<) $(@)", | ||
| executable = True, | ||
| output_to_bindir = 1, | ||
| ) | ||
|
|
||
| genrule( | ||
| name = "gometalinter_sh", | ||
| outs = ["gometalinter.sh"], | ||
| cmd = "printf '" + '\n'.join([ | ||
| "#!/bin/bash -ex", | ||
| "export PATH=./installer/bin", | ||
| "export HOME=test", | ||
| "./installer/bin/gometalinter --deadline=240s --disable-all \ | ||
| --exclude=\"pkg\\/config\\/validate.*\\.go.*\\(dupl\\)$$\" \ | ||
| --exclude=\"pkg\\/validate.*\\.go.*\\(dupl\\)$$\" \ | ||
| --cyclo-over=20 \ | ||
| --dupl-threshold=75 \ | ||
| --enable=golint \ | ||
| --enable=vet \ | ||
| --enable=gocyclo \ | ||
| --enable=misspell \ | ||
| --enable=dupl \ | ||
| installer/cmd/tectonic \ | ||
| installer/pkg/validate \ | ||
| installer/pkg/config \ | ||
| installer/pkg/config/aws \ | ||
| installer/pkg/config/azure \ | ||
| installer/pkg/config/gcp \ | ||
| installer/pkg/config/govcloud \ | ||
| installer/pkg/config/metal \ | ||
| installer/pkg/config/openstack \ | ||
| installer/pkg/config/vmware \ | ||
| installer/pkg/config-generator \ | ||
| installer/pkg/workflow, \ | ||
| tests/smoke", | ||
| ]) + "' > $@", | ||
| testonly = 1, | ||
| ) | ||
|
|
||
| sh_test( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could use our custom |
||
| name = "gometalinter", | ||
| size = "small", | ||
| srcs = [":gometalinter_sh"], | ||
| data = [ | ||
| "//installer/cmd/tectonic:go_files", | ||
| "//installer/pkg/validate:go_files", | ||
| "//installer/pkg/config:go_files", | ||
| "//installer/pkg/config/aws:go_files", | ||
| "//installer/pkg/config/azure:go_files", | ||
| "//installer/pkg/config/gcp:go_files", | ||
| "//installer/pkg/config/govcloud:go_files", | ||
| "//installer/pkg/config/metal:go_files", | ||
| "//installer/pkg/config/openstack:go_files", | ||
| "//installer/pkg/config/vmware:go_files", | ||
| "//installer/pkg/config-generator:go_files", | ||
| "//installer/pkg/workflow:go_files", | ||
| "//tests/smoke:go_files", | ||
| "//installer:gometalinter_runtime", | ||
| "//installer:golint_runtime", | ||
| "//installer:govet_runtime", | ||
| "//installer:gocyclo_runtime", | ||
| "//installer:misspell_runtime", | ||
| "//installer:dupl_runtime", | ||
| ], | ||
| ) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 listto grab all the packages.There was a problem hiding this comment.
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