-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMakefile
More file actions
96 lines (73 loc) · 4.22 KB
/
Copy pathMakefile
File metadata and controls
96 lines (73 loc) · 4.22 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
SHELL = /bin/sh
# --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# --- Setup ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
.PHONY: install-lefthook install-golangci-lint
install-lefthook:
(command -v lefthook || go install github.com/evilmartians/lefthook@latest) && lefthook install
install-golangci-lint:
command -v golangci-lint || go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.4.0
# --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# --- Go (Golang) ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
.PHONY: go-mod-clean go-mod-tidy go-mod-update go-fmt go-lint go-test go-build go-install
go-mod-clean:
go clean -modcache
go-mod-tidy:
go mod tidy
go-mod-update:
go get -f -t -u ./...
go get -f -u ./...
go-fmt: install-golangci-lint
golangci-lint fmt ./...
go-lint: go-fmt
golangci-lint run ./...
go-test:
go test -v -race ./...
go-build:
go build -v -ldflags '-s -w' -o bin/xcrawl3r cmd/xcrawl3r/main.go
go-install:
go install -v ./...
# --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# --- Docker ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
DOCKERFILE := ./Dockerfile
IMAGE_NAME = hueristiq/xcrawl3r
IMAGE_TAG = $(shell cat internal/configuration/configuration.go | grep "VERSION =" | sed 's/.*VERSION = "\([0-9.]*\)".*/\1/')
IMAGE = $(IMAGE_NAME):$(IMAGE_TAG)
.PHONY: docker-build
docker-build:
docker build -f $(DOCKERFILE) -t $(IMAGE) -t $(IMAGE_NAME):latest .
# --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# --- Help -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
.PHONY: help
help:
@echo ""
@echo "Available commands:"
@echo ""
@echo " Setup:"
@echo ""
@echo " install-lefthook ......... Install lefthook."
@echo " install-golangci-lint .... Install golangci-lint."
@echo ""
@echo " Go (Golang):"
@echo ""
@echo " go-mod-clean ............. Clean Go module cache."
@echo " go-mod-tidy .............. Tidy Go modules."
@echo " go-mod-update ............ Update Go modules."
@echo " go-fmt ................... Format Go code."
@echo " go-lint .................. Lint Go code."
@echo " go-test .................. Run Go tests."
@echo " go-build ................. Build Go program."
@echo " go-install ............... Install Go program."
@echo ""
@echo " Docker:"
@echo ""
@echo " docker-build ............. Build Docker image."
@echo ""
@echo " Help:"
@echo ""
@echo " help ..................... Display this help information."
@echo ""
.DEFAULT_GOAL = help