forked from hashicorp/nomad-driver-podman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GNUmakefile
98 lines (82 loc) · 3.12 KB
/
GNUmakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
SHELL = bash
# Handle multi-path environments
GOPATH := $(shell go env GOPATH | cut -d: -f1)
# Respect $GOBIN if set in environment or via $GOENV file.
BIN := $(shell go env GOBIN)
ifndef BIN
BIN := $(GOPATH)/bin
endif
default: help
HELP_FORMAT=" \033[36m%-25s\033[0m %s\n"
.PHONY: help
help: ## Display this usage information
@echo "Valid targets:"
@grep -E '^[^ ]+:.*?## .*$$' $(MAKEFILE_LIST) | \
sort | \
awk 'BEGIN {FS = ":.*?## "}; \
{printf $(HELP_FORMAT), $$1, $$2}'
@echo ""
.PHONY: changelogfmt
changelogfmt: ## Format changelog GitHub links
@echo "--> Making [GH-xxxx] references clickable..."
@sed -E 's|([^\[])\[GH-([0-9]+)\]|\1[[GH-\2](https://github.com/hashicorp/nomad-driver-podman/issues/\2)]|g' CHANGELOG.md > changelog.tmp && mv changelog.tmp CHANGELOG.md
.PHONY: check
check: hclfmt ## Lint the source code
@echo "==> Linting source code ..."
@$(BIN)/golangci-lint run
@echo "==> vetting hc-log statements"
@$(BIN)/hclogvet $(CURDIR)
.PHONY: hclfmt
hclfmt: ## Format HCL files with hclfmt
@echo "--> Formatting HCL"
@find . -name '.git' -prune \
-o \( -name '*.nomad' -o -name '*.hcl' -o -name '*.tf' \) \
-print0 | xargs -0 hclfmt -w
@if (git status -s | grep -q -e '\.hcl$$' -e '\.nomad$$' -e '\.tf$$'); then echo The following HCL files are out of sync; git status -s | grep -e '\.hcl$$' -e '\.nomad$$' -e '\.tf$$'; exit 1; fi
.PHONY: deps
deps: ## Install build dependencies
@echo "==> Installing build dependencies ..."
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2
go install github.com/hashicorp/go-hclog/hclogvet@v0.1.6
go install gotest.tools/gotestsum@v1.10.0
go install github.com/hashicorp/hcl/v2/cmd/hclfmt@d0c4fa8b0bbc2e4eeccd1ed2a32c2089ed8c5cf1
.PHONY: clean
clean: ## Cleanup previous build
@echo "==> Cleanup previous build"
rm -f ./build/nomad-driver-podman
pkg/%/nomad-driver-podman: GO_OUT ?= $@
pkg/%/nomad-driver-podman: ## Build the nomad-driver-podman plugin for GOOS_GOARCH, e.g. pkg/linux_amd64/nomad-driver-podman
@echo "==> Building $@ with tags $(GO_TAGS)..."
CGO_ENABLED=0 \
GOOS=$(firstword $(subst _, ,$*)) \
GOARCH=$(lastword $(subst _, ,$*)) \
go build -trimpath -o $(GO_OUT)
.PRECIOUS: pkg/%/nomad-driver-podman
pkg/%.zip: pkg/%/nomad-driver-podman ## Build and zip the nomad-driver-podman plugin for GOOS_GOARCH, e.g. pkg/linux_amd64.zip
@echo "==> Packaging for $@..."
zip -j $@ $(dir $<)*
.PHONY: dev
dev: clean build/nomad-driver-podman ## Build the nomad-driver-podman plugin
build/nomad-driver-podman:
@echo "==> Building driver plugin ..."
mkdir -p build
go build -o build/nomad-driver-podman .
.PHONY: test
test: ## Run unit tests
@echo "==> Running unit tests ..."
go test -v -race ./...
.PHONY: test-ci
test-ci: ## Run unit tests in CI
@echo "==> Running unit tests in CI ..."
@$(BIN)/gotestsum --format=testname --rerun-fails=0 --packages=". ./api" -- \
-cover \
-timeout=10m \
-count=1 \
. ./api
.PHONY: version
version:
ifneq (,$(wildcard version/version_ent.go))
@$(CURDIR)/scripts/version.sh version/version.go version/version_ent.go
else
@$(CURDIR)/scripts/version.sh version/version.go version/version.go
endif