-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathMakefile
102 lines (75 loc) · 2.5 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
# Variables
TAILWIND_INPUT := modules/core/presentation/assets/css/main.css
TAILWIND_OUTPUT := modules/core/presentation/assets/css/main.min.css
# Install dependencies
deps:
go get ./...
# Seed database
seed:
go run cmd/seed/main.go
generate:
go generate ./... && templ generate
# Run tests
test:
go test -v ./... -coverprofile=./coverage/coverage.out
# Run tests with file watching
test-watch:
gow test -v ./...
# Generate dependency graph
graph:
goda graph ./modules/... | dot -Tpng -o dependencies.png
# Run tests inside docker
test-docker:
docker compose -f compose.testing.yml up --build erp_local
coverage-score:
go tool cover -func ./coverage/coverage.out | grep "total:" | awk '{print ((int($$3) > 80) != 1) }'
report:
go tool cover -html=coverage.out -o ./coverage/cover.html
# Run PostgreSQL
localdb:
docker compose -f compose.dev.yml up
clear-localdb:
rm -rf postgres-data/
reset-localdb:
docker compose -f compose.dev.yml down
make clear-localdb
make localdb
migrate:
go run cmd/migrate/main.go $(filter-out $@,$(MAKECMDGOALS))
# Compile TailwindCSS (with watch)
css-watch:
tailwindcss -c tailwind.config.js -i $(TAILWIND_INPUT) -o $(TAILWIND_OUTPUT) --minify --watch
# Compile TailwindCSS (without watch)
css:
tailwindcss -c tailwind.config.js -i $(TAILWIND_INPUT) -o $(TAILWIND_OUTPUT) --minify
# Run linter
lint:
golangci-lint run ./...
# Release - assume Alpine Linux as target
release:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o /build/run_server cmd/server/main.go
# Release - assume local OS as target
release-local:
go build -ldflags="-s -w" -o run_server cmd/server/main.go
# Clean build artifacts
clean:
rm -rf $(TAILWIND_OUTPUT)
## Linter targets
#.PHONY: build-iota-linter run-iota-linter clean-iota-linter
# Build the JSON linter
build-iota-linter:
go build -o bin/iotalinter tools/iotalinter.go
# Run the JSON linter
run-iota-linter:
./bin/iotalinter ./...
# Clean built binaries
clean-iota-linter:
rm -f bin/iotalinter
build-docker-base:
docker buildx build --push --platform linux/amd64,linux/arm64 -t iotauz/sdk:base-$v --target base .
build-docker-prod:
docker buildx build --push --platform linux/amd64,linux/arm64 -t iotauz/sdk:$v --target production .
# Prevents make from treating the argument as an undefined target
%:
@:
.PHONY: default deps test test-watch localdb clear-localdb reset-localdb migrate-up migrate-down dev css-watch css lint release release-local clean setup build-iota-linter run-iota-linter clean-iota-linter collect-migrations