-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
61 lines (49 loc) · 1.92 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
-include .env
SPANNER_EMULATOR_GRPC_PORT ?= 9010
SPANNER_EMULATOR_REST_PORT ?= 9020
BIN_DIR := ./.bin
GORELEASER_VERSION = 1.15.1
WRENCH := $(abspath $(BIN_DIR)/wrench)
GORELEASER := $(abspath $(BIN_DIR)/goreleaser-$(GORELEASER_VERSION))
EMULATOR_SPANNER_PROJECT = xxx
EMULATOR_SPANNER_INSTANCE = splanter-test
EMULATOR_SPANNER_DATABASE = splanter-test
wrench: $(WRENCH)
$(WRENCH): $(TOOLS_SUM)
@cd tools && go build -o $(WRENCH) github.com/cloudspannerecosystem/wrench
goreleaser: $(GORELEASER)
$(GORELEASER):
@curl -sSL "https://github.com/goreleaser/goreleaser/releases/download/v$(GORELEASER_VERSION)/goreleaser_$(shell uname -s)_$(shell uname -m).tar.gz" | tar -C $(BIN_DIR) -xzv goreleaser
@mv ./$(BIN_DIR)/goreleaser $(GORELEASER)
.PHONY: test
test:
@SPANNER_PROJECT=${SPANNER_PROJECT} \
SPANNER_INSTANCE=${SPANNER_INSTANCE} \
SPANNER_DATABASE=${SPANNER_DATABASE} \
go test -race -shuffle=on ./...
.PHONY: test-docker
test-docker: $(WRENCH)
docker compose stop
docker compose up --detach
docker run --rm --network splanter_default jwilder/dockerize:0.6.1 -wait tcp://spanner:9010 -timeout 10s
SPANNER_EMULATOR_HOST=localhost:$(SPANNER_EMULATOR_GRPC_PORT) $(WRENCH) instance create \
--project=$(EMULATOR_SPANNER_PROJECT) \
--instance=$(EMULATOR_SPANNER_INSTANCE)
SPANNER_EMULATOR_HOST=localhost:$(SPANNER_EMULATOR_GRPC_PORT) $(WRENCH) create \
--project=$(EMULATOR_SPANNER_PROJECT) \
--instance=$(EMULATOR_SPANNER_INSTANCE) \
--database=$(EMULATOR_SPANNER_DATABASE) \
--directory ./internal/spanner/testdata
docker run \
--rm \
--volume "$(shell pwd):/src" \
--workdir /src \
--network splanter_default \
--env SPANNER_EMULATOR_HOST=spanner:9010 \
--env SPANNER_PROJECT=$(EMULATOR_SPANNER_PROJECT) \
--env SPANNER_INSTANCE=$(EMULATOR_SPANNER_INSTANCE) \
--env SPANNER_DATABASE=$(EMULATOR_SPANNER_DATABASE) \
golang:1.20.0-bullseye make test
.PHONY: release
release: $(GORELEASER)
$(GORELEASER) release