From 104203ed0357493923bd92cd8cf0f306168db360 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Tue, 18 Aug 2020 10:10:12 +0200 Subject: [PATCH] ci: pass REBASE=1 to have commitlint rebase the branch When Mergify adds a merge commit to the branch that is being tested with commitlint, the tool tries to detect the most recent changes based on the newly merged commit. This is for most PRs the master branch, and that contains incorrect commit messages in the history. Because of this, commitlint will fail. By adding an option (REBASE=1) to the commitlint make target, CI jobs can request a rebase so that the history of the PR becomes linear again and commitlint should be able to detect only the new commits. Signed-off-by: Niels de Vos --- Makefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7c7fd1e2e..f69eb4752 100644 --- a/Makefile +++ b/Makefile @@ -119,8 +119,15 @@ func-test: check-env: @./scripts/check-env.sh +# +# commitlint will do a rebase on top of GIT_SINCE when REBASE=1 is passed. +# +# Usage: make commitlint REBASE=1 +# +commitlint: REBASE ?= 0 commitlint: git fetch -v $(shell cut -d/ -f1 <<< "$(GIT_SINCE)") $(shell cut -d/ -f2- <<< "$(GIT_SINCE)") + @test $(REBASE) -eq 0 || git -c user.name=commitlint -c user.email=commitline@localhost rebase $(GIT_SINCE) commitlint --from FETCH_HEAD .PHONY: cephcsi @@ -157,8 +164,9 @@ containerized-build: .container-cmd .devel-container-id $(CONTAINER_CMD) run --rm -v $(CURDIR):/go/src/github.com/ceph/ceph-csi$(SELINUX_VOL_FLAG) $(CSI_IMAGE_NAME):devel make $(TARGET) containerized-test: TARGET = test +containerized-test: REBASE ?= 0 containerized-test: .container-cmd .test-container-id - $(CONTAINER_CMD) run --rm -v $(CURDIR):/go/src/github.com/ceph/ceph-csi$(SELINUX_VOL_FLAG) $(CSI_IMAGE_NAME):test make $(TARGET) GIT_SINCE=$(GIT_SINCE) + $(CONTAINER_CMD) run --rm -v $(CURDIR):/go/src/github.com/ceph/ceph-csi$(SELINUX_VOL_FLAG) $(CSI_IMAGE_NAME):test make $(TARGET) GIT_SINCE=$(GIT_SINCE) REBASE=$(REBASE) # create a (cached) container image with dependencied for building cephcsi .devel-container-id: .container-cmd scripts/Dockerfile.devel