From e2cc41f44e545427eda5c916b089f69ae99e80a9 Mon Sep 17 00:00:00 2001
From: Valentin Rothberg <rothberg@redhat.com>
Date: Fri, 20 Sep 2019 10:43:14 +0200
Subject: [PATCH] add vendor checks to Makefile and the CI

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
---
 .cirrus.yml         |  2 ++
 Makefile            |  9 ++++++++-
 hack/tree_status.sh | 15 +++++++++++++++
 3 files changed, 25 insertions(+), 1 deletion(-)
 create mode 100755 hack/tree_status.sh

diff --git a/.cirrus.yml b/.cirrus.yml
index d5498eb..fcca28b 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -61,6 +61,8 @@ validate_task:
 
     validate_script:
       - make validate
+      - make vendor
+      - ./hack/tree_status.sh
       - make
 
 test_task:
diff --git a/Makefile b/Makefile
index 31f8370..4d1cf4c 100644
--- a/Makefile
+++ b/Makefile
@@ -76,9 +76,16 @@ clean:
 test: .install.ginkgo
 	$(GO) test -v ./...
 
+vendor:
+	export GO111MODULE=on \
+		$(GO) mod tidy && \
+		$(GO) mod vendor && \
+		$(GO) mod verify
+
 .PHONY: \
 	binaries \
 	test \
 	gofmt \
 	lint \
-	validate
+	validate \
+	vendor
diff --git a/hack/tree_status.sh b/hack/tree_status.sh
new file mode 100755
index 0000000..ac874a3
--- /dev/null
+++ b/hack/tree_status.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+set -e
+
+SUGGESTION="${SUGGESTION:-sync the vendor.conf and commit all changes.}"
+
+STATUS=$(git status --porcelain)
+if [[ -z $STATUS ]]
+then
+	echo "tree is clean"
+else
+	echo "tree is dirty, please $SUGGESTION"
+	echo ""
+	echo "$STATUS"
+	exit 1
+fi
-- 
GitLab