-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
108 lines (87 loc) · 2.38 KB
/
Makefile
File metadata and controls
108 lines (87 loc) · 2.38 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
97
98
99
100
101
102
103
104
105
106
107
108
# gomarks - simple bookmark manager
# See LICENSE file for copyright and license details.
PROJECT_NAME := gomarks
BINARY_NAME := gm
BIN_DIR := $(CURDIR)/bin
BIN_PATH := $(BIN_DIR)/$(BINARY_NAME)
INSTALL_DIR := /usr/local/bin
LDFLAGS := -s -w
FN ?= .
full: build
# Target to build everything
all: lint check test build
# Build the binary
build:
@echo '>> Building $(PROJECT_NAME)'
@go build -ldflags='$(LDFLAGS)' -o $(BIN_PATH) $(CURDIR)
@echo '>> Binary built at $(BIN_PATH)'
# Build the binary with debugger
debug: test
@echo '>> Building $(BINARY_NAME) with debugger'
@go build -gcflags='all=-N -l' -o $(BIN_PATH)-debug $(CURDIR)
# Run tests
test:
@echo '>> Testing $(BINARY_NAME)'
@go test ./...
@echo
testrace:
@echo '>> Testing $(BINARY_NAME)'
@go test ./... -race
@echo
testcover:
@echo '>> Testing $(BINARY_NAME)'
@go test ./... -coverprofile=coverage.out
@go tool cover -html=coverage.out -o coverage.html
@xdg-open coverage.html
# Run tests with gotestsum
testsum:
@echo '>> Testing $(BINARY_NAME)'
@gotestsum --format=pkgname-and-test-fails --hide-summary=skipped
# Run tests with verbose mode on
vtest:
@echo '>> Testing $(BINARY_NAME) (verbose)'
@go test -v ./...
# Run tests for a specific function
testfn:
@echo '>> Testing function $(FN)'
@go test -run $(FN) ./...
# Run tests for a specific function with verbose
vtestfn:
@echo '>> Testing function $(FN)'
@go test -v -run $(FN) ./...
# Benchmark code
bench:
@echo '>> Benchmark'
@go test -run='^$$' -bench=. ./... | grep -v "PASS" | grep -v "ok" | grep -v "?"
# Lint code with 'golangci-lint'
lint:
@echo '>> Linting code'
@go vet ./...
golangci-lint run ./...
# Lint code with 'golangci-lint' and 'codespell'
check:
@echo '>> Checking code with linters'
golangci-lint run -p bugs -p error
codespell .
# Clean binary directories
clean:
@echo '>> Cleaning bin'
rm -rf $(BIN_DIR)
# Clean caches
cleanall: clean
@echo '>> Cleaning cache'
go clean -cache
# Install the binary to the system
install:
mkdir -p $(INSTALL_DIR)
cp $(BIN_PATH) $(INSTALL_DIR)/$(BINARY_NAME)
chmod 755 $(INSTALL_DIR)/$(BINARY_NAME)
@echo '>> $(BINARY_NAME) has been installed on your device'
# Uninstall the binary from the system
uninstall:
rm -rf $(BIN_DIR)
rm -rf $(INSTALL_DIR)/$(BINARY_NAME)
@echo '>> $(BINARY_NAME) has been removed from your device'
tidy:
go mod tidy
.PHONY: all build debug test clean full check lint testfn