From f9f9fba26c24b888cd094bc9c85342c3ddc52ba1 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Thu, 2 Jul 2020 14:05:42 +0200 Subject: [PATCH] ci: generate golangci.yml with correct CEPH_VERSION When building against go-ceph, the most recent version of Ceph is assumed to be available (currently Octopus). In case an older version of the development packages is installed, building go-ceph will fail. Golangci-lint does not accept the `-tags nautilus` parameter like other Golang tools. Instead, the build-constraints need to be configured in a confguration file. This change takes care of the following: - move the current scripts/golangci.yml to a template - add the @@CEPH_VERSION@@ substitute - generate the configuration file when needed Signed-off-by: Niels de Vos --- .gitignore | 3 +++ Makefile | 6 +++++- scripts/{golangci.yml => golangci.yml.in} | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) rename scripts/{golangci.yml => golangci.yml.in} (99%) diff --git a/.gitignore b/.gitignore index 96e371bbd..f19f8ae30 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,6 @@ deploy/cephcsi/image/cephcsi *.orig *.patch *.rej + +# generated golangci-lint configuration +scripts/golangci.yml diff --git a/Makefile b/Makefile index 6a14e17b0..d16fac6a5 100644 --- a/Makefile +++ b/Makefile @@ -86,7 +86,10 @@ mod-check: check-env @echo 'running: go mod verify' @go mod verify && [ "$(shell sha512sum go.mod)" = "`sha512sum go.mod`" ] || ( echo "ERROR: go.mod was modified by 'go mod verify'" && false ) -go-lint: +scripts/golangci.yml: scripts/golangci.yml.in + sed "s/@@CEPH_VERSION@@/$(CEPH_VERSION)/g" < scripts/golangci.yml.in > scripts/golangci.yml + +go-lint: scripts/golangci.yml ./scripts/lint-go.sh lint-extras: @@ -163,6 +166,7 @@ clean: go clean -mod=vendor -r -x rm -f deploy/cephcsi/image/cephcsi rm -f _output/cephcsi + $(RM) scripts/golangci.yml $(RM) e2e.test [ ! -f .devel-container-id ] || $(CONTAINER_CMD) rmi $(CSI_IMAGE_NAME):devel $(RM) .devel-container-id diff --git a/scripts/golangci.yml b/scripts/golangci.yml.in similarity index 99% rename from scripts/golangci.yml rename to scripts/golangci.yml.in index 9b97d9a92..440ea12ae 100644 --- a/scripts/golangci.yml +++ b/scripts/golangci.yml.in @@ -5,6 +5,9 @@ # options for analysis running run: + build-tags: + - @@CEPH_VERSION@@ + # default concurrency is a available CPU number concurrency: 4