-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
114 lines (95 loc) · 3.3 KB
/
Makefile
File metadata and controls
114 lines (95 loc) · 3.3 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
109
110
111
112
113
114
.PHONY: dev run build build-cli test tidy deps-upgrade deps-clean-cache lint race bench cover tree fmt fmt-check clean
LOG_DIR := logs
BIN_NAME := timefy
BIN_DIR := bin
# Detect OS for binary extension
ifeq ($(OS),Windows_NT)
BIN_EXT := .exe
else
BIN_EXT :=
endif
BIN_OUT := $(BIN_DIR)/$(BIN_NAME)$(BIN_EXT)
# ==============================================================================
# Development
# Prints CLI help output for quick reference during development.
# ==============================================================================
dev:
go run ./main/main.go
# ==============================================================================
# Running the main application
# Executes cmd/archflow/main.go, useful for development and quick testing.
run:
go run ./cmd/timefy
# ==============================================================================
# Building the application
# Compiles cmd/archflow into a binary at bin/archflow (or bin/archflow.exe on Windows).
build:
@mkdir -p $(BIN_DIR)
go build -o $(BIN_OUT) ./cmd/timefy
# Same as build, explicitly for the CLI binary.
build-cli:
@mkdir -p $(BIN_DIR)
go build -o $(BIN_OUT) ./cmd/timefy
# ==============================================================================
# Module support and testing
# Runs tests across all packages in the project, showing code coverage.
test:
go test -cover ./...
# Cleans up the module by removing unused dependencies, then re-vendors.
tidy:
go mod tidy
go mod vendor
# ==============================================================================
# Upgrading dependencies
# Updates all direct dependencies to their latest minor/patch versions,
# then re-tidies and re-vendors.
deps-upgrade:
go get -u -t -d -v ./...
go mod tidy
go mod vendor
# Removes all items from the Go module cache.
deps-clean-cache:
go clean -modcache
# ==============================================================================
# Quality
# Runs go vet across all packages.
lint:
go vet ./...
# Runs all tests with the race detector enabled.
race:
go test -race -count=1 ./...
# Runs all benchmarks with memory allocation reporting.
bench:
go test -bench=. -benchmem ./...
# Generates an HTML coverage report at coverage.html.
cover:
@mkdir -p $(LOG_DIR)
go test -coverprofile=./$(LOG_DIR)/coverage.out ./...
go tool cover -html=./$(LOG_DIR)/coverage.out -o ./$(LOG_DIR)/coverage.html
# ==============================================================================
# Formatting
# Formats all Go source files in-place using gofmt.
fmt:
go fmt ./...
# Checks whether all Go source files are properly formatted.
# Exits with a non-zero status if any files need formatting.
fmt-check:
@unformatted=$$(gofmt -l .); \
if [ -n "$$unformatted" ]; then \
echo "The following files are not formatted:"; \
echo "$$unformatted"; \
exit 1; \
fi
# ==============================================================================
# Utilities
# Creates a text file representing the project's directory structure.
tree:
@mkdir -p $(LOG_DIR)
tree -I ".gradle|.idea|build|logs|.vscode|.git|.github|vendor" > ./$(LOG_DIR)/tree_source_oss.txt
cat ./$(LOG_DIR)/tree_source_oss.txt
# ==============================================================================
# Clean
# Removes the build directory and log directory.
clean:
rm -rf $(BIN_DIR)
rm -rf $(LOG_DIR)