-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
104 lines (86 loc) · 2.45 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
VER=`cat VERSION`
# Build
build:
go build -o verbisexec -ldflags="-X 'github.com/verbiscms/verbis/api.ProductionString=false' -X 'github.com/verbiscms/verbis/api/version.Version=$(VER)'"
.PHONY: build
build-linux:
env GOOS=linux GOARCH=amd64 go build -o verbisexec-linux -ldflags="-X 'github.com/verbiscms/verbis/api.ProductionString=true' -X 'github.com/verbiscms/verbis/api/version.Version=$(VER)'"
.PHONY: build-linux
build-arm:
env GOOS=darwin GOARCH=arm64 go build -o verbisexec-arm -ldflags="-X 'github.com/verbiscms/verbis/api.ProductionString=true' -X 'github.com/verbiscms/verbis/api/version.Version=$(VER)'"
.PHONY: build-arm
# Set Verbis up when cloned.
setup:
go mod tidy
cd admin && npm install
cd admin && npm run build
.PHONY: setup
# Builds and serves
serve:
$(MAKE) build && ./verbisexec start
.PHONY: serve
# Builds Verbis for production
build-prod:
go build -o verbisexec -ldflags="-X 'github.com/verbiscms/verbis/api.ProductionString=true' -X 'github.com/verbiscms/verbis/api/version.Version=$(VER)'"
.PHONY: build-prod
# Creates and build dist folder
dist:
goreleaser release --rm-dist --snapshot
.PHONY: dist
# Echo the current versnion
version:
echo $(VER)
.PHONY: version
# Release verbis, expects commit message
release:
./bin/release.sh
.PHONY: release
# Run gofmt in ./api...
format:
go fmt ./api/...
.PHONY: format
# Test uses race and coverage
test:
go clean -testcache && go test -race $$(go list ./... | grep -v /api/mocks/ | grep -v /api/test) -coverprofile=coverage.out -covermode=atomic
.PHONY: test
# Test with -v
test-v:
go clean -testcache && go test -race -v $$(go list ./... | grep -v /api/mocks/ | grep -v /api/test) -coverprofile=coverage.out -covermode=atomic
.PHONY: test-v
# Run all the tests and opens the coverage report
cover: test
go tool cover -html=coverage.out
.PHONY: cover
# Github Actions
ci:
rm -rf admin/dist
mkdir admin/dist
touch admin/dist/.gitkeep
$(MAKE) format
$(MAKE) test
.PHONY: ci
# Make mocks keeping directory tree
mock:
cd api && rm -rf mocks && mockery --all --keeptree --exported=true && rm mocks/cache/providerAdder.go
.PHONY: mock
# Run linter
lint:
golangci-lint run ./api/...
.PHONY: lint
# Show to-do items per file.
todo:
@grep \
--exclude-dir=vendor \
--exclude-dir=node_modules \
--exclude=Makefile \
--exclude="*.map" \
--text \
--color \
-nRo -E ' TODO:.*|SkipNow' .
.PHONY: todo
# Make format, lint and test
all:
$(MAKE) format
$(MAKE) lint
$(MAKE) test
.PHONY: all