Skip to content

Commit

Permalink
chore: add release action to auto build binaries (zeromicro#1884)
Browse files Browse the repository at this point in the history
* chore: add release action to auto build binaries

Signed-off-by: chenquan <chenquan.dev@gmail.com>

* fix: test bugs

Signed-off-by: chenquan <chenquan.dev@gmail.com>
  • Loading branch information
chenquan authored May 25, 2022
1 parent 72ebbb9 commit fd12659
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 7 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -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
39 changes: 32 additions & 7 deletions core/logx/tracelogger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand All @@ -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()))
Expand All @@ -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()
Expand All @@ -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())
Expand All @@ -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()))
Expand Down Expand Up @@ -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()))
Expand All @@ -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()))
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit fd12659

Please sign in to comment.