Create & Init Project...

This commit is contained in:
2019-04-22 18:49:16 +08:00
commit fc4fa37393
25440 changed files with 4054998 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
"go_library",
)
go_binary(
name = "cmd",
embed = [":go_default_library"],
tags = ["automanaged"],
)
go_library(
name = "go_default_library",
srcs = ["main.go"],
data = ["tapd.toml"],
importpath = "go-common/app/service/ep/footman/cmd",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/ep/footman/conf:go_default_library",
"//app/service/ep/footman/server/http:go_default_library",
"//app/service/ep/footman/service:go_default_library",
"//library/ecode/tip:go_default_library",
"//library/log:go_default_library",
"//library/net/trace:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//app/service/ep/footman/cmd/bugly:all-srcs",
"//app/service/ep/footman/cmd/tapd:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,46 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
"go_library",
)
go_binary(
name = "bugly",
embed = [":go_default_library"],
tags = ["automanaged"],
)
go_library(
name = "go_default_library",
srcs = ["bugly.go"],
importpath = "go-common/app/service/ep/footman/cmd/bugly",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/ep/footman/conf:go_default_library",
"//app/service/ep/footman/service:go_default_library",
"//library/cache/memcache:go_default_library",
"//library/container/pool:go_default_library",
"//library/database/orm:go_default_library",
"//library/log:go_default_library",
"//library/net/http/blademaster:go_default_library",
"//library/net/netutil/breaker:go_default_library",
"//library/time:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,100 @@
package main
import (
"context"
"flag"
"go-common/app/service/ep/footman/conf"
"go-common/app/service/ep/footman/service"
"go-common/library/cache/memcache"
"go-common/library/container/pool"
"go-common/library/database/orm"
"go-common/library/log"
xhttp "go-common/library/net/http/blademaster"
"go-common/library/net/netutil/breaker"
"go-common/library/time"
)
func main() {
var (
versionPath string
cookiePath string
tokenPath string
action string
)
flag.StringVar(&versionPath, "v", "", "版本批次文件路径")
flag.StringVar(&cookiePath, "c", "", "cookie文件路径")
flag.StringVar(&tokenPath, "t", "", "token文件路径")
flag.StringVar(&action, "a", "", "操作类型")
flag.Parse()
c := &conf.Config{
HTTPClient: &xhttp.ClientConfig{
App: &xhttp.App{
Key: "c05dd4e1638a8af0",
Secret: "7daa7f8c06cd33c5c3067063c746fdcb",
},
Dial: time.Duration(20000000000),
Timeout: time.Duration(100000000000),
KeepAlive: time.Duration(600000000000),
Breaker: &breaker.Config{
Window: time.Duration(100000000000),
Sleep: time.Duration(20000000000),
Bucket: 10,
Ratio: 0.5,
Request: 100,
},
},
Bugly: &conf.BuglyConf{
Host: "https://bugly.qq.com",
Cookie: cookiePath,
Token: tokenPath,
Version: versionPath,
},
ORM: &orm.Config{
DSN: "root:123456@tcp(172.18.33.130:3306)/footman?timeout=200ms&readTimeout=2000ms&writeTimeout=2000ms&parseTime=true&loc=Local&charset=utf8,utf8mb4",
Active: 5,
Idle: 5,
IdleTimeout: time.Duration(20000000000),
},
Mail: &conf.Mail{
Host: "smtp.exmail.qq.com",
Port: 465,
Username: "merlin@bilibili.com",
Password: "",
NoticeOwner: []string{"fengyifeng@bilibili.com"},
},
Memcache: &conf.Memcache{
Expire: time.Duration(10000000),
Config: &memcache.Config{
Name: "merlin",
Proto: "tcp",
Addr: "172.22.33.137:11216",
DialTimeout: time.Duration(1000),
ReadTimeout: time.Duration(1000),
WriteTimeout: time.Duration(1000),
Config: &pool.Config{
Active: 10,
IdleTimeout: time.Duration(1000),
},
},
},
Bugly2Tapd: &conf.Bugly2Tapd{
ProjectIds: []string{"900028525"},
},
}
s := service.New(c)
log.Info("v1.0.40")
switch action {
case "insertTapd":
s.BuglyInsertTapd(context.Background())
default:
s.GetSaveIssuesWithMultiVersion(context.Background())
s.UpdateBuglyStatusInTapd(context.Background())
s.UpdateBugInTapd(context.Background())
}
defer s.Close()
}

View File

@@ -0,0 +1,46 @@
package main
import (
"flag"
"os"
"os/signal"
"syscall"
"go-common/app/service/ep/footman/conf"
"go-common/app/service/ep/footman/server/http"
"go-common/app/service/ep/footman/service"
ecode "go-common/library/ecode/tip"
"go-common/library/log"
"go-common/library/net/trace"
)
func main() {
flag.Parse()
if err := conf.Init(); err != nil {
panic(err)
}
log.Init(conf.Conf.Log)
defer log.Close()
log.Info("start")
defer trace.Close()
ecode.Init(conf.Conf.Ecode)
s := service.New(conf.Conf)
http.Init(conf.Conf, s)
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
for {
si := <-c
log.Info("get a signal %s", si.String())
switch si {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
log.Info("exit")
s.Close()
return
case syscall.SIGHUP:
default:
return
}
}
}

View File

@@ -0,0 +1,76 @@
[bm]
addr = "0.0.0.0:9001"
timeout = "10s"
[httpClient]
key = "c05dd4e1638a8af0"
secret = "7daa7f8c06cd33c5c3067063c746fdcb"
dial = "2s"
timeout = "100s"
keepAlive = "60s"
timer = 1000
[httpClient.breaker]
window = "10s"
sleep = "2000ms"
bucket = 10
ratio = 0.5
request = 100
[tapd]
WorkspaceIDs = ["20060791","20055921"]
IterationWorkspaceIDs = ["20060791","20055921","20082211"]
StoryWorkspaceIDs = ["20060791","20055921"]
BugWorkspaceIDs = ["20082211"]
IPS = 30
SPS = 30
SCPS = 50
CPS = 50
StoryFilePath = "story.txt"
ChangeFilePath = "change.txt"
IterationFilePath = "iteration.txt"
BugFilePath = "bug.txt"
retryTime = 5
waitTime = "10s"
[scheduler]
#每天凌晨2点跑拉取数据任务
saveTapdTime = "0 0 2 * * ?"
[mail]
host = "smtp.exmail.qq.com"
port = 465
username = "merlin@bilibili.com"
password = ""
noticeOwner = ["fengyifeng@bilibili.com"]
[memcache]
name = "merlin"
proto = "tcp"
addr = "172.22.33.137:11216"
idle = 5
active = 10
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
expire = "12h"
[bugly]
host = "https://bugly.qq.com"
cookie = "D:\\fyf\\code5\\bugly-dailyrun\\conf\\cookie.conf"
token = "D:\\fyf\\code5\\bugly-dailyrun\\conf\\token.conf"
version = "D:\\fyf\\code5\\bugly-dailyrun\\conf\\version.conf"
[bugly2tapd]
projectIds = ["900028525"]
[orm]
dsn = "root:123456@tcp(172.18.33.130:3306)/footman?timeout=200ms&readTimeout=2000ms&writeTimeout=2000ms&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 5
idle = 5
idleTimeout = "4h"

View File

@@ -0,0 +1,46 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
"go_library",
)
go_binary(
name = "tapd",
embed = [":go_default_library"],
tags = ["automanaged"],
)
go_library(
name = "go_default_library",
srcs = ["tapd.go"],
importpath = "go-common/app/service/ep/footman/cmd/tapd",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/ep/footman/conf:go_default_library",
"//app/service/ep/footman/model:go_default_library",
"//app/service/ep/footman/service:go_default_library",
"//library/cache/memcache:go_default_library",
"//library/container/pool:go_default_library",
"//library/log:go_default_library",
"//library/net/http/blademaster:go_default_library",
"//library/net/netutil/breaker:go_default_library",
"//library/time:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,144 @@
package main
import (
"flag"
"go-common/app/service/ep/footman/conf"
"go-common/app/service/ep/footman/model"
"go-common/app/service/ep/footman/service"
"go-common/library/cache/memcache"
"go-common/library/container/pool"
"go-common/library/log"
xhttp "go-common/library/net/http/blademaster"
"go-common/library/net/netutil/breaker"
"go-common/library/time"
)
func main() {
var (
workspaceType string
reportType string
workspaceID string
iteration string
reportPath string
isTimeStr string
startTime string
endTime string
importPath string
importSheetName string
)
flag.StringVar(&workspaceType, "t", "", "端类型android或ios")
flag.StringVar(&reportType, "r", "", "报表类型")
flag.StringVar(&workspaceID, "w", "", "项目ID")
flag.StringVar(&iteration, "i", "", "迭代名称")
flag.StringVar(&reportPath, "p", "", "报表文件路径")
flag.StringVar(&isTimeStr, "d", "n", "是否详细时间")
flag.StringVar(&startTime, "s", "", "开始时间 2018-01-01")
flag.StringVar(&endTime, "e", "", "结束时间 2019-01-01")
flag.StringVar(&importPath, "f", "", "导入文件")
flag.StringVar(&importSheetName, "sn", "", "导入文件sheet name")
flag.Parse()
c := &conf.Config{
Tapd: &conf.Tapd{
RetryTime: 5,
WaitTime: time.Duration(100000),
},
HTTPClient: &xhttp.ClientConfig{
App: &xhttp.App{
Key: "c05dd4e1638a8af0",
Secret: "7daa7f8c06cd33c5c3067063c746fdcb",
},
Dial: time.Duration(2000000000),
Timeout: time.Duration(10000000000),
KeepAlive: time.Duration(60000000000),
Breaker: &breaker.Config{
Window: time.Duration(10000000000),
Sleep: time.Duration(2000000000),
Bucket: 10,
Ratio: 0.5,
Request: 100,
},
},
Mail: &conf.Mail{
Host: "smtp.exmail.qq.com",
Port: 465,
Username: "merlin@bilibili.com",
Password: "",
NoticeOwner: []string{"fengyifeng@bilibili.com"},
},
Memcache: &conf.Memcache{
Expire: time.Duration(10000000),
Config: &memcache.Config{
Name: "merlin",
Proto: "tcp",
Addr: "172.22.33.137:11216",
DialTimeout: time.Duration(1000),
ReadTimeout: time.Duration(1000),
WriteTimeout: time.Duration(1000),
Config: &pool.Config{
Active: 10,
IdleTimeout: time.Duration(1000),
},
},
},
}
s := service.New(c)
switch reportType {
//纯测试时长统计列表区分_ios_android
case "testtime":
if err := s.TestTimeReport(workspaceID, workspaceType, iteration, reportPath, model.Test, model.IPS, model.SPS, model.SCPS); err != nil {
log.Error("Error happened when generating test time reprot:error(%v)", err)
}
//待测试时长统计 不区分ios android
case "waittest":
if err := s.WaitTimeReport(workspaceID, iteration, reportPath, model.Test, model.IPS, model.SPS, model.SCPS); err != nil {
log.Error("Error happened when generating wait for test time reprot:error(%v)", err)
}
//产品验收时长统计 不区分ios android
case "experiencetime":
if err := s.TestTimeReport(workspaceID, workspaceType, iteration, reportPath, model.Experience, model.IPS, model.SPS, model.SCPS); err != nil {
log.Error("Error happened when generating experience time reprot:error(%v)", err)
}
case "delayedstory":
if err := s.DelayedStoryReport(workspaceID, workspaceType, iteration, reportPath, model.IPS, model.SPS, model.SCPS); err != nil {
log.Error("Error happened when generating delayed story reprot:error(%v)", err)
}
//测试中打回需求统计
case "testrejected":
if err := s.RejectedStoryReport(workspaceID, workspaceType, iteration, reportPath, model.Test, model.IPS, model.SPS, model.SCPS); err != nil {
log.Error("Error happened when generating test rejected story reprot:error(%v)", err)
}
//产品验收打回需求统计
case "experiencerejected":
if err := s.RejectedStoryReport(workspaceID, workspaceType, iteration, reportPath, model.Experience, model.IPS, model.SPS, model.SCPS); err != nil {
log.Error("Error happened when generating experience rejected story reprot:error(%v)", err)
}
//故事墙
case "storywall":
isTime := false
if isTimeStr == "y" {
isTime = true
}
if err := s.StoryWallReport(workspaceID, workspaceType, iteration, reportPath, isTime, model.IPS, model.SPS, model.SCPS, model.CPS); err != nil {
log.Error("Error happened when generating story wall reprot:error(%v)", err)
}
case "storywallreport":
if err := s.GenStoryReport(workspaceType, importPath, importSheetName, reportPath, iteration, startTime, endTime); err != nil {
log.Error("Error happened when generating experience rejected story reprot:error(%v)", err)
}
}
}