-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
119 lines (103 loc) · 3.71 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Makefile for Golang Project
# Project Variables
PROJECT_NAME := myproject
GO := go
GOFMT := gofmt -s
GOFILES := $(shell find . -name "*.go" -type f)
GOTEST := $(GO) test
GOBENCH := $(GO) test -run=^$$ -bench .
GOLANGCI_LINT_VERSION := v1.55.1
GOLANGCI_LINT_FILE := bin/golangci-lint
GOLANGCI_LINT_VERSIONED := $(GOLANGCI_LINT_FILE)-$(GOLANGCI_LINT_VERSION)
GOLINT := $(GOLANGCI_LINT_VERSIONED) run
# Phony Targets
.PHONY: help build test bench lint fmt tidy setup clean
# Help
help:
@echo "Choose a command to run in $(PROJECT_NAME):"
@echo " build"
@echo " Compile the project into a binary."
@echo " test"
@echo " Run tests on a compiled project. This includes different levels of tests for various components."
@echo " bench"
@echo " Run benchmarks on a compiled project. This includes benchmarks for concurrency and pattern components."
@echo " lint"
@echo " Run linters on the project using a specific version of golangci-lint."
@echo " fmt"
@echo " Format the Go source files."
@echo " tidy"
@echo " Remove unused dependencies from the project."
@echo " setup"
@echo " Set up the necessary tools for linting."
@echo " clean"
@echo " Remove temporary files and compiled binaries."
@echo " fixme-basic"
@echo " Run basic tests for the 'fixme' challenge."
@echo " fixme-intermediate"
@echo " Run intermediate tests for the 'fixme' challenge."
@echo " fixme-advanced"
@echo " Run advanced tests for the 'fixme' challenge."
@echo " implme-basic"
@echo " Run basic tests and benchmarks for the 'implme' basic challenge."
@echo " implme-intermediate"
@echo " Run intermediate tests for the 'implme' intermediate challenge."
@echo " implme-advanced"
@echo " Run advanced tests for the 'implme' advanced challenge."
# Test Targets for different components
test:
@echo "Testing concurrency components..."
@$(GOTEST) ./internal/concurrency/...
@echo "Testing pattern components..."
@$(GOTEST) ./internal/pattern/...
# Test Targets for different components
fixme-basic:
@echo "Running basic tests..."
@$(GOTEST) -v -run=^TestBasic ./internal/challenge/fixme/...
# Test Targets for different components
fixme-intermediate:
@echo "Running intermediate tests..."
@$(GOTEST) -v -run=^TestIntermediate ./internal/challenge/fixme/...
# Test Targets for different components
fixme-advanced:
@echo "Running advanced tests..."
@$(GOTEST) -v -run=^TestAdvanced ./internal/challenge/fixme/...
# Test Targets for different components
implme-basic:
@echo "Running basic tests..."
@$(GOTEST) -v ./internal/challenge/implme/basic...
@echo "Running basic benchmarks..."
@$(GOBENCH) ./internal/challenge/implme/basic...
# Test Targets for different components
implme-intermediate:
@echo "Running intermediate tests..."
@$(GOTEST) -v ./internal/challenge/implme/intermediate...
# Test Targets for different components
implme-advanced:
@echo "Running advanced tests..."
@$(GOTEST) -v ./internal/challenge/implme/advanced...
# Benchmark Targets for different components
bench:
@echo "Benchmarking concurrency components..."
@$(GOBENCH) ./internal/concurrency/...
@echo "Benchmarking pattern components..."
@$(GOBENCH) ./internal/pattern/...
# Linting
lint: $(GOLANGCI_LINT_VERSIONED)
@echo "Linting the code..."
@$(GOLINT)
# Go mod tidy
tidy:
@echo "Tidying up the go.mod and go.sum files..."
@$(GO) mod tidy
# Setup
$(GOLANGCI_LINT_VERSIONED):
@echo "Setting up..."
@mkdir -p bin
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./bin $(GOLANGCI_LINT_VERSION)
@mv $(GOLANGCI_LINT_FILE) $(GOLANGCI_LINT_VERSIONED)
# Cleaning up
clean:
@echo "Cleaning up..."
@rm -f $(PROJECT_NAME)
@rm -f $(GOLANGCI_LINT_VERSIONED)
@rm -f coverage.out