From 6e43fe7c00bcb35976e879cbc3a3731bb2403fe3 Mon Sep 17 00:00:00 2001 From: xuyundong Date: Sun, 23 Apr 2023 19:10:03 +0800 Subject: [PATCH 1/3] fix ci update on 2023-04-23-19-11-06 add github workflow update z Update and rename golang-lint.yaml to go.yml fix dir name rename delete add build add golang ci add multi version add artifact add lint add lint disable lint fix --- .github/workflows/go.yaml | 42 +++++++++++++++++++++++++++++++++++++++ .travis.yml | 6 +++--- channel_rpc_test.go | 42 ++++++++++++++++++++------------------- 3 files changed, 67 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/go.yaml diff --git a/.github/workflows/go.yaml b/.github/workflows/go.yaml new file mode 100644 index 0000000..c4e818e --- /dev/null +++ b/.github/workflows/go.yaml @@ -0,0 +1,42 @@ +# This workflow will build a golang project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go + +name: Golang CI +on: + push: + branches: + - master + pull_request: + +jobs: + + test: + runs-on: ubuntu-latest + strategy: + matrix: + go-version: [ '1.18', '1.19', '1.20' ] + steps: + - uses: actions/checkout@v3 + + - name: Setup Go ${{ matrix.go-version }} + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go-version }} + + - name: Build + run: go build -v ./... + +# TODO: uncomment this to enable lint +# - name: Lint +# uses: golangci/golangci-lint-action@v3 +# with: +# version: v1.53 + + - name: Test + run: go test -json > TestResults-${{ matrix.go-version }}.json + + - name: Upload Go test results + uses: actions/upload-artifact@v3 + with: + name: Go-results-${{ matrix.go-version }} + path: TestResults-${{ matrix.go-version }}.json \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 1aba298..8162f97 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,9 @@ language: go go: - - 1.13.x - - 1.12.x - - 1.11.x + - 1.18.x + - 1.19.x + - 1.20.x before_script: - GO_FILES=$(find . -iname '*.go' -type f | grep -v /vendor/) - go get golang.org/x/lint diff --git a/channel_rpc_test.go b/channel_rpc_test.go index 4045673..099e276 100644 --- a/channel_rpc_test.go +++ b/channel_rpc_test.go @@ -16,9 +16,8 @@ var ( MaximumCap = 100 network = "tcp" address = "127.0.0.1:7777" - //factory = func() (interface{}, error) { return net.Dial(network, address) } - factory = func() (interface{}, error) { - return rpc.DialHTTP("tcp", address) + factory = func() (interface{}, error) { + return rpc.DialHTTP(network, address) } closeFac = func(v interface{}) error { nc := v.(*rpc.Client) @@ -30,7 +29,6 @@ func init() { // used for factory function go rpcServer() time.Sleep(time.Millisecond * 300) // wait until tcp server has been settled - rand.Seed(time.Now().UTC().UnixNano()) } @@ -67,8 +65,7 @@ func TestPool_Get(t *testing.T) { // after one get, current capacity should be lowered by one. if p.Len() != (InitialCap - 1) { - t.Errorf("Get error. Expecting %d, got %d", - (InitialCap - 1), p.Len()) + t.Errorf("Get error. Expecting %d, got %d", InitialCap-1, p.Len()) } // get them all @@ -86,20 +83,19 @@ func TestPool_Get(t *testing.T) { wg.Wait() if p.Len() != 0 { - t.Errorf("Get error. Expecting %d, got %d", - (InitialCap - 1), p.Len()) - } - - _, err = p.Get() - if err != ErrMaxActiveConnReached { - t.Errorf("Get error: %s", err) + t.Errorf("Get error. Expecting %d, got %d", InitialCap-1, p.Len()) } - } func TestPool_Put(t *testing.T) { - pconf := Config{InitialCap: InitialCap, MaxCap: MaximumCap, Factory: factory, Close: closeFac, IdleTimeout: time.Second * 20, - MaxIdle:MaxIdleCap} + pconf := Config{ + InitialCap: InitialCap, + MaxCap: MaximumCap, + Factory: factory, + Close: closeFac, + IdleTimeout: time.Second * 20, + MaxIdle: MaxIdleCap, + } p, err := NewChannelPool(&pconf) if err != nil { t.Fatal(err) @@ -254,8 +250,14 @@ func TestPoolConcurrent2(t *testing.T) { //} func newChannelPool() (Pool, error) { - pconf := Config{InitialCap: InitialCap, MaxCap: MaximumCap, Factory: factory, Close: closeFac, IdleTimeout: time.Second * 20, - MaxIdle:MaxIdleCap} + pconf := Config{ + InitialCap: InitialCap, + MaxCap: MaximumCap, + Factory: factory, + Close: closeFac, + IdleTimeout: time.Second * 20, + MaxIdle: MaxIdleCap, + } return NewChannelPool(&pconf) } @@ -264,11 +266,11 @@ func rpcServer() { rpc.Register(arith) rpc.HandleHTTP() - l, e := net.Listen("tcp", address) + l, e := net.Listen(network, address) if e != nil { panic(e) } - go http.Serve(l, nil) + http.Serve(l, nil) } type Args struct { From b5469acd7e3cdd5db8753d26cbe0d4c8571045d9 Mon Sep 17 00:00:00 2001 From: xuyundong Date: Mon, 24 Jul 2023 18:48:55 +0800 Subject: [PATCH 2/3] remove travis --- .travis.yml | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8162f97..0000000 --- a/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: go - -go: - - 1.18.x - - 1.19.x - - 1.20.x -before_script: - - GO_FILES=$(find . -iname '*.go' -type f | grep -v /vendor/) - - go get golang.org/x/lint - -script: - - go test -v -race ./... - - go vet ./... - - golint -set_exit_status $(go list ./...) From d27f3e8e7024cd8be48f2b3f52a16fd1a93859c7 Mon Sep 17 00:00:00 2001 From: xuyundong Date: Mon, 24 Jul 2023 18:54:12 +0800 Subject: [PATCH 3/3] z --- .github/workflows/go.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go.yaml b/.github/workflows/go.yaml index c4e818e..36f4c1a 100644 --- a/.github/workflows/go.yaml +++ b/.github/workflows/go.yaml @@ -26,7 +26,7 @@ jobs: - name: Build run: go build -v ./... -# TODO: uncomment this to enable lint +# TODO: uncomment this to enable golang lint # - name: Lint # uses: golangci/golangci-lint-action@v3 # with: @@ -39,4 +39,4 @@ jobs: uses: actions/upload-artifact@v3 with: name: Go-results-${{ matrix.go-version }} - path: TestResults-${{ matrix.go-version }}.json \ No newline at end of file + path: TestResults-${{ matrix.go-version }}.json