forked from interuss/dss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
158 lines (129 loc) · 6.12 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
GOPATH := $(shell go env GOPATH 2> /dev/null)
GOBIN := $(GOPATH)/bin
COMMIT := $(shell scripts/git/commit.sh)
# LAST_RELEASE_TAG determines the version of the DSS and is baked into
# the executable using linker flags. We gracefully ignore any tag that
# does not satisfy the naming pattern v*, thus supporting interleaving release
# and ordinary tags.
LAST_RELEASE_TAG := $(shell git describe --tags --abbrev=0 --match='v*' 2> /dev/null | grep -E 'v[0-9]+\.[0-9]+\.[0-9]+')
LAST_RELEASE_TAG := $(or $(LAST_RELEASE_TAG), v0.0.0)
GENERATOR_TAG := generator:$(LAST_RELEASE_TAG)
# Build and version information is baked into the executable itself.
BUILD_LDFLAGS := -X github.com/interuss/dss/pkg/build.time=$(shell date -u '+%Y-%m-%d.%H:%M:%S') -X github.com/interuss/dss/pkg/build.commit=$(COMMIT) -X github.com/interuss/dss/pkg/build.host=$(shell hostname)
VERSION_LDFLAGS := -X github.com/interuss/dss/pkg/version.tag=$(LAST_RELEASE_TAG) -X github.com/interuss/dss/pkg/version.commit=$(COMMIT)
LDFLAGS := $(BUILD_LDFLAGS) $(VERSION_LDFLAGS)
ifeq ($(OS),Windows_NT)
detected_OS := Windows
else
detected_OS := $(shell uname -s)
endif
.PHONY: interuss
interuss:
go install -ldflags "$(LDFLAGS)" ./cmds/...
go-mod-download: go.mod
go mod download
go.mod:
go mod tidy
.PHONY: format
format:
clang-format -style=file -i pkg/api/v1/ridpb/rid.proto
clang-format -style=file -i pkg/api/v1/scdpb/scd.proto
clang-format -style=file -i pkg/api/v1/auxpb/aux_service.proto
.PHONY: lint
lint:
docker run --rm -v $(CURDIR):/dss -w /dss golangci/golangci-lint:v1.26.0 golangci-lint run --timeout 5m -v -E gofmt,bodyclose,rowserrcheck,misspell,golint -D staticcheck,vet
docker run --rm -v $(CURDIR):/dss -w /dss golangci/golangci-lint:v1.26.0 golangci-lint run --timeout 5m -v --disable-all -E staticcheck --skip-dirs '^cmds/http-gateway,^pkg/logging'
find . -name '*.sh' | xargs docker run --rm -v $(CURDIR):/dss -w /dss koalaman/shellcheck
pkg/api/v1/ridpb/rid.pb.go: pkg/api/v1/ridpb/rid.proto generator
docker run -v$(CURDIR):/src:delegated -w /src $(GENERATOR_TAG) protoc \
-I/usr/include \
-I/src \
-I/go/src \
-I/go/pkg/mod/github.com/grpc-ecosystem/grpc-gateway@v1.14.3/third_party/googleapis \
--go_out=plugins=grpc:. $<
pkg/api/v1/ridpb/rid.pb.gw.go: pkg/api/v1/ridpb/rid.proto pkg/api/v1/ridpb/rid.pb.go generator
docker run -v$(CURDIR):/src:delegated -w /src $(GENERATOR_TAG) protoc \
-I/usr/include \
-I. \
-I/go/src \
-I/go/pkg/mod/github.com/grpc-ecosystem/grpc-gateway@v1.14.3/third_party/googleapis \
--grpc-gateway_out=logtostderr=true,allow_delete_body=true:. $<
pkg/api/v1/ridpb/rid.proto: generator
docker run -v$(CURDIR):/src:delegated -w /src $(GENERATOR_TAG) openapi2proto \
-spec interfaces/uastech/standards/remoteid/augmented.yaml -annotate \
-tag dss \
-indent 2 \
-package ridpb > $@
pkg/api/v1/auxpb/aux_service.pb.go: pkg/api/v1/auxpb/aux_service.proto generator
docker run -v$(CURDIR):/src:delegated -w /src $(GENERATOR_TAG) protoc \
-I/usr/include \
-I. \
-I/go/src \
-I/go/pkg/mod/github.com/grpc-ecosystem/grpc-gateway@v1.14.3/third_party/googleapis \
--go_out=plugins=grpc:. $<
pkg/api/v1/auxpb/aux_service.pb.gw.go: pkg/api/v1/auxpb/aux_service.proto pkg/api/v1/auxpb/aux_service.pb.go generator
docker run -v$(CURDIR):/src:delegated -w /src $(GENERATOR_TAG) protoc \
-I/usr/include \
-I. \
-I/go/src \
-I/go/pkg/mod/github.com/grpc-ecosystem/grpc-gateway@v1.14.3/third_party/googleapis \
--grpc-gateway_out=logtostderr=true,allow_delete_body=true:. $<
pkg/api/v1/scdpb/scd.pb.go: pkg/api/v1/scdpb/scd.proto generator
docker run -v$(CURDIR):/src:delegated -w /src $(GENERATOR_TAG) protoc \
-I/usr/include \
-I. \
-I/go/src \
-I/go/pkg/mod/github.com/grpc-ecosystem/grpc-gateway@v1.14.3/third_party/googleapis \
--go_out=plugins=grpc:. $<
pkg/api/v1/scdpb/scd.pb.gw.go: pkg/api/v1/scdpb/scd.proto pkg/api/v1/scdpb/scd.pb.go generator
docker run -v$(CURDIR):/src:delegated -w /src $(GENERATOR_TAG) protoc \
-I/usr/include \
-I. \
-I/go/src \
-I/go/pkg/mod/github.com/grpc-ecosystem/grpc-gateway@v1.14.3/third_party/googleapis \
--grpc-gateway_out=logtostderr=true,allow_delete_body=true:. $<
interfaces/scd_adjusted.yaml: interfaces/astm-utm/Protocol/utm.yaml
./interfaces/adjuster/adjust_openapi_yaml.sh ./interfaces/astm-utm/Protocol/utm.yaml ./interfaces/scd_adjusted.yaml
pkg/api/v1/scdpb/scd.proto: interfaces/scd_adjusted.yaml generator
docker run -v$(CURDIR):/src:delegated -w /src $(GENERATOR_TAG) openapi2proto \
-spec interfaces/scd_adjusted.yaml -annotate \
-tag dss \
-indent 2 \
-package scdpb > $@
generator:
docker build --rm -t $(GENERATOR_TAG) build/generator
.PHONY: protos
protos: pkg/api/v1/auxpb/aux_service.pb.gw.go pkg/api/v1/ridpb/rid.pb.gw.go pkg/api/v1/scdpb/scd.pb.gw.go
.PHONY: install-staticcheck
install-staticcheck:
go get honnef.co/go/tools/cmd/staticcheck
.PHONY: staticcheck
staticcheck: install-staticcheck
staticcheck -go 1.12 ./...
.PHONY: test
test:
go test -ldflags "$(LDFLAGS)" -count=1 -v ./pkg/... ./cmds/...
.PHONY: test-cockroach
test-cockroach: cleanup-test-cockroach
@docker run -d --name dss-crdb-for-testing -p 26257:26257 -p 8080:8080 cockroachdb/cockroach:v20.1.1 start --insecure > /dev/null
go run ./cmds/db-manager/main.go --schemas_dir ./build/deploy/db_schemas/defaultdb --db_version latest --cockroach_host localhost
go test -count=1 -v ./pkg/rid/store/cockroach -store-uri "postgresql://root@localhost:26257?sslmode=disable"
go test -count=1 -v ./pkg/scd/store/cockroach -store-uri "postgresql://root@localhost:26257?sslmode=disable"
go test -count=1 -v ./pkg/rid/application -store-uri "postgresql://root@localhost:26257?sslmode=disable"
@docker stop dss-crdb-for-testing > /dev/null
@docker rm dss-crdb-for-testing > /dev/null
.PHONY: cleanup-test-cockroach
cleanup-test-cockroach:
@docker stop dss-crdb-for-testing > /dev/null 2>&1 || true
@docker rm dss-crdb-for-testing > /dev/null 2>&1 || true
.PHONY: test-e2e
test-e2e:
test/docker_e2e.sh
release: VERSION = v$(MAJOR).$(MINOR).$(PATCH)
release:
scripts/release.sh $(VERSION)
start-locally:
build/dev/run_locally.sh build
build/dev/run_locally.sh up
stop-locally:
build/dev/run_locally.sh stop