2019-09-27 21:51:53 +00:00
|
|
|
# Copyright 2018 The containerd Authors.
|
2019-01-12 04:58:27 +00:00
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
GO := go
|
|
|
|
GOOS := $(shell $(GO) env GOOS)
|
|
|
|
GOARCH := $(shell $(GO) env GOARCH)
|
2019-09-27 21:51:53 +00:00
|
|
|
WHALE = "🇩"
|
|
|
|
ONI = "👹"
|
2019-01-12 04:58:27 +00:00
|
|
|
EPOCH_TEST_COMMIT := f9e02affccd51702191e5312665a16045ffef8ab
|
|
|
|
PROJECT := github.com/containerd/cri
|
|
|
|
BINDIR := ${DESTDIR}/usr/local/bin
|
|
|
|
BUILD_DIR := _output
|
|
|
|
# VERSION is derived from the current commit for HEAD. Version is used
|
|
|
|
# to set/overide the containerd version in vendor/github.com/containerd/containerd/version.
|
|
|
|
VERSION := $(shell git rev-parse --short HEAD)
|
|
|
|
TARBALL_PREFIX := cri-containerd
|
|
|
|
TARBALL := $(TARBALL_PREFIX)-$(VERSION).$(GOOS)-$(GOARCH).tar.gz
|
|
|
|
BUILD_TAGS := seccomp apparmor
|
|
|
|
# Add `-TEST` suffix to indicate that all binaries built from this repo are for test.
|
|
|
|
GO_LDFLAGS := -X $(PROJECT)/vendor/github.com/containerd/containerd/version.Version=$(VERSION)-TEST
|
|
|
|
SOURCES := $(shell find cmd/ pkg/ vendor/ -name '*.go')
|
|
|
|
PLUGIN_SOURCES := $(shell ls *.go)
|
|
|
|
INTEGRATION_SOURCES := $(shell find integration/ -name '*.go')
|
|
|
|
|
|
|
|
all: binaries
|
|
|
|
|
2019-09-27 21:51:53 +00:00
|
|
|
help: ## this help
|
|
|
|
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9._-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort
|
|
|
|
|
|
|
|
verify: lint gofmt boiler check-vendor ## execute the source code verification tools
|
|
|
|
|
|
|
|
version: ## print current cri plugin release version
|
2019-01-12 04:58:27 +00:00
|
|
|
@echo $(VERSION)
|
|
|
|
|
|
|
|
lint:
|
2019-09-27 21:51:53 +00:00
|
|
|
@echo "$(WHALE) $@"
|
|
|
|
golangci-lint run --skip-files .*_test.go
|
2019-01-12 04:58:27 +00:00
|
|
|
|
|
|
|
gofmt:
|
2019-09-27 21:51:53 +00:00
|
|
|
@echo "$(WHALE) $@"
|
2019-01-12 04:58:27 +00:00
|
|
|
@./hack/verify-gofmt.sh
|
|
|
|
|
|
|
|
boiler:
|
2019-09-27 21:51:53 +00:00
|
|
|
@echo "$(WHALE) $@"
|
2019-01-12 04:58:27 +00:00
|
|
|
@./hack/verify-boilerplate.sh
|
|
|
|
|
2019-09-27 21:51:53 +00:00
|
|
|
check-vendor:
|
|
|
|
@echo "$(WHALE) $@"
|
|
|
|
@./hack/verify-vendor.sh
|
|
|
|
|
2019-01-12 04:58:27 +00:00
|
|
|
.PHONY: sort-vendor sync-vendor update-vendor
|
|
|
|
|
|
|
|
sort-vendor:
|
2019-09-27 21:51:53 +00:00
|
|
|
@echo "$(WHALE) $@"
|
2019-01-12 04:58:27 +00:00
|
|
|
@./hack/sort-vendor.sh
|
|
|
|
|
|
|
|
sync-vendor:
|
2019-09-27 21:51:53 +00:00
|
|
|
@echo "$(WHALE) $@ from containerd"
|
2019-01-12 04:58:27 +00:00
|
|
|
@./hack/sync-vendor.sh
|
|
|
|
|
2019-09-27 21:51:53 +00:00
|
|
|
update-vendor: sync-vendor sort-vendor ## Syncs containerd/vendor.conf -> vendor.conf and sorts vendor.conf
|
|
|
|
@echo "$(WHALE) $@"
|
2019-01-12 04:58:27 +00:00
|
|
|
|
|
|
|
$(BUILD_DIR)/containerd: $(SOURCES) $(PLUGIN_SOURCES)
|
2019-09-27 21:51:53 +00:00
|
|
|
@echo "$(WHALE) $@"
|
2019-01-12 04:58:27 +00:00
|
|
|
$(GO) build -o $@ \
|
|
|
|
-tags '$(BUILD_TAGS)' \
|
|
|
|
-ldflags '$(GO_LDFLAGS)' \
|
|
|
|
-gcflags '$(GO_GCFLAGS)' \
|
|
|
|
$(PROJECT)/cmd/containerd
|
|
|
|
|
2019-09-27 21:51:53 +00:00
|
|
|
test: ## unit test
|
|
|
|
@echo "$(WHALE) $@"
|
2019-01-12 04:58:27 +00:00
|
|
|
$(GO) test -timeout=10m -race ./pkg/... \
|
|
|
|
-tags '$(BUILD_TAGS)' \
|
|
|
|
-ldflags '$(GO_LDFLAGS)' \
|
|
|
|
-gcflags '$(GO_GCFLAGS)'
|
|
|
|
|
|
|
|
$(BUILD_DIR)/integration.test: $(INTEGRATION_SOURCES)
|
2019-09-27 21:51:53 +00:00
|
|
|
@echo "$(WHALE) $@"
|
2019-01-12 04:58:27 +00:00
|
|
|
$(GO) test -c $(PROJECT)/integration -o $(BUILD_DIR)/integration.test
|
|
|
|
|
2019-09-27 21:51:53 +00:00
|
|
|
test-integration: $(BUILD_DIR)/integration.test binaries ## integration test
|
|
|
|
@echo "$(WHALE) $@"
|
2019-01-12 04:58:27 +00:00
|
|
|
@./hack/test-integration.sh
|
|
|
|
|
2019-09-27 21:51:53 +00:00
|
|
|
test-cri: binaries ## critools CRI validation test
|
|
|
|
@echo "$(WHALE) $@"
|
2019-01-12 04:58:27 +00:00
|
|
|
@./hack/test-cri.sh
|
|
|
|
|
2019-09-27 21:51:53 +00:00
|
|
|
test-e2e-node: binaries ## e2e node test
|
|
|
|
@echo "$(WHALE) $@"
|
2019-01-12 04:58:27 +00:00
|
|
|
@VERSION=$(VERSION) ./hack/test-e2e-node.sh
|
|
|
|
|
2019-09-27 21:51:53 +00:00
|
|
|
clean: ## cleanup binaries
|
|
|
|
@echo "$(WHALE) $@"
|
|
|
|
@rm -rf $(BUILD_DIR)/*
|
2019-01-12 04:58:27 +00:00
|
|
|
|
2019-09-27 21:51:53 +00:00
|
|
|
binaries: $(BUILD_DIR)/containerd ## build a customized containerd (same result as make containerd)
|
|
|
|
@echo "$(WHALE) $@"
|
2019-01-12 04:58:27 +00:00
|
|
|
|
|
|
|
static-binaries: GO_LDFLAGS += -extldflags "-fno-PIC -static"
|
2019-09-27 21:51:53 +00:00
|
|
|
static-binaries: $(BUILD_DIR)/containerd ## build static containerd
|
|
|
|
@echo "$(WHALE) $@"
|
2019-01-12 04:58:27 +00:00
|
|
|
|
2019-09-27 21:51:53 +00:00
|
|
|
containerd: $(BUILD_DIR)/containerd ## build a customized containerd with CRI plugin for testing
|
|
|
|
@echo "$(WHALE) $@"
|
2019-01-12 04:58:27 +00:00
|
|
|
|
2019-09-27 21:51:53 +00:00
|
|
|
install-containerd: containerd ## installs customized containerd to system location
|
|
|
|
@echo "$(WHALE) $@"
|
|
|
|
@install -D -m 755 $(BUILD_DIR)/containerd $(BINDIR)/containerd
|
2019-01-12 04:58:27 +00:00
|
|
|
|
2019-09-27 21:51:53 +00:00
|
|
|
install: install-containerd ## installs customized containerd to system location
|
|
|
|
@echo "$(WHALE) $@"
|
2019-01-12 04:58:27 +00:00
|
|
|
|
2019-09-27 21:51:53 +00:00
|
|
|
uninstall: ## remove containerd from system location
|
|
|
|
@echo "$(WHALE) $@"
|
|
|
|
@rm -f $(BINDIR)/containerd
|
2019-01-12 04:58:27 +00:00
|
|
|
|
|
|
|
$(BUILD_DIR)/$(TARBALL): static-binaries vendor.conf
|
|
|
|
@BUILD_DIR=$(BUILD_DIR) TARBALL=$(TARBALL) VERSION=$(VERSION) ./hack/release.sh
|
|
|
|
|
2019-09-27 21:51:53 +00:00
|
|
|
release: $(BUILD_DIR)/$(TARBALL) ## build release tarball
|
2019-01-12 04:58:27 +00:00
|
|
|
|
2019-09-27 21:51:53 +00:00
|
|
|
push: $(BUILD_DIR)/$(TARBALL) ## push release tarball to GCS
|
|
|
|
@echo "$(WHALE) $@"
|
2019-01-12 04:58:27 +00:00
|
|
|
@BUILD_DIR=$(BUILD_DIR) TARBALL=$(TARBALL) VERSION=$(VERSION) ./hack/push.sh
|
|
|
|
|
2019-09-27 21:51:53 +00:00
|
|
|
proto: ## update protobuf of the cri plugin api
|
|
|
|
@echo "$(WHALE) $@"
|
|
|
|
@API_PATH=pkg/api/v1 hack/update-proto.sh
|
|
|
|
@API_PATH=pkg/api/runtimeoptions/v1 hack/update-proto.sh
|
2019-01-12 04:58:27 +00:00
|
|
|
|
|
|
|
.PHONY: install.deps
|
|
|
|
|
2019-09-27 21:51:53 +00:00
|
|
|
install.deps: ## install dependencies of cri (default 'seccomp apparmor' BUILDTAGS for runc build)
|
|
|
|
@echo "$(WHALE) $@"
|
2019-01-12 04:58:27 +00:00
|
|
|
@./hack/install/install-deps.sh
|
|
|
|
|
|
|
|
.PHONY: .gitvalidation
|
|
|
|
# When this is running in travis, it will only check the travis commit range.
|
|
|
|
# When running outside travis, it will check from $(EPOCH_TEST_COMMIT)..HEAD.
|
|
|
|
.gitvalidation:
|
2019-09-27 21:51:53 +00:00
|
|
|
@echo "$(WHALE) $@"
|
2019-01-12 04:58:27 +00:00
|
|
|
ifeq ($(TRAVIS),true)
|
|
|
|
git-validation -q -run DCO,short-subject
|
|
|
|
else
|
|
|
|
git-validation -v -run DCO,short-subject -range $(EPOCH_TEST_COMMIT)..HEAD
|
|
|
|
endif
|
|
|
|
|
2019-09-27 21:51:53 +00:00
|
|
|
.PHONY: install.tools .install.gitvalidation .install.golangci-lint .install.vndr
|
2019-01-12 04:58:27 +00:00
|
|
|
|
2019-09-27 21:51:53 +00:00
|
|
|
install.tools: .install.gitvalidation .install.golangci-lint .install.vndr ## install tools used by verify
|
|
|
|
@echo "$(WHALE) $@"
|
2019-01-12 04:58:27 +00:00
|
|
|
|
|
|
|
.install.gitvalidation:
|
2019-09-27 21:51:53 +00:00
|
|
|
@echo "$(WHALE) $@"
|
2019-01-12 04:58:27 +00:00
|
|
|
$(GO) get -u github.com/vbatts/git-validation
|
|
|
|
|
2019-09-27 21:51:53 +00:00
|
|
|
.install.golangci-lint:
|
|
|
|
@echo "$(WHALE) $@"
|
2019-10-22 17:27:11 +00:00
|
|
|
$(GO) get -d github.com/golangci/golangci-lint/cmd/golangci-lint
|
|
|
|
@cd $(GOPATH)/src/github.com/golangci/golangci-lint/cmd/golangci-lint; \
|
|
|
|
git checkout v1.18.0; \
|
|
|
|
go install
|
2019-09-27 21:51:53 +00:00
|
|
|
|
|
|
|
.install.vndr:
|
|
|
|
@echo "$(WHALE) $@"
|
|
|
|
$(GO) get -u github.com/LK4D4/vndr
|
2019-01-12 04:58:27 +00:00
|
|
|
|
|
|
|
.PHONY: \
|
|
|
|
binaries \
|
|
|
|
static-binaries \
|
|
|
|
containerd \
|
|
|
|
install-containerd \
|
|
|
|
release \
|
|
|
|
push \
|
|
|
|
boiler \
|
|
|
|
clean \
|
|
|
|
default \
|
|
|
|
gofmt \
|
|
|
|
help \
|
|
|
|
install \
|
|
|
|
lint \
|
|
|
|
test \
|
|
|
|
test-integration \
|
|
|
|
test-cri \
|
|
|
|
test-e2e-node \
|
|
|
|
uninstall \
|
|
|
|
version \
|
2019-09-27 21:51:53 +00:00
|
|
|
proto \
|
|
|
|
check-vendor
|