-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
79 lines (66 loc) · 2.45 KB
/
Makefile
File metadata and controls
79 lines (66 loc) · 2.45 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
# Some necessary variables
TESTS=$$(go list ./... | grep -v /vendor/ | grep -v /tests | sort)
SRC=$(shell find . -type f -name '*.go' -not -path "./vendor/*")
# Application main and final binary locations
APP=cmd/gonsul.go
APP_BINARY=bin/gonsul
# These are the values we want to pass for VERSION
VERSION=Stockbroking-CMC-Gonsul-$(SEMANTIC_VERSION)
BUILD_DATE=$(shell date -u +%Y-%m-%d.%H%M%S)
# Setup the -ldflags option for go build here, interpolate the variable values
LDFLAGS_APP=-ldflags "-X github.com/miniclip/gonsul/app.Version=${VERSION} -X github.com/miniclip/gonsul/app.BuildDate=${BUILD_DATE}"
# Builds the application defaulting to the host operating system
build:
@echo "=== Building SRV ==="
go build ${LDFLAGS_APP} -a -installsuffix cgo -o ${APP_BINARY} ${APP}
@echo "=== Done ==="
# Builds the application for Linux
build-linux:
@echo "=== Building SRV for Linux ==="
GOOS=linux GOARCH=amd64 go build ${LDFLAGS_APP} -o ${APP_BINARY} ${APP}
@echo "=== Done ==="
# Builds the application for Windows 64-bit
build-windows:
@echo "=== Building SRV for Windows 64-bit ==="
GOOS=windows GOARCH=amd64 go build ${LDFLAGS_APP} -o ${APP_BINARY}.exe ${APP}
@echo "=== Done ==="
# Default target
default: build
# Target to build for both Linux and Windows
all: build-linux build-windows
# Generates the needed mocks
GOPATH?=${HOME}/go
mocks:
@echo "=== Generating mocks ==="
rm -rf ./tests/mocks/*.go
go install github.com/vektra/mockery/v2@latest
CGO_ENABLED=0 $(GOPATH)/bin/mockery --all --output ./tests/mocks --dir ./app/
CGO_ENABLED=0 $(GOPATH)/bin/mockery --all --output ./tests/mocks --dir ./internal/
@echo "=== Done ==="
# Validates the correct format of the code
fmt:
@echo "=== Validating code compliance ==="
gofmt -l -e ${SRC}
@echo "=== Done ==="
# Runs our unit tests
test: mocks fmt
@echo "=== Running tests ==="
go test ${TESTS}
@echo "=== Done ==="
# Launches our environment
env:
@echo "=== Running Environment ==="
docker-compose up
# Lint our root folder Markdown files
MARKDOWNLINT := $(shell command -v markdownlint 2> /dev/null)
markdownlint:
ifdef MARKDOWNLINT
@for FILE in CONTRIBUTING.md LICENCE.md README.md ; do \
if test -f $$FILE ; then \
$(MARKDOWNLINT) -c markdownlint.config $$FILE ; \
fi \
done
else
@echo "Not executing Markdown linting: 'markdownlint' (https://github.com/DavidAnson/markdownlint) not available"
endif
.PHONY: markdownlint