From 78190f834633c41184c43d29ab4785274e063e47 Mon Sep 17 00:00:00 2001 From: Chris Crone Date: Fri, 4 Dec 2020 17:48:15 +0100 Subject: [PATCH] build: Add containerized go mod tidy Signed-off-by: Chris Crone --- Dockerfile | 9 +++++++++ Makefile | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 742e584e..be4e43e1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -111,6 +111,15 @@ RUN go get -u github.com/kunalkushwaha/ltag RUN --mount=target=. \ make -f builder.Makefile check-license-headers +FROM base AS make-go-mod-tidy +COPY . . +RUN --mount=type=cache,target=/go/pkg/mod \ + go mod tidy + +FROM scratch AS go-mod-tidy +COPY --from=make-go-mod-tidy /compose-cli/go.mod . +COPY --from=make-go-mod-tidy /compose-cli/go.sum . + FROM base AS check-go-mod COPY . . RUN make -f builder.Makefile check-go-mod diff --git a/Makefile b/Makefile index 23d287c5..4a85885e 100644 --- a/Makefile +++ b/Makefile @@ -92,6 +92,9 @@ moby-cli-link: ## Create com.docker.cli symlink if does not already exist validate-headers: ## Check license header for all files @docker build . --target check-license-headers +go-mod-tidy: ## Run go mod tidy in a container and output resulting go.mod and go.sum + @docker build . --target go-mod-tidy --output . + validate-go-mod: ## Validate go.mod and go.sum are up-to-date @docker build . --target check-go-mod @@ -128,4 +131,4 @@ help: ## Show help FORCE: -.PHONY: all validate protos cli e2e-local cross test cache-clear lint check-dependencies serve classic-link help clean-aci-e2e +.PHONY: all validate protos cli e2e-local cross test cache-clear lint check-dependencies serve classic-link help clean-aci-e2e go-mod-tidy