mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
add make target for containerized tests
`make containerized-test` has been added as a make target. This runs the 'make test' target in a container. All test dependencies are installed in the container once, and the container is kept around for running `make containerized-test` subsequently. The test container is based on Fedora:latest so that all test tools get easily installed and are available in a recent version. The production container is based on the Ceph container which has CentOS as Operating System and therefor a more stable (too old) toolset. Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
committed by
mergify[bot]
parent
58c2a3f15f
commit
3c6054ddf9
15
Makefile
15
Makefile
@ -65,16 +65,25 @@ cephcsi:
|
||||
if [ ! -d ./vendor ]; then (go mod tidy && go mod vendor); fi
|
||||
GOOS=linux GOARCH=$(GOARCH) go build -mod vendor -a -ldflags '$(LDFLAGS)' -o _output/cephcsi ./cmd/
|
||||
|
||||
.PHONY: containerized-build
|
||||
.PHONY: containerized-build containerized-test
|
||||
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 -C /go/src/github.com/ceph/ceph-csi 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 test
|
||||
|
||||
# create a (cached) container image with dependencied for building cephcsi
|
||||
.devel-container-id: scripts/Dockerfile.devel
|
||||
[ ! -f .devel-container-id ] || $(CONTAINER_CMD) rmi $(CSI_IMAGE_NAME):devel
|
||||
$(CONTAINER_CMD) build -t $(CSI_IMAGE_NAME):devel -f ./scripts/Dockerfile.devel .
|
||||
$(CONTAINER_CMD) inspect -f '{{.Id}}' $(CSI_IMAGE_NAME):devel > .devel-container-id
|
||||
|
||||
# create a (cached) container image with dependencied for testing cephcsi
|
||||
.test-container-id: scripts/Dockerfile.test
|
||||
[ ! -f .test-container-id ] || $(CONTAINER_CMD) rmi $(CSI_IMAGE_NAME):test
|
||||
$(CONTAINER_CMD) build -t $(CSI_IMAGE_NAME):test -f ./scripts/Dockerfile.test .
|
||||
$(CONTAINER_CMD) inspect -f '{{.Id}}' $(CSI_IMAGE_NAME):test > .test-container-id
|
||||
|
||||
image-cephcsi: cephcsi
|
||||
cp _output/cephcsi deploy/cephcsi/image/cephcsi
|
||||
chmod +x deploy/cephcsi/image/cephcsi
|
||||
@ -87,8 +96,10 @@ push-image-cephcsi: image-cephcsi
|
||||
if [ $(GOARCH) = amd64 ]; then $(CONTAINER_CMD) push $(CSI_IMAGE); fi
|
||||
|
||||
clean:
|
||||
go clean -r -x
|
||||
go clean -mod=vendor -r -x
|
||||
rm -f deploy/cephcsi/image/cephcsi
|
||||
rm -f _output/cephcsi
|
||||
[ ! -f .devel-container-id ] || $(CONTAINER_CMD) rmi $(CSI_IMAGE_NAME):devel
|
||||
$(RM) .devel-container-id
|
||||
[ ! -f .test-container-id ] || $(CONTAINER_CMD) rmi $(CSI_IMAGE_NAME):test
|
||||
$(RM) .test-container-id
|
||||
|
Reference in New Issue
Block a user