-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
130 lines (100 loc) · 2.74 KB
/
Makefile
File metadata and controls
130 lines (100 loc) · 2.74 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
repository_root := $(shell git rev-parse --show-toplevel)
repository_root := $(or $(repository_root), $(CURDIR))
include $(repository_root)/variables.mk
CONFIG_FILES ?= $(wildcard ./config/*.ini)
CONFIG_FILE ?= ./config/dev.ini
COMPOSE_PROJECT_NAME ?= $(notdir $(CURDIR))
GO ?= go
default: start/prisme
.PHONY: start
start:
$(DOCKER_COMPOSE) \
-f ./docker-compose.yml \
up --wait \
.PHONY: start/prisme
start/prisme: start tmp/prisme
PRISME_CONFIG=$(CONFIG_FILE) air --build.cmd '$(MAKE) tmp/prisme' --build.bin './tmp/prisme' \
|& bunyan
.PHONY: start/addevents
start/addevents:
$(DOCKER_COMPOSE) \
-f ./docker-compose.yml \
up --wait \
&& $(GO) run -tags test ./cmd/addevents $(ARGS) |& bunyan
.PHONY: stop
stop:
$(DOCKER_COMPOSE) \
-f ./docker-compose.yml \
stop
.PHONY: down
down:
$(DOCKER_COMPOSE) \
-f ./docker-compose.yml \
down
.PHONY: clean
clean:
-$(DOCKER_COMPOSE) \
-f ./docker-compose.yml \
down --volumes --remove-orphans
rm -rf tmp/
.PHONY: lint
lint: codegen
openapi-spec-validator openapi.yml
golangci-lint run --allow-parallel-runners --timeout 2m ./...
$(MAKE) -C ./tests lint
$(MAKE) -C ./front lint
.PHONY: lint/fix
lint/fix:
go fmt ./...
$(MAKE) -C ./tests lint/fix
$(MAKE) -C ./front lint/fix
.PHONY: codegen
codegen: ./pkg/embedded/static/wa.js ./pkg/embedded/static/openapi.json ./pkg/embedded/dashboard
.PHONY: ./pkg/embedded/dashboard
./pkg/embedded/dashboard:
mkdir -p $@
$(MAKE) -C front DIST_DIR="../$@" build
./pkg/embedded/static/openapi.json: ./openapi.yml
yq < $^ > $@
./pkg/embedded/static/wa.js: ./tracker/web_analytics.js
minify --js-version 2019 $^ > $@
$(CONFIG_FILE): ./config/example.ini
@echo "$(CONFIG_FILE) doesn't exist, generating one..."
@cp ./config/example.ini $@
@chmod +x $(CONFIG_FILE)
@echo "$(CONFIG_FILE) generated, you can edit it!"
tmp/prisme: go/build/prisme
tmp/:
mkdir -p tmp/
.PHONY: test/unit
test/unit: codegen
go test -v -tags assert,test -short -race -bench=./... -benchmem ./...
.PHONY: test/integ
test/integ: start $(CONFIG_FILE)
go test -tags chdb,test -v -race -p 1 -run TestInteg ./...
go test -tags chdb,test -v -p 1 -run TestIntegNoRaceDetector ./...
$(MAKE) clean
.PHONY: test/e2e
test/e2e:
$(MAKE) -C ./tests
tests/%: FORCE
$(MAKE) -C ./tests $*
.PHONY: phony/integ
bench/integ:
go test -tags chdb,test -v -p 1 -run ^$$ -bench=BenchmarkInteg -benchtime 10s ./...
.PHONY: go/build
go/build: go/build/prisme
go/build/%: FORCE codegen
$(GO) build -o ./tmp/$* -race ./cmd/$*
.PHONY: nix/build
nix/build:
nix build -L .#default
.PHONY: docker/build
docker/build: docker/build/prisme
@true
.PHONY: docker/build/prisme
docker/build/prisme:
nix build -L .#docker
$(DOCKER) load < result
if [ "$${REMOVE_RESULT:=1}" = "1" ]; then rm -f result; fi
FORCE: