File tree Expand file tree Collapse file tree 3 files changed +44
-0
lines changed
Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ TOOLS_BIN_DIR := $(TOOLS_DIR)/bin
3131GO_INSTALL = ./scripts/go_install.sh
3232E2E_CONF_FILE_ENVSUBST := $(REPO_ROOT ) /test/e2e/config/ibmcloud-e2e-envsubst.yaml
3333
34+ GO_APIDIFF := $(TOOLS_BIN_DIR ) /go-apidiff
3435GOLANGCI_LINT := $(TOOLS_BIN_DIR ) /golangci-lint
3536KUSTOMIZE := $(TOOLS_BIN_DIR ) /kustomize
3637GOJQ := $(TOOLS_BIN_DIR ) /gojq
@@ -405,6 +406,20 @@ lint: $(GOLANGCI_LINT) ## Lint codebase
405406lint-fix : $(GOLANGCI_LINT ) # # Lint the codebase and run auto-fixers if supported by the linter
406407 GOLANGCI_LINT_EXTRA_ARGS=--fix $(MAKE ) lint
407408
409+ APIDIFF_OLD_COMMIT ?= $(shell git rev-parse origin/main)
410+
411+ .PHONY : apidiff
412+ apidiff : $(GO_APIDIFF ) # # Check for API differences.
413+ @if ($( call checkdiff) | grep " api/" ); then \
414+ $(GO_APIDIFF ) $(APIDIFF_OLD_COMMIT ) --print-compatible; \
415+ else \
416+ echo " No changes to 'api/'. Nothing to do." ; \
417+ fi
418+
419+ define checkdiff
420+ git --no-pager diff --name-only FETCH_HEAD
421+ endef
422+
408423ALL_VERIFY_CHECKS = doctoc boilerplate shellcheck modules gen manifests conversions # tiltfile
409424
410425.PHONY : verify
Original file line number Diff line number Diff line change @@ -52,6 +52,10 @@ help: # Display this help
5252
5353# #@ hack/tools:
5454
55+ GO_APIDIFF := $(BIN_DIR ) /go-apidiff
56+ $(GO_APIDIFF ) : $(BIN_DIR ) go.mod go.sum # # Build a local copy of go-apidiff.
57+ go build -tags=tools -o $@ github.com/joelanford/go-apidiff
58+
5559GOLANGCI_LINT := $(BIN_DIR ) /golangci-lint
5660$(GOLANGCI_LINT ) : $(BIN_DIR ) go.mod go.sum # # Build a local copy of golangci-lint.
5761 go build -tags=tools -o $@ github.com/golangci/golangci-lint/cmd/golangci-lint
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Copyright 2022 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+ REPO_ROOT=$( dirname " ${BASH_SOURCE[0]} " ) /..
22+ # shellcheck source=../hack/ensure-go.sh
23+ source " ${REPO_ROOT} /hack/ensure-go.sh"
24+
25+ cd " ${REPO_ROOT} " && APIDIFF_OLD_COMMIT=" ${PULL_BASE_SHA} " make apidiff
You can’t perform that action at this time.
0 commit comments