2023-11-14 17:10:30 +08:00
IMG_TOOL ?= docker
2023-08-22 08:58:42 +08:00
BINARY ?= atest
2023-11-14 17:10:30 +08:00
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
2023-10-19 17:36:44 +08:00
HELM_VERSION ?= v0.0.2
2023-10-13 17:41:48 +08:00
APP_VERSION ?= v0.0.13
2023-10-25 16:58:17 +08:00
HELM_REPO ?= docker.io/linuxsuren
2023-07-10 17:03:55 +08:00
2023-11-12 07:31:15 +08:00
fmt :
2023-11-18 13:58:34 +08:00
go mod tidy
2023-11-12 07:31:15 +08:00
go fmt ./...
2023-11-14 17:10:30 +08:00
cd extensions/store-etcd && go mod tidy && go fmt ./...
cd extensions/store-git && go mod tidy && go fmt ./...
cd extensions/store-orm && go mod tidy && go fmt ./...
cd extensions/store-s3 && go mod tidy && go fmt ./...
2023-11-18 13:58:34 +08:00
cd extensions/store-mongodb && go mod tidy && go fmt ./...
2022-06-08 19:04:47 +08:00
build :
mkdir -p bin
2023-03-08 17:32:53 +08:00
rm -rf bin/atest
2023-11-17 14:13:04 +08:00
CGO_ENABLED = 0 go build ${ TOOLEXEC } -a ${ BUILD_FLAG } -o bin/${ BINARY } main.go
2023-12-01 15:37:01 +08:00
build-ext : build -ext -git build -ext -orm build -ext -s 3 build -ext -etcd build -ext -mongodb build -ext -monitor -docker
2023-09-11 09:11:44 +08:00
build-ext-git :
CGO_ENABLED = 0 go build -ldflags "-w -s" -o bin/atest-store-git extensions/store-git/main.go
2023-10-23 15:59:22 +08:00
build-ext-orm :
CGO_ENABLED = 0 go build -ldflags "-w -s" -o bin/atest-store-orm extensions/store-orm/main.go
2023-11-08 15:30:25 +08:00
build-ext-etcd :
CGO_ENABLED = 0 go build -ldflags "-w -s" -o bin/atest-store-etcd extensions/store-etcd/main.go
build-ext-s3 :
CGO_ENABLED = 0 go build -ldflags "-w -s" -o bin/atest-store-s3 extensions/store-s3/main.go
2023-11-18 13:58:34 +08:00
build-ext-mongodb :
CGO_ENABLED = 0 go build -ldflags "-w -s" -o bin/atest-store-mongodb extensions/store-mongodb/main.go
2023-12-01 15:37:01 +08:00
build-ext-monitor-docker :
CGO_ENABLED = 0 go build -ldflags "-w -s" -o bin/atest-monitor-docker extensions/monitor-docker/main.go
2023-11-12 07:31:15 +08:00
build-ui :
cd console/atest-ui && npm i && npm run build-only
2023-08-22 09:46:42 +08:00
embed-ui :
2023-07-07 08:21:53 +08:00
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
2023-08-22 09:46:42 +08:00
clean-embed-ui :
2023-08-26 13:35:31 +08:00
git checkout cmd/data/index.html
git checkout cmd/data/index.js
git checkout cmd/data/index.css
2023-08-22 09:46:42 +08:00
build-embed-ui : embed -ui
2023-09-26 07:29:10 +08:00
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
2023-08-22 09:46:42 +08:00
make clean-embed-ui
2023-11-14 18:05:13 +08:00
build-darwin :
BINARY = atest_darwin GOOS = darwin make build
build-win :
BINARY = atest.exe GOOS = windows make build
2023-08-22 08:58:42 +08:00
build-win-embed-ui :
2023-11-14 18:05:13 +08:00
BINARY = atest.exe GOOS = windows make build-embed-ui
2023-04-04 13:18:51 +08:00
goreleaser :
goreleaser build --rm-dist --snapshot
2023-11-05 20:39:20 +08:00
make clean-embed-ui
2023-04-04 13:18:51 +08:00
build-image :
2023-07-21 18:47:11 +08:00
${ IMG_TOOL } build -t ghcr.io/linuxsuren/api-testing:master . \
2023-10-09 11:40:54 +08:00
--build-arg GOPROXY = ${ GOPROXY } \
2023-07-21 18:47:11 +08:00
--build-arg VERSION = $( shell git describe --abbrev= 0 --tags) -$( shell git rev-parse --short HEAD)
2023-04-04 14:13:16 +08:00
run-image :
2023-07-10 17:03:55 +08:00
docker run -p 7070:7070 -p 8080:8080 ghcr.io/linuxsuren/api-testing:master
2023-11-05 20:39:20 +08:00
run-server : build -ui
go run . server --local-storage 'bin/*.yaml' --console-path console/atest-ui/dist
2023-07-16 21:10:03 +08:00
run-console :
cd console/atest-ui && npm run dev
copy :
2023-03-12 15:08:28 +08:00
sudo cp bin/atest /usr/local/bin/
2023-11-08 15:30:25 +08:00
copy-ext :
2023-12-01 15:37:01 +08:00
sudo cp bin/atest-* /usr/local/bin/
2023-07-16 21:10:03 +08:00
copy-restart : build -embed -ui
2023-04-15 21:47:50 +08:00
atest service stop
make copy
atest service restart
2023-07-10 17:03:55 +08:00
2023-10-13 17:41:48 +08:00
# helm
helm-package :
2023-10-13 21:24:47 +08:00
helm package helm/api-testing --version ${ HELM_VERSION } -helm --app-version ${ APP_VERSION } -d bin
2023-10-13 17:41:48 +08:00
helm-push :
2023-10-25 15:15:19 +08:00
helm push bin/api-testing-${ HELM_VERSION } -helm.tgz oci://${ HELM_REPO }
2023-10-13 17:41:48 +08:00
helm-lint :
helm lint helm/api-testing
2023-08-31 09:53:19 +08:00
# plugins
plugin-git :
GOOS = ${ OS } go build -ldflags "-w -s" -o bin/atest-store-git extensions/store-git/main.go
2023-03-05 11:32:27 +08:00
test :
2023-04-02 14:51:00 +08:00
go test ./... -cover -v -coverprofile= coverage.out
go tool cover -func= coverage.out
2023-09-05 09:53:06 +08:00
testlong :
go test pkg/limit/limiter_long_test.go -v
2023-07-18 17:35:39 +08:00
test-ui :
cd console/atest-ui && npm run test:unit
2023-11-08 15:30:25 +08:00
test-ui-e2e :
2023-07-18 17:35:39 +08:00
cd console/atest-ui && npm run test:e2e
2023-06-07 22:59:47 +08:00
test-collector :
go test github.com/linuxsuren/api-testing/extensions/collector/./... -cover -v -coverprofile= collector-coverage.out
go tool cover -func= collector-coverage.out
2023-07-10 17:03:55 +08:00
test-store-orm :
go test github.com/linuxsuren/api-testing/extensions/store-orm/./... -cover -v -coverprofile= store-orm-coverage.out
go tool cover -func= store-orm-coverage.out
2023-08-01 07:28:53 +08:00
test-store-s3 :
go test github.com/linuxsuren/api-testing/extensions/store-s3/./... -cover -v -coverprofile= store-s3-coverage.out
go tool cover -func= store-s3-coverage.out
2023-08-15 10:18:08 +08:00
test-store-git :
go test github.com/linuxsuren/api-testing/extensions/store-git/./... -cover -v -coverprofile= store-git-coverage.out
go tool cover -func= store-git-coverage.out
2023-11-08 15:30:25 +08:00
test-store-etcd :
go test github.com/linuxsuren/api-testing/extensions/store-etcd/./... -cover -v -coverprofile= store-etcd-coverage.out
go tool cover -func= store-etcd-coverage.out
2023-08-10 08:15:53 +08:00
test-operator :
cd operator && make test # converage file path: operator/cover.out
2023-11-08 15:30:25 +08:00
test-all-backend : test test -collector test -store -orm test -store -s 3 test -store -git test -store -etcd
2023-07-18 17:35:39 +08:00
test-all : test -all -backend test -ui
2023-11-08 15:30:25 +08:00
test-e2e :
2023-11-13 14:24:21 +08:00
cd e2e && ./start.sh && ./start.sh compose-k8s.yaml
2023-07-16 21:10:03 +08:00
install-precheck :
cp .github/pre-commit .git/hooks/pre-commit
2023-04-04 13:18:51 +08:00
grpc :
2023-07-29 22:14:58 +08:00
protoc --proto_path= . \
--go_out= . --go_opt= paths = source_relative \
2023-04-04 13:18:51 +08:00
--go-grpc_out= . --go-grpc_opt= paths = source_relative \
2023-07-29 22:14:58 +08:00
pkg/server/server.proto \
2023-12-01 15:37:01 +08:00
pkg/testing/remote/loader.proto \
pkg/runner/monitor/monitor.proto
2023-06-26 08:47:24 +08:00
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 \
2023-11-24 11:53:48 +08:00
--openapiv2_out . \
--openapiv2_opt logtostderr = true \
--openapiv2_opt generate_unbound_methods = true \
2023-06-26 08:47:24 +08:00
pkg/server/server.proto
2023-08-12 08:02:59 +08:00
grpc-java :
protoc --plugin= protoc-gen-grpc-java \
--grpc-java_out= bin --proto_path= . \
pkg/server/server.proto \
pkg/testing/remote/loader.proto
2023-04-04 13:18:51 +08:00
grpc-js :
protoc -I= pkg/server server.proto \
--js_out= import_style = commonjs:bin \
--grpc-web_out= import_style = commonjs,mode= grpcwebtext:bin
2023-06-26 08:47:24 +08:00
# 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
2023-09-26 09:44:35 +08:00
# 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
2023-11-24 11:53:48 +08:00
hd :
curl https://linuxsuren.github.io/tools/install.sh| bash
install-tool : hd
2023-04-04 13:18:51 +08:00
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
2023-06-26 08:47:24 +08:00
hd i protoc-gen-grpc-web
2023-07-01 17:59:07 +08:00
hd i protoc-gen-grpc-gateway
2023-11-26 18:14:38 +08:00
hd get protocolbuffers/protobuf@v25.1 -o protobuf.zip
unzip protobuf.zip bin/protoc
rm -rf protobuf.zip
sudo install bin/protoc /usr/local/bin/
2023-11-24 11:53:48 +08:00
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
2023-11-12 07:31:15 +08:00
hd i cli/cli
gh extension install linuxsuren/gh-dev