From ce76ded47da9428e6e7635c0bbd8bbd46fc25677 Mon Sep 17 00:00:00 2001 From: liulei Date: Fri, 7 Jan 2022 18:16:12 +0800 Subject: [PATCH] fix: bench dir ci error and enable ci lint check --- .github/workflows/tests.yml | 5 ++++- .golangci.yml | 6 +++--- bench/main.go | 2 +- bench/svr/http.go | 19 ++++++++++++------- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c267a52..7028864 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -41,5 +41,8 @@ jobs: run: | go mod download + - name: Run ci lint + run: make lint + - name: Run test cover - run: sh helper/test-cover.sh + run: sh helper/test-cover.sh \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml index 5d5bf7b..58479dc 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,8 +1,8 @@ run: deadline: 5m - # skip-dirs: - # - test - # - examples + skip-dirs: + - test +# - bench linter-settings: goconst: diff --git a/bench/main.go b/bench/main.go index 310af87..34bd859 100644 --- a/bench/main.go +++ b/bench/main.go @@ -21,7 +21,7 @@ usage: ` func hintAndExit() { - fmt.Printf(usage) + fmt.Print(usage) os.Exit(0) } diff --git a/bench/svr/http.go b/bench/svr/http.go index 427c245..ed3f3cc 100644 --- a/bench/svr/http.go +++ b/bench/svr/http.go @@ -65,10 +65,11 @@ func reloadData() { logger.Debugf("%d users inserted. used: %dms", total, time.Since(began).Milliseconds()) } -var uidCounter int32 = 0 -var mode string = "" -var sqls int = 1 +var uidCounter int32 +var mode string +var sqls = 1 +// PrepareBenchDB prepares db data for bench func PrepareBenchDB() { db := pdbGet() _, err := dtmimp.DBExec(db, "drop table if exists dtm_busi.user_account_log") @@ -95,7 +96,9 @@ func StartSvr() { app := dtmutil.GetGinApp() benchAddRoute(app) logger.Debugf("bench listening at %d", benchPort) - go app.Run(fmt.Sprintf(":%s", benchPort)) + go func() { + _ = app.Run(fmt.Sprintf(":%s", benchPort)) + }() } func qsAdjustBalance(uid int, amount int, c *gin.Context) (interface{}, error) { @@ -116,11 +119,13 @@ func qsAdjustBalance(uid int, amount int, c *gin.Context) (interface{}, error) { if strings.Contains(mode, "barrier") { barrier, err := dtmcli.BarrierFromQuery(c.Request.URL.Query()) logger.FatalIfError(err) - barrier.Call(txGet(), f) + err = barrier.Call(txGet(), f) + logger.FatalIfError(err) } else { tx := txGet() - f(tx) - err := tx.Commit() + err := f(tx) + logger.FatalIfError(err) + err = tx.Commit() logger.FatalIfError(err) }