2015-05-24 08:13:05 +00:00
|
|
|
DOCKER_CI_IMAGE = go-ceph-ci
|
2019-10-21 23:04:22 +00:00
|
|
|
CONTAINER_CMD := docker
|
2019-12-05 14:13:04 +00:00
|
|
|
CONTAINER_OPTS := --security-opt $(shell grep -q selinux /sys/kernel/security/lsm && echo "label=disabled" || echo "apparmor:unconfined")
|
2019-11-04 14:22:35 +00:00
|
|
|
VOLUME_FLAGS :=
|
2019-12-17 15:50:58 +00:00
|
|
|
CEPH_VERSION := nautilus
|
2019-11-04 14:22:35 +00:00
|
|
|
|
|
|
|
SELINUX := $(shell getenforce 2>/dev/null)
|
|
|
|
ifeq ($(SELINUX),Enforcing)
|
|
|
|
VOLUME_FLAGS = :z
|
|
|
|
endif
|
2019-10-21 23:04:22 +00:00
|
|
|
|
2015-05-24 08:13:05 +00:00
|
|
|
build:
|
2019-12-17 15:50:58 +00:00
|
|
|
go build -v -tags $(CEPH_VERSION) $(shell go list ./... | grep -v /contrib)
|
2015-05-24 08:13:05 +00:00
|
|
|
fmt:
|
|
|
|
go fmt ./...
|
|
|
|
test:
|
|
|
|
go test -v ./...
|
|
|
|
|
2019-12-17 15:50:58 +00:00
|
|
|
test-docker: check-ceph-version .build-docker
|
2019-11-04 14:22:35 +00:00
|
|
|
$(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)
|
2015-05-24 08:13:05 +00:00
|
|
|
|
2019-10-30 18:22:08 +00:00
|
|
|
.build-docker: Dockerfile entrypoint.sh
|
2019-12-17 15:50:58 +00:00
|
|
|
$(CONTAINER_CMD) build --build-arg CEPH_VERSION=$(CEPH_VERSION) -t $(DOCKER_CI_IMAGE) .
|
2019-10-21 23:04:22 +00:00
|
|
|
@$(CONTAINER_CMD) inspect -f '{{.Id}}' $(DOCKER_CI_IMAGE) > .build-docker
|
2019-12-17 15:50:58 +00:00
|
|
|
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
|
2018-12-10 22:17:39 +00:00
|
|
|
|
|
|
|
check:
|
2019-12-12 02:04:19 +00:00
|
|
|
# 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
|
2020-02-04 19:46:17 +00:00
|
|
|
|
|
|
|
# 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
|