Skip to content

Commit 6f3838b

Browse files
committed
🏃 add apidiff to verify.sh
1 parent bac7e8a commit 6f3838b

File tree

5 files changed

+103
-2
lines changed

5 files changed

+103
-2
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export GO111MODULE=on
3838
TOOLS_DIR := hack/tools
3939
TOOLS_BIN_DIR := $(TOOLS_DIR)/bin
4040
GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR)/golangci-lint)
41+
GO_APIDIFF := $(abspath $(TOOLS_BIN_DIR)/go-apidiff)
4142

4243
# The help will print out all targets with their descriptions organized bellow their categories. The categories are represented by `##@` and the target descriptions by `##`.
4344
# The awk commands is responsible to read the entire set of makefiles included in this invocation, looking for lines of the file as xyz: ## something, and then pretty-format the target and help. Then, if there's a line with ##@ something, that gets pretty-printed as a category.
@@ -60,7 +61,10 @@ test: ## Run the script check-everything.sh which will check all.
6061
## --------------------------------------
6162

6263
$(GOLANGCI_LINT): $(TOOLS_DIR)/go.mod # Build golangci-lint from tools folder.
63-
cd $(TOOLS_DIR); go build -tags=tools -o bin/golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint
64+
cd $(TOOLS_DIR) && go build -tags=tools -o bin/golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint
65+
66+
$(GO_APIDIFF): $(TOOLS_DIR)/go.mod # Build go-apidiff from tools folder.
67+
cd $(TOOLS_DIR) && go build -tags=tools -o bin/go-apidiff github.com/joelanford/go-apidiff
6468

6569
## --------------------------------------
6670
## Linting

hack/apidiff.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env 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+
source $(dirname ${BASH_SOURCE})/common.sh
22+
23+
REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
24+
cd "${REPO_ROOT}"
25+
26+
APIDIFF="hack/tools/bin/go-apidiff"
27+
28+
header_text "fetching tools"
29+
make "${APIDIFF}"
30+
31+
header_text "verifying api diff"
32+
"${APIDIFF}" "${PULL_BASE_SHA}" --print-compatible

hack/tools/go.mod

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ module sigs.k8s.io/controller-runtime/hack/tools
22

33
go 1.13
44

5-
require github.com/golangci/golangci-lint v1.23.6
5+
require (
6+
github.com/golangci/golangci-lint v1.23.6
7+
github.com/joelanford/go-apidiff v0.0.0-20191206194835-106bcff5f060
8+
)

0 commit comments

Comments
 (0)