Skip to content

Commit

Permalink
m
Browse files Browse the repository at this point in the history
  • Loading branch information
eudore committed Nov 30, 2024
1 parent 0398573 commit 1bd4782
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/github-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
9 changes: 9 additions & 0 deletions _example/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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),
Expand Down
3 changes: 1 addition & 2 deletions _example/middleware2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
23 changes: 16 additions & 7 deletions _example/otherCover.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, ", "))
}
}
}
Expand Down

0 comments on commit 1bd4782

Please sign in to comment.