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 <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2020-08-18 10:10:12 +02:00 committed by mergify[bot]
parent aca606ca42
commit 104203ed03

View File

@ -119,8 +119,15 @@ func-test:
check-env: check-env:
@./scripts/check-env.sh @./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: commitlint:
git fetch -v $(shell cut -d/ -f1 <<< "$(GIT_SINCE)") $(shell cut -d/ -f2- <<< "$(GIT_SINCE)") 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 commitlint --from FETCH_HEAD
.PHONY: cephcsi .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) $(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: TARGET = test
containerized-test: REBASE ?= 0
containerized-test: .container-cmd .test-container-id 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 # create a (cached) container image with dependencied for building cephcsi
.devel-container-id: .container-cmd scripts/Dockerfile.devel .devel-container-id: .container-cmd scripts/Dockerfile.devel