Skip to content

Commit 083f550

Browse files
committed
Apidiff test runs only if the changes are in api/ and exp/api/
Signed-off-by: Meghana Jangi <[email protected]>
1 parent bf6ba4d commit 083f550

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,11 @@ clean-temporary: ## Remove all temporary files and folders.
191191
clean-release: ## Remove the release folder.
192192
rm -rf $(RELEASE_DIR)
193193

194+
APIDIFF_OLD_COMMIT ?= $(shell git rev-parse origin/main)
195+
194196
.PHONY: apidiff
195197
apidiff: $(GO_APIDIFF) ## Check for API differences.
196-
$(GO_APIDIFF) $(shell git rev-parse origin/main) --print-compatible
198+
$(GO_APIDIFF) $(APIDIFF_OLD_COMMIT) --print-compatible
197199

198200
.PHONY: format-tiltfile
199201
format-tiltfile: ## Format the Tiltfile.

scripts/ci-apidiff.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ set -o pipefail
2020

2121
REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
2222

23-
APIDIFF="${REPO_ROOT}/hack/tools/bin/go-apidiff"
24-
25-
cd "${REPO_ROOT}" && make "${APIDIFF##*/}"
26-
echo "*** Running go-apidiff ***"
27-
28-
${APIDIFF} "${PULL_BASE_SHA}" --print-compatible
23+
cd "${REPO_ROOT}"
24+
APICHANGE=$(git --no-pager diff --name-only FETCH_HEAD)
25+
if echo "${APICHANGE}" | grep "/api/"
26+
then
27+
echo "*** Running go-apidiff ***"
28+
APIDIFF_OLD_COMMIT="${PULL_BASE_SHA}" make apidiff
29+
else
30+
echo "No files under api/ or exp/api/ changed."
31+
fi

0 commit comments

Comments
 (0)