forked from astronomer/astro-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
67 lines (51 loc) · 1.54 KB
/
Makefile
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
OUTPUT ?= astro
GIT_COMMIT=$(shell git rev-parse HEAD)
GIT_COMMIT_SHORT=$(shell git rev-parse --short HEAD)
VERSION ?= SNAPSHOT-${GIT_COMMIT_SHORT}
LDFLAGS_VERSION=-X github.com/astronomer/astro-cli/version.CurrVersion=${VERSION}
LDFLAGS_GIT_COMMIT=-X github.com/astronomer/astro-cli/version.CurrCommit=${GIT_COMMIT}
.DEFAULT_GOAL := build
dep:
dep ensure
build:
go build -o ${OUTPUT} -ldflags "${LDFLAGS_VERSION} ${LDFLAGS_GIT_COMMIT}" main.go
test:
go test -v ./...
format:
@echo "--> Running go fmt"
@go fmt $(GOFILES)
vet:
@echo "--> Running go vet"
@go vet $(GOFILES); if [ $$? -eq 1 ]; then \
echo ""; \
echo "Vet found suspicious constructs. Please check the reported constructs"; \
echo "and fix them if necessary before submitting the code for review."; \
exit 1; \
fi
style:
@echo ">> checking code style"
@! gofmt -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^'
staticcheck:
@echo ">> running staticcheck"
@staticcheck $(GOFILES)
gosimple:
@echo ">> running gosimple"
@gosimple $(GOFILES)
tools:
@echo ">> installing some extra tools"
@go get -u -v honnef.co/go/tools/...
install: build
$(eval DESTDIR ?= $(GOBIN))
mkdir -p $(DESTDIR)
cp ${OUTPUT} $(DESTDIR)
uninstall:
$(eval DESTDIR ?= $(GOBIN))
rm $(GOBIN)/$(OUTPUT)
ifeq (debug,$(firstword $(MAKECMDGOALS)))
# use the rest as arguments for "debug"
DEBUG_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
$(eval $(DEBUG_ARGS):;@:)
endif
debug:
echo $(RUN_ARGS)
dlv debug github.com/astronomer/astro-cli -- $(DEBUG_ARGS)