-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
472 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,5 +18,7 @@ | |
# vendor/ | ||
|
||
# Go workspace file | ||
go.work | ||
.idea | ||
.vscode/ | ||
**/.DS_Store | ||
test.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
APP_PATH:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) | ||
SCRIPTS_PATH:=$(APP_PATH)/scripts | ||
|
||
.PHONY: setup | ||
setup: | ||
@echo "初始化开发环境......" | ||
@find "$(SCRIPTS_PATH)" -type f -name '*.sh' -exec chmod +x {} \; | ||
@bash $(SCRIPTS_PATH)/setup/setup.sh | ||
@$(MAKE) tidy | ||
|
||
# 依赖清理 | ||
.PHONY: tidy | ||
tidy: | ||
@go mod tidy | ||
|
||
# 代码风格 | ||
.PHONY: fmt | ||
fmt: | ||
@goimports -l -w $$(find . -type f -name '*.go' -not -path "./.idea/*" -not -path "./cmd/monolithic/ioc/wire_gen.go") | ||
@gofumpt -l -w $$(find . -type f -name '*.go' -not -path "./.idea/*" -not -path "./cmd/monolithic/ioc/wire_gen.go") | ||
|
||
# 静态扫描 | ||
.PHONY: lint | ||
lint: | ||
@golangci-lint run -c $(SCRIPTS_PATH)/lint/.golangci.yaml ./... | ||
|
||
# 单元测试 | ||
.PHONY: ut | ||
ut: | ||
@go test -race -cover -coverprofile=unit.out -failfast -shuffle=on ./... | ||
|
||
# 集成测试 | ||
.PHONY: it | ||
it: | ||
@make dev_3rd_down | ||
@make dev_3rd_up | ||
@go test -tags=integration -race -cover -coverprofile=integration.out -failfast -shuffle=on ./... | ||
@make dev_3rd_down | ||
|
||
# 端到端测试 | ||
.PHONY: e2e | ||
e2e: | ||
@make dev_3rd_down | ||
@make dev_3rd_up | ||
@go test -tags=e2e -race -cover -coverprofile=e2e.out -failfast -shuffle=on ./... | ||
@make dev_3rd_down | ||
|
||
# 启动本地研发 docker 依赖 | ||
.PHONY: dev_3rd_up | ||
dev_3rd_up: | ||
@docker compose -f ./scripts/deploy/dev-compose.yaml up -d | ||
|
||
.PHONY: dev_3rd_down | ||
dev_3rd_down: | ||
@docker compose -f ./scripts/deploy/dev-compose.yaml down -v | ||
|
||
.PHONY: check | ||
check: | ||
@echo "\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 检查阶段 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n" | ||
@echo "整理项目依赖中......" | ||
@$(MAKE) tidy | ||
@echo "代码风格检查中......" | ||
@$(MAKE) fmt | ||
@echo "代码静态扫描中......" | ||
@$(MAKE) lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
|
||
output=$(make tidy) | ||
if [ -n "$output" ]; then | ||
echo "错误: 请在本地运行'make tidy'命令,确认无误后再提交." >&2 | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
|
||
output=$(make lint) | ||
if [ -n "$output" ]; then | ||
echo "错误: 请在本地运行'make lint'命令,确认无误后再提交." >&2 | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
|
||
output=$(make fmt) | ||
if [ -n "$output" ]; then | ||
echo >&2 "错误: 请在本地运行'make fmt'命令,确认无误后再提交." | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
|
||
echo "运行端到端测试中......" | ||
make e2e | ||
if [ $? -ne 0 ]; then | ||
echo "错误: 请在本地运行'make e2e'命令,确认测试全部通过后再提交." >&2 | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
|
||
echo "运行集成测试中......" | ||
make it | ||
if [ $? -ne 0 ]; then | ||
echo "错误: 请在本地运行'make it'命令,确认测试全部通过后再提交." >&2 | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
|
||
echo "运行单元测试中......" | ||
make ut | ||
if [ $? -ne 0 ]; then | ||
echo "错误: 请在本地运行'make ut'命令,确认测试全部通过后再提交." >&2 | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
version: '3' | ||
services: | ||
zookeeper: | ||
image: 'bitnami/zookeeper:latest' | ||
ports: | ||
- '2181:2181' | ||
environment: | ||
- ALLOW_ANONYMOUS_LOGIN=yes | ||
kafka: | ||
image: 'bitnami/kafka:3.5.1' | ||
ports: | ||
- '9092:9092' | ||
environment: | ||
- KAFKA_BROKER_ID=1 | ||
- KAFKA_CFG_LISTENERS=PLAINTEXT://:9092 | ||
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://127.0.0.1:9092 | ||
- KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181 | ||
- ALLOW_PLAINTEXT_LISTENER=yes | ||
- KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE=true | ||
depends_on: | ||
- zookeeper |
Oops, something went wrong.