diff --git a/.github/workflows/github-action.yml b/.github/workflows/github-action.yml index d6ba08c..7fcadc8 100644 --- a/.github/workflows/github-action.yml +++ b/.github/workflows/github-action.yml @@ -62,7 +62,7 @@ jobs: - name: Run Notice run: go run _example/otherCover.go - name: Run Coverage - if: env.go == '1.20' + if: matrix.go == '1.20' run: go tool cover -html coverage.out -o coverage.html - uses: codecov/codecov-action@v3 if: env.go == '1.20' @@ -71,7 +71,7 @@ jobs: files: coverage.out flags: ${{ matrix.os }},go-${{ matrix.go }} - uses: actions/upload-artifact@v3 - if: env.go == '1.20' + if: matrix.go == '1.20' with: name: Coverage-eudore-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.go }} - path: ${{ env.WORKDIR }}/coverage.html + path: ${{ env.WORKDIR }}/coverage.html \ No newline at end of file diff --git a/_example/logger_test.go b/_example/logger_test.go index cb7dc8e..c23f189 100644 --- a/_example/logger_test.go +++ b/_example/logger_test.go @@ -58,6 +58,13 @@ func TestLoggerStd(t *testing.T) { ) NewLoggerWithContext(ctx) NewLoggerWithContext(context.Background()) + + NewLogger(&LoggerConfig{ + Handlers: []LoggerHandler{ + NewLoggerWriterStdout(true), + NewLoggerWriterStdout(false), + }, + }).Info("Stdout") } func TestLoggerInit1(t *testing.T) { @@ -280,6 +287,8 @@ func TestLoggerWriterAsync(t *testing.T) { defer os.Remove(logfile) log := NewLogger(&LoggerConfig{ Handlers: []LoggerHandler{ + NewLoggerWriterStdout(true), + NewLoggerWriterStdout(false), NewLoggerWriterAsync([]LoggerHandler{ &loggerAsyncWait{}, }, 5, 2048, time.Millisecond*50), diff --git a/_example/middleware2_test.go b/_example/middleware2_test.go index 32a6813..00b997a 100644 --- a/_example/middleware2_test.go +++ b/_example/middleware2_test.go @@ -18,7 +18,6 @@ import ( . "github.com/eudore/eudore/middleware" "github.com/gobwas/ws" "github.com/gobwas/ws/wsutil" - "github.com/google/uuid" ) type metadatable func() any @@ -81,7 +80,7 @@ func TestMiddlewareLoggerAccess(*testing.T) { NewLoggerLevelFunc(func(Context) int { return 4 }), ) app.AddMiddleware("global", NewRequestIDFunc(func(Context) string { - return uuid.New().String() + return GetStringRandom(16) })) app.AnyFunc("/long", func(ctx Context) { time.Sleep(time.Millisecond * 10) diff --git a/_example/otherCover.go b/_example/otherCover.go index 209cc4b..053b144 100644 --- a/_example/otherCover.go +++ b/_example/otherCover.go @@ -17,18 +17,27 @@ func main() { if err != nil { panic(err) } + + level := 100.00 + var results []string for _, pkg := range strings.Split(os.Getenv("PACKAGES"), ",") { v, ok := total[pkg] if ok { cov := percent(v[0], v[1]) - switch { - case cov >= 99: - fmt.Printf("::notice::%s \t%.1f%%\r\n", pkg, cov) - case cov >= 90: - fmt.Printf("::warning::%s \t%.1f%%\r\n", pkg, cov) - default: - fmt.Printf("::error::%s \t%.1f%%\r\n", pkg, cov) + if cov < level { + level = cov } + results = append(results, fmt.Sprintf("%s %.1f%%", pkg, cov)) + } + } + if results != nil { + switch { + case level >= 99: + fmt.Printf("::notice::%s\r\n", strings.Join(results, ", ")) + case level >= 90: + fmt.Printf("::warning::%s\r\n", strings.Join(results, ", ")) + default: + fmt.Printf("::error::%s\r\n", strings.Join(results, ", ")) } } }