-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
103 lines (90 loc) · 2.21 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
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
99
100
101
102
103
.DEFAULT_GOAL:=help
## === Tasks ===
.PHONY: check
## Run tests and linters
check: tidy lint test
.PHONY: tidy
## Run go mod tidy
tidy:
@go mod tidy
.PHONY: outdated
## Show outdated direct dependencies
outdated:
@go list -u -m -json all | go-mod-outdated -update -direct
.PHONY: test
## Run tests
test:
@go test -coverprofile=coverage.out -race -json ./... | gotestfmt
.PHONY: test.demo
## Run tests
test.demo: install
@rm -rf tmp/test
@mkdir -p tmp/test
@cd tmp/test && \
git init . && \
git remote add origin https://github.com/foomo/posh-test-demo && \
posh init && \
echo "replace github.com/foomo/posh => ../../../" >> .posh/go.mod && \
make shell.build && \
bin/posh execute welcome demo
.PHONY: lint
## Run linter
lint:
@golangci-lint run
.PHONY: lint.fix
## Fix lint violations
lint.fix:
@golangci-lint run --fix
.PHONY: lint.super
## Run super linter
lint.super:
docker run --rm -it \
-e 'RUN_LOCAL=true' \
-e 'DEFAULT_BRANCH=main' \
-e 'IGNORE_GITIGNORED_FILES=true' \
-e 'VALIDATE_JSCPD=false' \
-e 'VALIDATE_GO=false' \
-v $(PWD):/tmp/lint \
github/super-linter
.PHONY: install
## Run go install
install: GOPATH=${shell go env GOPATH}
install:
@go install -a main.go
@mv "${GOPATH}/bin/main" "${GOPATH}/bin/posh"
.PHONY: install.debug
## Run go install with debug
install.debug:
@go install -a -gcflags "all=-N -l" main.go
## === Utils ===
## Show help text
help:
@awk '{ \
if ($$0 ~ /^.PHONY: [a-zA-Z\-\_0-9]+$$/) { \
helpCommand = substr($$0, index($$0, ":") + 2); \
if (helpMessage) { \
printf "\033[36m%-23s\033[0m %s\n", \
helpCommand, helpMessage; \
helpMessage = ""; \
} \
} else if ($$0 ~ /^[a-zA-Z\-\_0-9.]+:/) { \
helpCommand = substr($$0, 0, index($$0, ":")); \
if (helpMessage) { \
printf "\033[36m%-23s\033[0m %s\n", \
helpCommand, helpMessage"\n"; \
helpMessage = ""; \
} \
} else if ($$0 ~ /^##/) { \
if (helpMessage) { \
helpMessage = helpMessage"\n "substr($$0, 3); \
} else { \
helpMessage = substr($$0, 3); \
} \
} else { \
if (helpMessage) { \
print "\n "helpMessage"\n" \
} \
helpMessage = ""; \
} \
}' \
$(MAKEFILE_LIST)