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
|
2020-04-23 10:50:12 +00:00
|
|
|
CONTAINER_OPTS := --security-opt $(shell grep -q selinux /sys/kernel/security/lsm && echo "label=disable" || echo "apparmor:unconfined")
|
2020-03-11 18:57:27 +00:00
|
|
|
CONTAINER_CONFIG_DIR := testing/containers/ceph
|
2019-11-04 14:22:35 +00:00
|
|
|
VOLUME_FLAGS :=
|
2019-12-17 15:50:58 +00:00
|
|
|
CEPH_VERSION := nautilus
|
2020-04-17 15:29:30 +00:00
|
|
|
RESULTS_DIR :=
|
2020-05-13 21:01:32 +00:00
|
|
|
CHECK_GOFMT_FLAGS := -e -s -l
|
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
|
|
|
|
2020-04-17 15:29:30 +00:00
|
|
|
ifdef RESULTS_DIR
|
|
|
|
RESULTS_VOLUME := -v $(RESULTS_DIR):/results$(VOLUME_FLAGS)
|
|
|
|
endif
|
|
|
|
|
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 ./...
|
|
|
|
|
2020-03-11 17:50:23 +00:00
|
|
|
.PHONY: test-docker test-container
|
|
|
|
test-docker: test-container
|
2020-04-17 15:29:30 +00:00
|
|
|
test-container: check-ceph-version .build-docker $(RESULTS_DIR)
|
|
|
|
$(CONTAINER_CMD) run --device /dev/fuse --cap-add SYS_ADMIN $(CONTAINER_OPTS) --rm -v $(CURDIR):/go/src/github.com/ceph/go-ceph$(VOLUME_FLAGS) $(RESULTS_VOLUME) $(DOCKER_CI_IMAGE)
|
|
|
|
|
|
|
|
ifdef RESULTS_DIR
|
|
|
|
$(RESULTS_DIR):
|
|
|
|
mkdir -p $(RESULTS_DIR)
|
|
|
|
endif
|
2015-05-24 08:13:05 +00:00
|
|
|
|
2020-03-11 17:50:23 +00:00
|
|
|
.PHONY: ci-image
|
|
|
|
ci-image: .build-docker
|
2020-03-11 18:52:53 +00:00
|
|
|
.build-docker: $(CONTAINER_CONFIG_DIR)/Dockerfile entrypoint.sh
|
|
|
|
$(CONTAINER_CMD) build --build-arg CEPH_VERSION=$(CEPH_VERSION) -t $(DOCKER_CI_IMAGE) -f $(CONTAINER_CONFIG_DIR)/Dockerfile .
|
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
|
|
|
|
2020-05-13 21:01:32 +00:00
|
|
|
check: check-revive check-format
|
|
|
|
|
|
|
|
check-format:
|
|
|
|
! gofmt $(CHECK_GOFMT_FLAGS) . | sed 's,^,formatting error: ,' | grep 'go$$'
|
|
|
|
|
|
|
|
check-revive:
|
2019-12-12 02:04:19 +00:00
|
|
|
# Configure project's revive checks using .revive.toml
|
|
|
|
# See: https://github.com/mgechev/revive
|
2020-03-28 17:20:13 +00:00
|
|
|
revive -config .revive.toml $$(go list ./... | grep -v /vendor/)
|
2020-02-04 19:46:17 +00:00
|
|
|
|
|
|
|
# Do a quick compile only check of the tests and impliclity the
|
|
|
|
# library code as well.
|
2020-04-13 15:22:39 +00:00
|
|
|
test-binaries: \
|
|
|
|
cephfs.test \
|
|
|
|
internal/callbacks.test \
|
|
|
|
internal/cutil.test \
|
|
|
|
internal/errutil.test \
|
|
|
|
internal/retry.test \
|
|
|
|
rados.test \
|
|
|
|
rbd.test
|
2020-02-04 19:46:17 +00:00
|
|
|
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
|