-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathMakefile
More file actions
75 lines (54 loc) · 2.04 KB
/
Copy pathMakefile
File metadata and controls
75 lines (54 loc) · 2.04 KB
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
.PHONY: clean docker-build test test-coverage test-bench mocks run run-cli dep lint air
all: test build/slack-bot build/cli
FLAGS = -trimpath -ldflags="-s -w -X github.com/innogames/slack-bot/v2/bot/version.Version=$(shell git describe --tags)"
# all packages of all go.work workspace modules: framework + cmd binaries + plugins
PKGS = github.com/innogames/slack-bot/v2/...
# all workspace modules, e.g. for per-module linting
MODULE_DIRS = . ./cmd/bot ./cmd/cli ./plugins/aws ./plugins/example ./plugins/ripeatlas
build/slack-bot: dep
@mkdir -p build/
go build $(FLAGS) -o build/slack-bot cmd/bot/main.go
build/cli: dep
@mkdir -p build/
go build $(FLAGS) -o build/cli cmd/cli/main.go
run: dep
go run -tags pprof $(FLAGS) cmd/bot/*.go
run-cli: dep
@test -f config.yaml || (echo "please create a config.yaml first. Hint: check the config.example.yaml" && exit 1)
go run $(FLAGS) cmd/cli/main.go -config config.yaml
run-cli-config:
go run cmd/cli/main.go -config config.yaml
clean:
rm -rf build/
# download go dependencies of all workspace modules into ./vendor/
dep:
@go work vendor
lint:
go fix $(PKGS)
@for dir in $(MODULE_DIRS); do \
echo "linting $$dir"; \
(cd $$dir && golangci-lint run --fix) || exit 1; \
done
docker-build:
docker build . --force-rm -t brainexe/slack-bot:latest
docker-push:
docker push brainexe/slack-bot:latest
test: dep
go test $(PKGS)
test-race: dep
go test $(PKGS) -race
test-bench:
go test -bench . $(PKGS) -benchmem
test-coverage: dep
@mkdir -p build
go test $(PKGS) -coverpkg=$(PKGS) -cover -coverprofile=./build/cover.out -covermode=atomic
go tool cover -html=./build/cover.out -o ./build/cover.html
@go tool cover -func ./build/cover.out | grep total | awk '{print "Total Coverage: " $$3 " see ./build/cover.html"}'
# build mocks for testable interfaces into ./mocks/ directory
mocks: dep
command -v mockery || go install github.com/vektra/mockery/v2@latest
go generate ./...
# live reload, see https://github.com/cosmtrek/air
run-live-reload:
command -v air || go install github.com/cosmtrek/air@latest
air