Skip to content

Commit 7036f69

Browse files
committed
Add Makefile and build scripts
1 parent 1bd4f38 commit 7036f69

File tree

4 files changed

+102
-7
lines changed

4 files changed

+102
-7
lines changed

.travis.yml

+1-7
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,4 @@ go:
66
- 1.11.x
77
go_import_path: k8s.io/utils
88
script:
9-
- go get -t -v ./...
10-
- diff -u <(echo -n) <(gofmt -d .)
11-
- diff -u <(echo -n) <(golint $(go list -e ./...))
12-
- go tool vet .
13-
- go test -v -race ./...
14-
install:
15-
- go get golang.org/x/lint/golint
9+
- make verify

Makefile

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright 2018 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
.PHONY: verify
16+
verify: depend verify-fmt verify-lint vet
17+
go test -v -race ./...
18+
19+
.PHONY: depend
20+
depend:
21+
go get -t -v ./...
22+
23+
.PHONY: verify-fmt
24+
verify-fmt:
25+
./hack/verify-gofmt.sh
26+
27+
.PHONY: verify-lint
28+
verify-lint:
29+
./hack/verify-golint.sh
30+
31+
.PHONY: vet
32+
vet:
33+
go tool vet .
34+
35+
.PHONY: update-fmt
36+
update-fmt:
37+
gofmt -s -w .

hack/verify-gofmt.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2017 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
if ! which gofmt > /dev/null; then
22+
echo "Can not find gofmt"
23+
exit 1
24+
fi
25+
26+
diff=$(gofmt -s -d . 2>&1)
27+
if [[ -n "${diff}" ]]; then
28+
echo "${diff}"
29+
echo
30+
echo "Please run 'make update-fmt'"
31+
exit 1
32+
fi

hack/verify-golint.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# Copyright 2018 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
if ! which golint > /dev/null; then
22+
echo "installing golint"
23+
go get golang.org/x/lint/golint
24+
fi
25+
26+
errors="$(golint ./...)"
27+
if [[ -n "$errors" ]]; then
28+
echo "Errors from golint:"
29+
echo
30+
echo "${errors}"
31+
exit 1
32+
fi

0 commit comments

Comments
 (0)