-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
125 lines (102 loc) · 2.84 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
120
121
122
123
124
125
repository_root := $(shell git rev-parse --show-toplevel)
repository_root := $(or $(repository_root), $(CURDIR))
include $(repository_root)/variables.mk
GENENV_FILES ?= $(wildcard ./config/*)
GENENV_FILE ?= ./config/genenv.local.sh
COMPOSE_PROJECT_NAME ?= $(notdir $(CURDIR))
.PHONY: start
start: start/server
start/%: .env
$(MAKE) go/build/$*
source ./.env \
&& $(DOCKER_COMPOSE) \
-f ./docker-compose.$${PRISME_MODE}.yml \
up --wait
$(DOCKER_COMPOSE) \
-f ./docker-compose.dev.yml \
down
-source ./.env \
&& $(DOCKER_COMPOSE) \
-f ./docker-compose.dev.yml \
up --wait --force-recreate
$(DOCKER) logs -f $(COMPOSE_PROJECT_NAME)-prisme-1 |& bunyan
.PHONY: stop
stop:
$(DOCKER_COMPOSE) \
-f ./docker-compose.dev.yml \
-f ./docker-compose.default.yml \
-f ./docker-compose.ingestion.yml \
stop
.PHONY: down
down:
$(DOCKER_COMPOSE) \
-f ./docker-compose.dev.yml \
-f ./docker-compose.default.yml \
-f ./docker-compose.ingestion.yml \
down
.PHONY: clean
clean:
@touch .env
$(DOCKER_COMPOSE) \
-f ./docker-compose.dev.yml \
-f ./docker-compose.default.yml \
-f ./docker-compose.ingestion.yml \
down --volumes --remove-orphans
rm -f .env
watch/%:
# When a new file is added, you must rerun make watch/...
find '(' -regex '.*\.go$$' -or -regex '.*docker-compose.*' ')' \
-and -not -regex '.*_test.go' \
-and -not -regex '.*_gen.go' \
-and -not -regex '.*/tests/.*' | \
entr -n -r sh -c "$(MAKE) $*"
.PHONY: lint
lint: codegen
golangci-lint run --timeout 2m ./...
$(MAKE) -C ./tests lint
.PHONY: lint/fix
lint/fix:
$(MAKE) -C ./tests lint/fix
.PHONY: codegen
codegen: ./pkg/embedded/static/wa.js
wire ./...
go generate -skip="wire" ./...
./pkg/embedded/static/wa.js: ./tracker/web_analytics.js
minify --js-version 2019 $^ > $@
$(GENENV_FILE):
@echo "$(GENENV_FILE) doesn't exist, generating one..."
@printf '#!/usr/bin/env bash\n\nDIR="$$(dirname $$0)"\nsource "$$DIR/genenv.sh"\n\n# setenv PRISME_XXX_OPTION "value"' > $@
@chmod +x $(GENENV_FILE)
@echo "$(GENENV_FILE) generated, you can edit it!"
.env: $(GENENV_FILES) $(GENENV_FILE)
bash $(GENENV_FILE) > .env; \
.PHONY: test/unit
test/unit: codegen
go test -v -tags assert -short -race -bench=./... -benchmem ./...
.PHONY: test/integ
test/integ: .env
$(DOCKER_COMPOSE) \
-f ./docker-compose.default.yml \
up --wait
source ./.env && go test -race -v -p 1 -run TestInteg ./...
$(DOCKER_COMPOSE) \
-f ./docker-compose.default.yml \
down --volumes --remove-orphans
.PHONY: test/e2e
test/e2e:
$(MAKE) -C ./tests
tests/%: FORCE
$(MAKE) -C ./tests $*
.PHONY: go/build
go/build: go/build/server
go/build/%: FORCE codegen
go build -o prisme -race ./cmd/$*
.PHONY: nix/build
nix/build:
nix build -L .#default
.PHONY: docker/build
docker/build:
nix build -L .#docker
$(DOCKER) load < result
if [ "$${REMOVE_RESULT:=1}" = "1" ]; then rm -f result; fi
FORCE: