2020-06-05 15:36:40 +00:00
|
|
|
CI_IMAGE_NAME = go-ceph-ci
|
2020-06-09 20:13:10 +00:00
|
|
|
CONTAINER_CMD ?=
|
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
|
2020-06-09 20:15:57 +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
|
2020-05-06 15:20:09 +00:00
|
|
|
IMPLEMENTS_OPTS :=
|
2019-11-04 14:22:35 +00:00
|
|
|
|
2020-06-09 20:13:10 +00:00
|
|
|
ifeq ($(CONTAINER_CMD),)
|
|
|
|
CONTAINER_CMD:=$(shell docker version >/dev/null 2>&1 && echo docker)
|
|
|
|
endif
|
|
|
|
ifeq ($(CONTAINER_CMD),)
|
|
|
|
CONTAINER_CMD:=$(shell podman version >/dev/null 2>&1 && echo podman)
|
|
|
|
endif
|
|
|
|
|
2020-06-05 15:36:40 +00:00
|
|
|
# the full name of the marker file including the ceph version
|
|
|
|
BUILDFILE=.build.$(CEPH_VERSION)
|
|
|
|
|
|
|
|
# the name of the image plus ceph version as tag
|
|
|
|
CI_IMAGE_TAG=$(CI_IMAGE_NAME):$(CEPH_VERSION)
|
|
|
|
|
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:
|
2020-06-09 20:37:47 +00:00
|
|
|
go test -v -tags $(CEPH_VERSION) ./...
|
2015-05-24 08:13:05 +00:00
|
|
|
|
2020-03-11 17:50:23 +00:00
|
|
|
.PHONY: test-docker test-container
|
|
|
|
test-docker: test-container
|
2020-06-10 14:46:28 +00:00
|
|
|
test-container: $(BUILDFILE) $(RESULTS_DIR)
|
2020-06-05 15:36:40 +00:00
|
|
|
$(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) $(CI_IMAGE_TAG)
|
2020-04-17 15:29:30 +00:00
|
|
|
|
|
|
|
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
|
2020-06-05 15:36:40 +00:00
|
|
|
ci-image: $(BUILDFILE)
|
2020-07-26 19:32:12 +00:00
|
|
|
$(BUILDFILE): $(CONTAINER_CONFIG_DIR)/Dockerfile entrypoint.sh micro-osd.sh
|
2020-06-05 15:36:40 +00:00
|
|
|
$(CONTAINER_CMD) build --build-arg CEPH_VERSION=$(CEPH_VERSION) -t $(CI_IMAGE_TAG) -f $(CONTAINER_CONFIG_DIR)/Dockerfile .
|
|
|
|
@$(CONTAINER_CMD) inspect -f '{{.Id}}' $(CI_IMAGE_TAG) > $(BUILDFILE)
|
|
|
|
echo $(CEPH_VERSION) >> $(BUILDFILE)
|
2019-12-17 15:50:58 +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
|
2020-06-09 20:37:47 +00:00
|
|
|
go test -c -tags $(CEPH_VERSION) ./$<
|
2020-02-04 19:46:17 +00:00
|
|
|
|
2020-05-04 21:39:22 +00:00
|
|
|
implements:
|
|
|
|
go build -o implements ./contrib/implements
|
|
|
|
|
2020-05-06 15:20:09 +00:00
|
|
|
check-implements: implements
|
|
|
|
./implements $(IMPLEMENTS_OPTS) ./cephfs ./rados ./rbd
|
|
|
|
|
2020-02-04 19:46:17 +00:00
|
|
|
# force_go_build is phony and builds nothing, can be used for forcing
|
|
|
|
# go toolchain commands to always run
|
2020-05-06 15:20:09 +00:00
|
|
|
.PHONY: build fmt test test-docker check test-binaries test-bins force_go_build check-implements
|