forked from LinuxSuRen/api-testing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
151 lines (144 loc) · 5.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
IMG_TOOL?=docker
BINARY?=atest
TOOLEXEC?= #-toolexec="skywalking-go-agent"
BUILD_FLAG?=-ldflags "-w -s -X github.com/linuxsuren/api-testing/pkg/version.version=$(shell git describe --tags) \
-X github.com/linuxsuren/api-testing/pkg/version.date=$(shell date +%Y-%m-%d)"
GOPROXY?=direct
HELM_VERSION?=v0.0.3
APP_VERSION?=v0.0.13
HELM_REPO?=docker.io/linuxsuren
fmt:
go mod tidy
go fmt ./...
build:
mkdir -p bin
rm -rf bin/atest
CGO_ENABLED=0 go build ${TOOLEXEC} -a ${BUILD_FLAG} -o bin/${BINARY} main.go
build-ui:
cd console/atest-ui && npm i && npm run build-only
embed-ui:
cd console/atest-ui && npm i && npm run build-only
cp console/atest-ui/dist/index.html cmd/data/index.html
cp console/atest-ui/dist/assets/*.js cmd/data/index.js
cp console/atest-ui/dist/assets/*.css cmd/data/index.css
clean-embed-ui:
git checkout cmd/data/index.html
git checkout cmd/data/index.js
git checkout cmd/data/index.css
build-embed-ui: embed-ui
GOOS=${OS} go build ${TOOLEXEC} -a -ldflags "-w -s -X github.com/linuxsuren/api-testing/pkg/version.version=$(shell git rev-parse --short HEAD)" -o bin/${BINARY} main.go
make clean-embed-ui
build-darwin:
BINARY=atest_darwin GOOS=darwin make build
build-win:
BINARY=atest.exe GOOS=windows make build
build-win-embed-ui:
BINARY=atest.exe GOOS=windows make build-embed-ui
goreleaser:
goreleaser build --rm-dist --snapshot
make clean-embed-ui
build-image:
${IMG_TOOL} build -t ghcr.io/linuxsuren/api-testing:master . \
--build-arg GOPROXY=${GOPROXY} \
--build-arg VERSION=$(shell git describe --abbrev=0 --tags)-$(shell git rev-parse --short HEAD)
run-image:
docker run -p 7070:7070 -p 8080:8080 ghcr.io/linuxsuren/api-testing:master
run-server: build-ui
go run . server --local-storage 'bin/*.yaml' --console-path console/atest-ui/dist
run-console:
cd console/atest-ui && npm run dev
copy:
sudo cp bin/atest /usr/local/bin/
copy-restart: build-embed-ui
atest service stop
make copy
atest service restart
# helm
helm-dev-update:
helm dep update helm/api-testing
helm-package: helm-dev-update
helm package helm/api-testing --version ${HELM_VERSION}-helm --app-version ${APP_VERSION} -d bin
helm-push:
helm push bin/api-testing-${HELM_VERSION}-helm.tgz oci://${HELM_REPO}
helm-lint: helm-dev-update
helm lint helm/api-testing
test:
go test ./... -cover -v -coverprofile=coverage.out
go tool cover -func=coverage.out
testlong:
go test pkg/limit/limiter_long_test.go -v
test-ui:
cd console/atest-ui && npm run test:unit
test-ui-e2e:
cd console/atest-ui && npm i && npm run test:e2e
test-operator:
cd operator && make test # converage file path: operator/cover.out
test-all-backend: test
test-all: test-all-backend test-ui
test-e2e:
cd e2e && ./start.sh && ./start.sh compose-k8s.yaml && ./start.sh compose-external.yaml
fuzz:
cd pkg/util && go test -fuzz FuzzZeroThenDefault -fuzztime 6s
install-precheck:
cp .github/pre-commit .git/hooks/pre-commit
grpc:
protoc --proto_path=. \
--go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
pkg/server/server.proto \
pkg/testing/remote/loader.proto \
pkg/runner/monitor/monitor.proto
grpc-gw:
protoc -I . --grpc-gateway_out . \
--grpc-gateway_opt logtostderr=true \
--grpc-gateway_opt paths=source_relative \
--grpc-gateway_opt generate_unbound_methods=true \
--openapiv2_out . \
--openapiv2_opt logtostderr=true \
--openapiv2_opt generate_unbound_methods=true \
pkg/server/server.proto
grpc-java:
protoc --plugin=protoc-gen-grpc-java \
--grpc-java_out=bin --proto_path=. \
pkg/server/server.proto \
pkg/testing/remote/loader.proto
grpc-js:
protoc -I=pkg/server server.proto \
--js_out=import_style=commonjs:bin \
--grpc-web_out=import_style=commonjs,mode=grpcwebtext:bin
# https://github.com/grpc/grpc-web
grpc-ts:
protoc -I=pkg/server server.proto \
--js_out=import_style=commonjs,binary:console/atest-ui/src \
--grpc-web_out=import_style=typescript,mode=grpcwebtext:console/atest-ui/src
# grpc-java:
# protoc --plugin=protoc-gen-grpc-java=/usr/local/bin/protoc-gen-grpc-java \
# --grpc-java_out=bin --proto_path=pkg/server server.proto
grpc-decs:
protoc --proto_path=. \
--descriptor_set_out=.github/testing/server.pb \
pkg/server/server.proto
grpc-testproto:
protoc -I . \
--descriptor_set_out=pkg/runner/grpc_test/test.pb \
pkg/runner/grpc_test/test.proto
protoc -I . \
--go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
pkg/runner/grpc_test/test.proto
hd:
curl https://linuxsuren.github.io/tools/install.sh|bash
install-tool: hd
go install google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]
hd i protoc-gen-grpc-web
hd i protoc-gen-grpc-gateway
hd get protocolbuffers/[email protected] -o protobuf.zip
unzip protobuf.zip bin/protoc
rm -rf protobuf.zip
sudo install bin/protoc /usr/local/bin/
sudo hd get https://github.com/grpc-ecosystem/grpc-gateway/releases/download/v2.18.1/protoc-gen-openapiv2-v2.18.1-linux-x86_64 -o /usr/local/bin/protoc-gen-openapiv2
sudo chmod +x /usr/local/bin/protoc-gen-openapiv2
init-env: hd
hd i cli/cli
gh extension install linuxsuren/gh-dev