mirror of
https://github.com/ceph/go-ceph
synced 2024-12-21 13:51:55 +00:00
86a3a66849
Pass `CEPH_VERSION=minic` (or 'luminous') on the `make test-docker` command to select building a container with a different Ceph version and running the tests in it. This passes the given CEPH_VERSION on to the `docker build` command as a --build-arg, which gets used for selecting the Ceph repository during container build. It also sets the environment variable CEPH_VERSION, which in turn is consumed by `entrypoint.sh` to set the `go build -tags ${CEPH_VERSION}` option that includes/excludes certain *.go files. See-also: https://golang.org/pkg/go/build/#hdr-Build_Constraints Signed-off-by: Niels de Vos <ndevos@redhat.com>
49 lines
1.8 KiB
Makefile
49 lines
1.8 KiB
Makefile
DOCKER_CI_IMAGE = go-ceph-ci
|
|
CONTAINER_CMD := docker
|
|
CONTAINER_OPTS := --security-opt $(shell grep -q selinux /sys/kernel/security/lsm && echo "label=disabled" || echo "apparmor:unconfined")
|
|
VOLUME_FLAGS :=
|
|
CEPH_VERSION := nautilus
|
|
|
|
SELINUX := $(shell getenforce 2>/dev/null)
|
|
ifeq ($(SELINUX),Enforcing)
|
|
VOLUME_FLAGS = :z
|
|
endif
|
|
|
|
build:
|
|
go build -v -tags $(CEPH_VERSION) $(shell go list ./... | grep -v /contrib)
|
|
fmt:
|
|
go fmt ./...
|
|
test:
|
|
go test -v ./...
|
|
|
|
test-docker: check-ceph-version .build-docker
|
|
$(CONTAINER_CMD) run --device /dev/fuse --cap-add SYS_ADMIN $(CONTAINER_OPTS) --rm -it -v $(CURDIR):/go/src/github.com/ceph/go-ceph$(VOLUME_FLAGS) $(DOCKER_CI_IMAGE)
|
|
|
|
.build-docker: Dockerfile entrypoint.sh
|
|
$(CONTAINER_CMD) build --build-arg CEPH_VERSION=$(CEPH_VERSION) -t $(DOCKER_CI_IMAGE) .
|
|
@$(CONTAINER_CMD) inspect -f '{{.Id}}' $(DOCKER_CI_IMAGE) > .build-docker
|
|
echo $(CEPH_VERSION) >> .build-docker
|
|
|
|
# check-ceph-version checks for the last used Ceph version in the container
|
|
# image and forces a rebuild of the image in case the Ceph version changed
|
|
.PHONY: check-ceph-version
|
|
check-ceph-version:
|
|
@grep -wq '$(CEPH_VERSION)' .build-docker 2>/dev/null || $(RM) .build-docker
|
|
|
|
check:
|
|
# Configure project's revive checks using .revive.toml
|
|
# See: https://github.com/mgechev/revive
|
|
@for d in $$(go list ./... | grep -v /vendor/); do revive -config .revive.toml $${d}; done
|
|
|
|
# Do a quick compile only check of the tests and impliclity the
|
|
# library code as well.
|
|
test-binaries: cephfs.test errutil.test rados.test rbd.test
|
|
test-bins: test-binaries
|
|
|
|
%.test: % force_go_build
|
|
go test -c ./$<
|
|
|
|
# force_go_build is phony and builds nothing, can be used for forcing
|
|
# go toolchain commands to always run
|
|
.PHONY: build fmt test test-docker check test-binaries test-bins force_go_build
|