From eff4f4ba50c8b20f30cd4303ebe9f05a521d8866 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Wed, 13 May 2020 15:20:05 +0200 Subject: [PATCH] ci: add commitlint target to the Makefile When passing `GIT_SINCE` as an argument, the commits from then on (defaults to origin/master) are used. A CI job can pass the base branch or ID so a range of patches gets checked. To test the last four commits, one can run: $ make containerized-test TARGET=commitlint GIT_SINCE=HEAD~4 Signed-off-by: Niels de Vos --- Makefile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 27237afe5..3b8f74b94 100644 --- a/Makefile +++ b/Makefile @@ -53,6 +53,10 @@ endif # single tests. TARGET ?= test +# Pass GIT_SINCE for the range of commits to test. Used with the commitlint +# target. +GIT_SINCE := origin/master + SELINUX := $(shell getenforce 2>/dev/null) ifeq ($(SELINUX),Enforcing) SELINUX_VOL_FLAG = :z @@ -60,7 +64,7 @@ endif all: cephcsi -.PHONY: go-test static-check mod-check go-lint lint-extras gosec +.PHONY: go-test static-check mod-check go-lint lint-extras gosec commitlint test: go-test static-check mod-check static-check: check-env go-lint lint-extras gosec @@ -98,6 +102,9 @@ func-test: check-env: @./scripts/check-env.sh +commitlint: + commitlint --from $(GIT_SINCE) + .PHONY: cephcsi cephcsi: check-env if [ ! -d ./vendor ]; then (go mod tidy && go mod vendor); fi @@ -108,7 +115,7 @@ containerized-build: .devel-container-id $(CONTAINER_CMD) run --rm -v $(PWD):/go/src/github.com/ceph/ceph-csi$(SELINUX_VOL_FLAG) $(CSI_IMAGE_NAME):devel make cephcsi containerized-test: .test-container-id - $(CONTAINER_CMD) run --rm -v $(PWD):/go/src/github.com/ceph/ceph-csi$(SELINUX_VOL_FLAG) $(CSI_IMAGE_NAME):test make $(TARGET) + $(CONTAINER_CMD) run --rm -v $(PWD):/go/src/github.com/ceph/ceph-csi$(SELINUX_VOL_FLAG) $(CSI_IMAGE_NAME):test make $(TARGET) GIT_SINCE=$(GIT_SINCE) # create a (cached) container image with dependencied for building cephcsi .devel-container-id: scripts/Dockerfile.devel