Verify gofmt as part of build

This commit is contained in:
Justin Santa Barbara 2016-12-30 11:16:04 -05:00
parent e1f6804278
commit e63dab8b9c
7 changed files with 151 additions and 7 deletions

View File

@ -241,7 +241,15 @@ govet:
verify-boilerplate:
sh -c hack/verify-boilerplate.sh
ci: kops nodeup-gocode examples test govet verify-boilerplate
.PHONY: verify-gofmt
verify-gofmt:
hack/verify-gofmt.sh
.PHONY: verify-packages
verify-packages:
hack/verify-packages.sh
ci: kops nodeup-gocode examples test govet verify-boilerplate verify-gofmt verify-packages
echo "Done!"
# --------------------------------------------------

60
hack/.packages Normal file
View File

@ -0,0 +1,60 @@
k8s.io/kops
k8s.io/kops/channels/cmd/channels
k8s.io/kops/channels/pkg/api
k8s.io/kops/channels/pkg/channels
k8s.io/kops/cloudmock/aws/mockec2
k8s.io/kops/cloudmock/aws/mockroute53
k8s.io/kops/cmd/kops
k8s.io/kops/cmd/kops/util
k8s.io/kops/cmd/nodeup
k8s.io/kops/dns-controller/cmd/dns-controller
k8s.io/kops/dns-controller/pkg/dns
k8s.io/kops/dns-controller/pkg/util
k8s.io/kops/dns-controller/pkg/watchers
k8s.io/kops/examples/kops-api-example
k8s.io/kops/federation
k8s.io/kops/federation/model
k8s.io/kops/federation/targets/kubernetes
k8s.io/kops/federation/tasks
k8s.io/kops/nodeup/pkg/model
k8s.io/kops/nodeup/pkg/model/resources
k8s.io/kops/pkg/apis/kops
k8s.io/kops/pkg/apis/kops/install
k8s.io/kops/pkg/apis/kops/registry
k8s.io/kops/pkg/apis/kops/v1alpha1
k8s.io/kops/pkg/apis/kops/v1alpha2
k8s.io/kops/pkg/client/simple
k8s.io/kops/pkg/client/simple/vfsclientset
k8s.io/kops/pkg/diff
k8s.io/kops/pkg/featureflag
k8s.io/kops/pkg/model
k8s.io/kops/pkg/model/components
k8s.io/kops/pkg/model/iam
k8s.io/kops/pkg/model/resources
k8s.io/kops/pkg/validation
k8s.io/kops/protokube/cmd/protokube
k8s.io/kops/protokube/pkg/protokube
k8s.io/kops/upup/models
k8s.io/kops/upup/pkg/fi
k8s.io/kops/upup/pkg/fi/cloudup
k8s.io/kops/upup/pkg/fi/cloudup/awstasks
k8s.io/kops/upup/pkg/fi/cloudup/awsup
k8s.io/kops/upup/pkg/fi/cloudup/gce
k8s.io/kops/upup/pkg/fi/cloudup/gcetasks
k8s.io/kops/upup/pkg/fi/cloudup/terraform
k8s.io/kops/upup/pkg/fi/fitasks
k8s.io/kops/upup/pkg/fi/k8sapi
k8s.io/kops/upup/pkg/fi/loader
k8s.io/kops/upup/pkg/fi/nodeup
k8s.io/kops/upup/pkg/fi/nodeup/cloudinit
k8s.io/kops/upup/pkg/fi/nodeup/local
k8s.io/kops/upup/pkg/fi/nodeup/nodetasks
k8s.io/kops/upup/pkg/fi/nodeup/tags
k8s.io/kops/upup/pkg/fi/secrets
k8s.io/kops/upup/pkg/fi/utils
k8s.io/kops/upup/pkg/kutil
k8s.io/kops/upup/tools/generators/fitask
k8s.io/kops/upup/tools/generators/pkg/codegen
k8s.io/kops/util/pkg/hashing
k8s.io/kops/util/pkg/tables
k8s.io/kops/util/pkg/vfs

22
hack/common.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
# Copyright 2016 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# common.sh has helper functions, and is sourced by the other scripts in this directory
set -o errexit
set -o nounset
set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..

View File

@ -14,9 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set -o errexit
. $(dirname "${BASH_SOURCE}")/common.sh
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
BAD_HEADERS=$(${KUBE_ROOT}/hack/verify-boilerplate.sh | awk '{ print $6}')
FORMATS="sh go Makefile Dockerfile"

View File

@ -15,11 +15,8 @@
# limitations under the License.
set -o errexit
set -o nounset
set -o pipefail
. $(dirname "${BASH_SOURCE}")/common.sh
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
boiler="${KUBE_ROOT}/hack/boilerplate/boilerplate.py"
files_need_boilerplate=($(${boiler} "$@"))

27
hack/verify-gofmt.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
# Copyright 2016 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
. $(dirname "${BASH_SOURCE}")/common.sh
GOFMT="gofmt -s -w"
bad_files=$(cat ${KUBE_ROOT}/hack/.packages | grep -v "^k8s.io/kops$" | sed -e s-^k8s.io/kops/-- | xargs -I {} $GOFMT -l {})
if [[ -n "${bad_files}" ]]; then
echo "!!! '$GOFMT' needs to be run on the following files: "
echo "${bad_files}"
echo "!!! Please run: make gofmt"
exit 1
fi

31
hack/verify-packages.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
# Copyright 2016 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
. $(dirname "${BASH_SOURCE}")/common.sh
# Check that the .packages file contains all packages
packages_file="${KUBE_ROOT}/hack/.packages"
if ! diff -u "${packages_file}" <(go list k8s.io/kops/... | grep -v vendor); then
{
echo
echo "hack/.packages is not in up to date. Please run:"
echo
echo " go list k8s.io/kops/... | grep -v vendor > hack/.packages"
echo
} >&2
false
fi