diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..3a20af3e --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,29 @@ +on: + release: + types: [ created ] + +jobs: + releases-matrix: + name: Release goctl binary + if: startsWith(github.ref, 'refs/tags/tools/goctl/') + runs-on: ubuntu-latest + strategy: + matrix: + # build and publish in parallel: linux/386, linux/amd64, linux/arm64, + # windows/386, windows/amd64, windows/arm64, darwin/amd64, darwin/arm64 + goos: [ linux, windows, darwin ] + goarch: [ "386", amd64, arm64 ] + exclude: + - goarch: "386" + goos: darwin + steps: + - uses: actions/checkout@v2 + - uses: zeromicro/go-zero-release-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + goos: ${{ matrix.goos }} + goarch: ${{ matrix.goarch }} + goversion: "https://dl.google.com/go/go1.17.5.linux-amd64.tar.gz" + project_path: "tools/goctl" + binary_name: "goctl" + extra_files: tools/goctl/goctl.md \ No newline at end of file diff --git a/core/logx/tracelogger_test.go b/core/logx/tracelogger_test.go index 614f16ce..8f8fe1b4 100644 --- a/core/logx/tracelogger_test.go +++ b/core/logx/tracelogger_test.go @@ -18,7 +18,11 @@ func TestTraceLog(t *testing.T) { SetLevel(InfoLevel) w := new(mockWriter) old := writer.Swap(w) - defer writer.Store(old) + writer.lock.RLock() + defer func() { + writer.lock.RUnlock() + writer.Store(old) + }() otp := otel.GetTracerProvider() tp := sdktrace.NewTracerProvider(sdktrace.WithSampler(sdktrace.AlwaysSample())) @@ -35,7 +39,11 @@ func TestTraceLog(t *testing.T) { func TestTraceError(t *testing.T) { w := new(mockWriter) old := writer.Swap(w) - defer writer.Store(old) + writer.lock.RLock() + defer func() { + writer.lock.RUnlock() + writer.Store(old) + }() otp := otel.GetTracerProvider() tp := sdktrace.NewTracerProvider(sdktrace.WithSampler(sdktrace.AlwaysSample())) @@ -49,7 +57,7 @@ func TestTraceError(t *testing.T) { l := WithContext(context.Background()) l = l.WithContext(nilCtx) l = l.WithContext(ctx) - SetLevel(InfoLevel) + SetLevel(ErrorLevel) l.WithDuration(time.Second).Error(testlog) validate(t, w.String(), true, true) w.Reset() @@ -61,6 +69,7 @@ func TestTraceError(t *testing.T) { validate(t, w.String(), true, true) w.Reset() l.WithDuration(time.Second).Errorw(testlog, Field("foo", "bar")) + fmt.Println(w.String()) validate(t, w.String(), true, true) assert.True(t, strings.Contains(w.String(), "foo"), w.String()) assert.True(t, strings.Contains(w.String(), "bar"), w.String()) @@ -69,7 +78,11 @@ func TestTraceError(t *testing.T) { func TestTraceInfo(t *testing.T) { w := new(mockWriter) old := writer.Swap(w) - defer writer.Store(old) + writer.lock.RLock() + defer func() { + writer.lock.RUnlock() + writer.Store(old) + }() otp := otel.GetTracerProvider() tp := sdktrace.NewTracerProvider(sdktrace.WithSampler(sdktrace.AlwaysSample())) @@ -102,7 +115,11 @@ func TestTraceInfoConsole(t *testing.T) { w := new(mockWriter) o := writer.Swap(w) - defer writer.Store(o) + writer.lock.RLock() + defer func() { + writer.lock.RUnlock() + writer.Store(o) + }() otp := otel.GetTracerProvider() tp := sdktrace.NewTracerProvider(sdktrace.WithSampler(sdktrace.AlwaysSample())) @@ -127,7 +144,11 @@ func TestTraceInfoConsole(t *testing.T) { func TestTraceSlow(t *testing.T) { w := new(mockWriter) old := writer.Swap(w) - defer writer.Store(old) + writer.lock.RLock() + defer func() { + writer.lock.RUnlock() + writer.Store(old) + }() otp := otel.GetTracerProvider() tp := sdktrace.NewTracerProvider(sdktrace.WithSampler(sdktrace.AlwaysSample())) @@ -159,7 +180,11 @@ func TestTraceSlow(t *testing.T) { func TestTraceWithoutContext(t *testing.T) { w := new(mockWriter) old := writer.Swap(w) - defer writer.Store(old) + writer.lock.RLock() + defer func() { + writer.lock.RUnlock() + writer.Store(old) + }() l := WithContext(context.Background()) SetLevel(InfoLevel)