From 4939ca33009916e79eca211d156c6b67ff4923b3 Mon Sep 17 00:00:00 2001 From: Andrei Aaron Date: Tue, 21 Mar 2023 19:25:13 +0200 Subject: [PATCH] ci(go.mod): verify go.mod and go.sum don't have uncommitted changes after `go mod tidy` (#1287) This is to avoid situations such as https://github.com/project-zot/zot/pull/1150 where an indirect dependency became direct without a corresponding go.mod change Signed-off-by: Andrei Aaron --- Makefile | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index dae6e9a2..35958707 100644 --- a/Makefile +++ b/Makefile @@ -36,10 +36,19 @@ extended-name:= .PHONY: all all: modcheck swagger binary binary-minimal binary-debug cli bench exporter-minimal verify-config test covhtml check check-gh-actions -.PHONY: modcheck -modcheck: +.PHONY: modtidy +modtidy: go mod tidy +.PHONY: modcheck +modcheck: modtidy + $(eval UNCOMMITED_FILES = $(shell git status --porcelain | grep -c 'go.mod\|go.sum')) + @if [ $(UNCOMMITED_FILES) != 0 ]; then \ + echo "Updated go.mod and/or go.sum have uncommitted changes, commit the changes accordingly ";\ + git status;\ + exit 1;\ + fi + .PHONY: create-name create-name: ifdef EXTENSIONS