mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-24 04:54:00 +00:00
Update makefile with Development docker image
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
72fe259745
commit
a7f3398a68
81
Makefile
81
Makefile
@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2017-2021, NVIDIA CORPORATION. All rights reserved.
|
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@ -27,14 +27,39 @@ MODULE := github.com/NVIDIA/nvidia-container-toolkit
|
|||||||
docker-native:
|
docker-native:
|
||||||
include $(CURDIR)/docker/docker.mk
|
include $(CURDIR)/docker/docker.mk
|
||||||
|
|
||||||
|
ifeq ($(IMAGE),)
|
||||||
|
REGISTRY ?= nvidia
|
||||||
|
IMAGE=$(REGISTRY)/container-toolkit
|
||||||
|
endif
|
||||||
|
IMAGE_TAG ?= $(GOLANG_VERSION)
|
||||||
|
BUILDIMAGE ?= $(IMAGE):$(IMAGE_TAG)-devel
|
||||||
|
|
||||||
|
EXAMPLES := $(patsubst ./examples/%/,%,$(sort $(dir $(wildcard ./examples/*/))))
|
||||||
|
EXAMPLE_TARGETS := $(patsubst %,example-%, $(EXAMPLES))
|
||||||
|
|
||||||
|
MAKE_TARGETS := binary build all check fmt assert-fmt lint lint-internal vet test examples coverage generate
|
||||||
|
|
||||||
|
TARGETS := $(MAKE_TARGETS) $(EXAMPLE_TARGETS)
|
||||||
|
|
||||||
|
DOCKER_TARGETS := $(patsubst %,docker-%, $(TARGETS))
|
||||||
|
.PHONY: $(TARGETS) $(DOCKER_TARGETS)
|
||||||
|
|
||||||
GOOS ?= linux
|
GOOS ?= linux
|
||||||
|
|
||||||
binary:
|
binary:
|
||||||
GOOS=$(GOOS) go build -ldflags "-s -w" -o "$(LIB_NAME)" $(MODULE)/cmd/$(LIB_NAME)
|
GOOS=$(GOOS) go build -ldflags "-s -w" -o "$(LIB_NAME)" $(MODULE)/cmd/$(LIB_NAME)
|
||||||
|
|
||||||
# Define the check targets for the Golang codebase
|
build:
|
||||||
.PHONY: check fmt assert-fmt ineffassign lint misspell vet
|
GOOS=$(GOOS) go build ./...
|
||||||
check: assert-fmt lint misspell vet
|
|
||||||
|
examples: $(EXAMPLE_TARGETS)
|
||||||
|
$(EXAMPLE_TARGETS): example-%:
|
||||||
|
GOOS=$(GOOS) go build ./examples/$(*)
|
||||||
|
|
||||||
|
all: check test build binary
|
||||||
|
check: assert-fmt lint vet
|
||||||
|
|
||||||
|
# Apply go fmt to the codebase
|
||||||
fmt:
|
fmt:
|
||||||
go list -f '{{.Dir}}' $(MODULE)/... \
|
go list -f '{{.Dir}}' $(MODULE)/... \
|
||||||
| xargs gofmt -s -l -w
|
| xargs gofmt -s -l -w
|
||||||
@ -55,8 +80,12 @@ ineffassign:
|
|||||||
ineffassign $(MODULE)/...
|
ineffassign $(MODULE)/...
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
# We use `go list -f '{{.Dir}}' $(GOLANG_PKG_PATH)/...` to skip the `vendor` folder.
|
# We use `go list -f '{{.Dir}}' $(MODULE)/...` to skip the `vendor` folder.
|
||||||
go list -f '{{.Dir}}' $(MODULE)/... | xargs golint -set_exit_status
|
go list -f '{{.Dir}}' $(MODULE)/... | grep -v /internal/ | xargs golint -set_exit_status
|
||||||
|
|
||||||
|
lint-internal:
|
||||||
|
# We use `go list -f '{{.Dir}}' $(MODULE)/...` to skip the `vendor` folder.
|
||||||
|
go list -f '{{.Dir}}' $(MODULE)/internal/... | xargs golint -set_exit_status
|
||||||
|
|
||||||
misspell:
|
misspell:
|
||||||
misspell $(MODULE)/...
|
misspell $(MODULE)/...
|
||||||
@ -65,8 +94,42 @@ vet:
|
|||||||
go vet $(MODULE)/...
|
go vet $(MODULE)/...
|
||||||
|
|
||||||
COVERAGE_FILE := coverage.out
|
COVERAGE_FILE := coverage.out
|
||||||
test:
|
test: build
|
||||||
go test -coverprofile=$(COVERAGE_FILE) $(MODULE)/...
|
go test -v -coverprofile=$(COVERAGE_FILE) $(MODULE)/...
|
||||||
|
|
||||||
coverage: test
|
coverage: test
|
||||||
go tool cover -func=$(COVERAGE_FILE)
|
cat $(COVERAGE_FILE) | grep -v "_mock.go" > $(COVERAGE_FILE).no-mocks
|
||||||
|
go tool cover -func=$(COVERAGE_FILE).no-mocks
|
||||||
|
|
||||||
|
generate:
|
||||||
|
go generate $(MODULE)/...
|
||||||
|
|
||||||
|
# Generate an image for containerized builds
|
||||||
|
# Note: This image is local only
|
||||||
|
.PHONY: .build-image .pull-build-image .push-build-image
|
||||||
|
.build-image: docker/Dockerfile.devel
|
||||||
|
if [ x"$(SKIP_IMAGE_BUILD)" = x"" ]; then \
|
||||||
|
$(DOCKER) build \
|
||||||
|
--progress=plain \
|
||||||
|
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
|
||||||
|
--tag $(BUILDIMAGE) \
|
||||||
|
-f $(^) \
|
||||||
|
docker; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
.pull-build-image:
|
||||||
|
$(DOCKER) pull $(BUILDIMAGE)
|
||||||
|
|
||||||
|
.push-build-image:
|
||||||
|
$(DOCKER) push $(BUILDIMAGE)
|
||||||
|
|
||||||
|
$(DOCKER_TARGETS): docker-%: .build-image
|
||||||
|
@echo "Running 'make $(*)' in docker container $(BUILDIMAGE)"
|
||||||
|
$(DOCKER) run \
|
||||||
|
--rm \
|
||||||
|
-e GOCACHE=/tmp/.cache \
|
||||||
|
-v $(PWD):$(PWD) \
|
||||||
|
-w $(PWD) \
|
||||||
|
--user $$(id -u):$$(id -g) \
|
||||||
|
$(BUILDIMAGE) \
|
||||||
|
make $(*)
|
||||||
|
Loading…
Reference in New Issue
Block a user