Skip to content
This repository was archived by the owner on Feb 5, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ pipeline {
withDockerContainer(tectonicBazelImage) {
sh "bazel test terraform_fmt --test_output=all"
sh "bazel test installer:cli_units --test_output=all"
sh "bazel test installer:gometalinter --test_output=all"
sh"""#!/bin/bash -ex
bazel build tarball tests/smoke

Expand Down
13 changes: 13 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ terrafom_version = "0.11.2"

provider_matchbox_version = "0.2.2"

gometalinter_version="2.0.5"

supported_platforms = [
"linux",
"darwin",
Expand Down Expand Up @@ -54,3 +56,14 @@ visibility = ["//visibility:public"]
strip_prefix = "terraform-provider-matchbox-v%s-%s-amd64/" % (provider_matchbox_version, platform),
url = "https://github.com/coreos/terraform-provider-matchbox/releases/download/v%s/terraform-provider-matchbox-v%s-%s-amd64.tar.gz" % (provider_matchbox_version, provider_matchbox_version, platform),
) for platform in supported_platforms]

[new_http_archive(
name = "gometalinter_runtime_%s" % platform,
build_file_content = """exports_files(
["gometalinter", "golint", "govet", "gocyclo", "misspell", "dupl"],
visibility = ["//visibility:public"]
)""",
strip_prefix = "gometalinter-%s-%s-amd64/" % (gometalinter_version, platform),
type = "tar.gz",
url = "https://github.com/alecthomas/gometalinter/releases/download/v%s/gometalinter-%s-%s-amd64.tar.gz" % (gometalinter_version, gometalinter_version, platform),
) for platform in supported_platforms]
134 changes: 134 additions & 0 deletions installer/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
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

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(
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.

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",
],
)

8 changes: 8 additions & 0 deletions installer/cmd/tectonic/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,11 @@ go_binary(
pure = "on",
visibility = ["//visibility:public"],
)

filegroup(
name = "go_files",
visibility = ["//visibility:public"],
srcs = glob([
"*.go",
]),
)
8 changes: 8 additions & 0 deletions installer/pkg/config-generator/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@ go_test(
embed = [":go_default_library"],
deps = ["//installer/pkg/config:go_default_library"],
)

filegroup(
name = "go_files",
visibility = ["//visibility:public"],
srcs = glob([
"*.go",
]),
)
8 changes: 8 additions & 0 deletions installer/pkg/config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@ go_library(
"//installer/vendor/gopkg.in/yaml.v2:go_default_library",
],
)

filegroup(
name = "go_files",
visibility = ["//visibility:public"],
srcs = glob([
"*.go",
]),
)
8 changes: 8 additions & 0 deletions installer/pkg/config/aws/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@ go_library(
importpath = "github.com/coreos/tectonic-installer/installer/pkg/config/aws",
visibility = ["//visibility:public"],
)

filegroup(
name = "go_files",
visibility = ["//visibility:public"],
srcs = glob([
"*.go",
]),
)
8 changes: 8 additions & 0 deletions installer/pkg/config/azure/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@ go_library(
importpath = "github.com/coreos/tectonic-installer/installer/pkg/config/azure",
visibility = ["//visibility:public"],
)

filegroup(
name = "go_files",
visibility = ["//visibility:public"],
srcs = glob([
"*.go",
]),
)
8 changes: 8 additions & 0 deletions installer/pkg/config/gcp/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@ go_library(
importpath = "github.com/coreos/tectonic-installer/installer/pkg/config/gcp",
visibility = ["//visibility:public"],
)

filegroup(
name = "go_files",
visibility = ["//visibility:public"],
srcs = glob([
"*.go",
]),
)
8 changes: 8 additions & 0 deletions installer/pkg/config/govcloud/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@ go_library(
importpath = "github.com/coreos/tectonic-installer/installer/pkg/config/govcloud",
visibility = ["//visibility:public"],
)

filegroup(
name = "go_files",
visibility = ["//visibility:public"],
srcs = glob([
"*.go",
]),
)
8 changes: 8 additions & 0 deletions installer/pkg/config/metal/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@ go_library(
importpath = "github.com/coreos/tectonic-installer/installer/pkg/config/metal",
visibility = ["//visibility:public"],
)

filegroup(
name = "go_files",
visibility = ["//visibility:public"],
srcs = glob([
"*.go",
]),
)
8 changes: 8 additions & 0 deletions installer/pkg/config/openstack/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@ go_library(
importpath = "github.com/coreos/tectonic-installer/installer/pkg/config/openstack",
visibility = ["//visibility:public"],
)

filegroup(
name = "go_files",
visibility = ["//visibility:public"],
srcs = glob([
"*.go",
]),
)
8 changes: 8 additions & 0 deletions installer/pkg/config/vmware/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@ go_library(
importpath = "github.com/coreos/tectonic-installer/installer/pkg/config/vmware",
visibility = ["//visibility:public"],
)

filegroup(
name = "go_files",
visibility = ["//visibility:public"],
srcs = glob([
"*.go",
]),
)
8 changes: 8 additions & 0 deletions installer/pkg/validate/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,11 @@ go_library(
importpath = "github.com/coreos/tectonic-installer/installer/pkg/validate",
visibility = ["//visibility:public"],
)

filegroup(
name = "go_files",
visibility = ["//visibility:public"],
srcs = glob([
"*.go",
]),
)
8 changes: 8 additions & 0 deletions installer/pkg/workflow/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@ go_library(
"//installer/vendor/k8s.io/client-go/tools/clientcmd:go_default_library",
],
)

filegroup(
name = "go_files",
visibility = ["//visibility:public"],
srcs = glob([
"*.go",
]),
)
4 changes: 2 additions & 2 deletions installer/pkg/workflow/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "github.com/coreos/tectonic-installer/installer/pkg/config"
// It is meant to carry state for one step to another.
// When creating a new workflow, initial state from external parameters
// is also injected by when initializing the metadata object.
// Steps taked thier inputs from the metadata object and persist
// Steps taked their inputs from the metadata object and persist
// results onto it for later consumption.
type metadata struct {
cluster config.Cluster
Expand All @@ -16,7 +16,7 @@ type metadata struct {

// Step is the entrypoint of a workflow step implementation.
// To add a new step, put your logic in a function that matches this signature.
// Next, add a refrence to this new function in a Workflow's steps list.
// Next, add a reference to this new function in a Workflow's steps list.
type Step func(*metadata) error

// Workflow is a high-level representation
Expand Down
10 changes: 10 additions & 0 deletions tests/smoke/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ go_test(
"//tests/smoke/vendor/k8s.io/client-go/tools/clientcmd:go_default_library",
"//tests/smoke/vendor/k8s.io/kubernetes/pkg/kubectl/cmd/util:go_default_library",
"//tests/smoke/vendor/k8s.io/kubernetes/pkg/kubectl/resource:go_default_library",
"//tests/smoke/vendor/k8s.io/client-go/rest:go_default_library",
],
)

Expand All @@ -52,6 +53,7 @@ go_test(
"//tests/smoke/vendor/k8s.io/client-go/tools/clientcmd:go_default_library",
"//tests/smoke/vendor/k8s.io/kubernetes/pkg/kubectl/cmd/util:go_default_library",
"//tests/smoke/vendor/k8s.io/kubernetes/pkg/kubectl/resource:go_default_library",
"//tests/smoke/vendor/k8s.io/client-go/rest:go_default_library",
],
)

Expand All @@ -63,3 +65,11 @@ filegroup(
],
visibility = ["//visibility:public"],
)

filegroup(
name = "go_files",
visibility = ["//visibility:public"],
srcs = glob([
"*.go",
]),
)
Loading