Debian Codegraph @

Makefile

raw ◀ ▶
1 Debian patch touch this file
1 SHELL = /bin/bash -euo pipefail
2
3 # Go binary to use in non-container targets
4 GO ?= go
5
6 # Variables for container targets
7 GO_VERSION ?= latest
8 CONTAINER ?= golang:$(GO_VERSION)
9 PKG = github.com/lorenzosaino/go-sysctl
10 DOCKER_RUN_FLAGS = --rm -it -v $$(pwd):/go/src/$(PKG) -w /go/src/$(PKG)
11
12 export GO111MODULE=on
13
•14 all: fmt-check vet nilness staticcheck test ## Run all checks and tests
15
16 .PHONY: mod-upgrade
17 mod-upgrade: ## Upgrade all vendored dependencies
18 $(GO) get -d -u -t ./...
19 $(GO) mod tidy
20 $(GO) mod vendor
21
22 .PHONY: mod-update
23 mod-update: ## Ensure all used dependencies are tracked in go.{mod|sum} and vendored
24 $(GO) mod tidy
25 $(GO) mod vendor
26
27 .PHONY: fmt-check
28 fmt-check: ## Validate that all source files pass "go fmt"
29 exit $(shell $(GO) fmt ./... | wc -l)
30
31
32 .PHONY: vet
33 vet: ## Run go vet
34 $(GO) vet ./...
35
36 .PHONY: staticcheck
37 staticcheck: ## Run staticcheck
38 @[ -x "$(shell which staticcheck)" ] || $(GO) install ./vendor/honnef.co/go/tools/cmd/staticcheck 2>/dev/null || $(GO) install honnef.co/go/tools/cmd/staticcheck@latest
39 staticcheck ./...
40
41 nilness: ## Run nilness
42 $(GO) install ./vendor/golang.org/x/tools/go/analysis/passes/nilness/cmd/nilness 2>/dev/null || [ -x "$(shell which nilness)" ] || $(GO) install golang.org/x/tools/go/analysis/passes/nilness/cmd/nilness@latest
43 nilness ./...
44
45 .PHONY: test
46 test: ## Run all tests
47 $(GO) test -race ./...
48
49 .PHONY: container-shell
50 container-shell: ## Open a shell on a Docker container
51 docker run $(DOCKER_RUN_FLAGS) $(CONTAINER) /bin/bash
52
53 .PHONY: container-%
54 container-%: ## Run any target of this Makefile in a Docker container
55 docker run $(DOCKER_RUN_FLAGS) $(CONTAINER) make $*
56
57 .PHONY: help
58 help: ## Print help
59 @(grep -E '^[a-zA-Z0-9_%-]+:.*?## .*$$' Makefile || true )| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'