From 2d7a64eb9777c248b87da3b9b2fd4fd613b3fded Mon Sep 17 00:00:00 2001 From: sanxun0325 Date: Sun, 13 Sep 2020 16:37:38 +0800 Subject: [PATCH 01/15] del travis.yml --- .travis.yml | 20 -------------------- example/config/main.go | 1 - 2 files changed, 21 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2f7a1a7d..00000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: go - -dist: xenial -sudo: required - -go: - - 1.12.x - -env: - - GO111MODULE=on - -before_install: go get golang.org/x/tools/cmd/goimports - -script: - - diff -u <(echo -n) <(gofmt -d -s .) - - diff -u <(echo -n) <(goimports -d .) - - go test -v ./... -coverprofile=coverage.txt -covermode=atomic - -after_success: - - bash <(curl -s https://codecov.io/bash) \ No newline at end of file diff --git a/example/config/main.go b/example/config/main.go index 169270e2..210ef5d8 100644 --- a/example/config/main.go +++ b/example/config/main.go @@ -131,5 +131,4 @@ func main() { PageSize: 10, }) fmt.Printf("Search config:%+v \n", searchPage) - } From 55c3f2b1c8bc990b08f630ef382d33530dd05ff7 Mon Sep 17 00:00:00 2001 From: sanxun0325 Date: Sun, 13 Sep 2020 16:50:02 +0800 Subject: [PATCH 02/15] update go.yml --- .github/workflows/go.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 084a762e..54fc4aee 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -29,10 +29,7 @@ jobs: - name: Install goimports run: go get golang.org/x/tools/cmd/goimports - - - name: Install go ci lint - run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0 - + - name: Test run: | diff -u <(echo -n) <(gofmt -d -s .) From 2d485186c2bb0e33c1b97d10eccf7101eede313e Mon Sep 17 00:00:00 2001 From: sanxun0325 Date: Sun, 13 Sep 2020 16:52:07 +0800 Subject: [PATCH 03/15] del go.yml --- .github/workflows/go.yml | 41 ---------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml deleted file mode 100644 index 54fc4aee..00000000 --- a/.github/workflows/go.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: CI - -on: - push: - branches: "master" - pull_request: - branches: "*" - -jobs: - - build: - name: ubuntu-latest ${{ matrix.config.go_version }} - runs-on: ubuntu-latest - strategy: - matrix: - config: - - go_version: 1.13 - - go_version: 1.14 - steps: - - - name: Set up Go 1.x - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.config.go_version }} - id: go - - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - - name: Install goimports - run: go get golang.org/x/tools/cmd/goimports - - - name: Test - run: | - diff -u <(echo -n) <(gofmt -d -s .) - diff -u <(echo -n) <(goimports -d .) - golangci-lint run -v --disable-all --enable=govet --enable=staticcheck --enable=ineffassign --enable=misspell - go test -v -race ./... -coverprofile=coverage.txt -covermode=atomic - - - name: Coverage - run: bash <(curl -s https://codecov.io/bash) From f56fe9c0a44ff93c9090ace0e834493df412500f Mon Sep 17 00:00:00 2001 From: sanxun0325 Date: Sun, 13 Sep 2020 16:54:53 +0800 Subject: [PATCH 04/15] add travis.yml --- .travis.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..2f7a1a7d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,20 @@ +language: go + +dist: xenial +sudo: required + +go: + - 1.12.x + +env: + - GO111MODULE=on + +before_install: go get golang.org/x/tools/cmd/goimports + +script: + - diff -u <(echo -n) <(gofmt -d -s .) + - diff -u <(echo -n) <(goimports -d .) + - go test -v ./... -coverprofile=coverage.txt -covermode=atomic + +after_success: + - bash <(curl -s https://codecov.io/bash) \ No newline at end of file From 4cc3dae27fb9bbe981791e3d2cbeb9aff140c40e Mon Sep 17 00:00:00 2001 From: sanxun0325 Date: Mon, 21 Sep 2020 10:12:10 +0800 Subject: [PATCH 05/15] commit go.yml --- .github/workflows/go.yml | 46 ++++++++++++++++++++++++++++++++++++++++ .travis.yml | 20 ----------------- 2 files changed, 46 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/go.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 00000000..d07df466 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,46 @@ +name: CI + +on: + push: + branches: "master" + pull_request: + branches: "*" + +jobs: + + build: + name: ubuntu-latest ${{ matrix.config.go_version }} + runs-on: ubuntu-latest + strategy: + matrix: + config: + - go_version: 1.13 + - go_version: 1.14 + steps: + + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.config.go_version }} + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Install goimports + run: go get golang.org/x/tools/cmd/goimports + + - name: Install go ci lint + run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0 + + - name: Test + run: | + diff -u <(echo -n) <(gofmt -d -s .) + diff -u <(echo -n) <(goimports -d .) + golangci-lint run -v --disable-all --enable=govet --enable=staticcheck --enable=ineffassign --enable=misspell + go test -v -race ./... -coverprofile=coverage.txt -covermode=atomic + + - name: Coverage + run: bash <(curl -s https://codecov.io/bash) + + diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2f7a1a7d..00000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: go - -dist: xenial -sudo: required - -go: - - 1.12.x - -env: - - GO111MODULE=on - -before_install: go get golang.org/x/tools/cmd/goimports - -script: - - diff -u <(echo -n) <(gofmt -d -s .) - - diff -u <(echo -n) <(goimports -d .) - - go test -v ./... -coverprofile=coverage.txt -covermode=atomic - -after_success: - - bash <(curl -s https://codecov.io/bash) \ No newline at end of file From 8d127f4dce8f8c48a4faae45f2f14ea40d38c0da Mon Sep 17 00:00:00 2001 From: sanxun0325 Date: Mon, 21 Sep 2020 10:26:28 +0800 Subject: [PATCH 06/15] update go.yml --- .github/workflows/go.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index d07df466..8f19fa75 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -37,7 +37,6 @@ jobs: run: | diff -u <(echo -n) <(gofmt -d -s .) diff -u <(echo -n) <(goimports -d .) - golangci-lint run -v --disable-all --enable=govet --enable=staticcheck --enable=ineffassign --enable=misspell go test -v -race ./... -coverprofile=coverage.txt -covermode=atomic - name: Coverage From 2546dca9f9800df68d9c7ec7942fb47e22f6469b Mon Sep 17 00:00:00 2001 From: sanxun0325 Date: Mon, 21 Sep 2020 10:38:55 +0800 Subject: [PATCH 07/15] update go.yml --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 8f19fa75..7d02d9ec 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -37,7 +37,7 @@ jobs: run: | diff -u <(echo -n) <(gofmt -d -s .) diff -u <(echo -n) <(goimports -d .) - go test -v -race ./... -coverprofile=coverage.txt -covermode=atomic + go test -v ./... -coverprofile=coverage.txt -covermode=atomic - name: Coverage run: bash <(curl -s https://codecov.io/bash) From 40d014bd649dd69ec045a70503e4a2bba7484aef Mon Sep 17 00:00:00 2001 From: sanxun0325 Date: Mon, 21 Sep 2020 11:36:49 +0800 Subject: [PATCH 08/15] update go.yml --- .github/workflows/go.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 7d02d9ec..79c06b14 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -30,9 +30,6 @@ jobs: - name: Install goimports run: go get golang.org/x/tools/cmd/goimports - - name: Install go ci lint - run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0 - - name: Test run: | diff -u <(echo -n) <(gofmt -d -s .) From ce5ee34bb60efb5de0afa1443751a682ef76a31b Mon Sep 17 00:00:00 2001 From: sanxun0325 Date: Thu, 24 Sep 2020 13:26:30 +0800 Subject: [PATCH 09/15] update config_client_test dataid --- clients/config_client/config_client_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/config_client/config_client_test.go b/clients/config_client/config_client_test.go index 5278cebc..f361d931 100644 --- a/clients/config_client/config_client_test.go +++ b/clients/config_client/config_client_test.go @@ -477,7 +477,7 @@ func TestListen(t *testing.T) { t.Run("TestListenConfigWithMultipleClients", func(t *testing.T) { ch := make(chan string) listenConfigParam := vo.ConfigParam{ - DataId: localConfigTest.DataId, + DataId: "MultipleClients", Group: localConfigTest.Group, OnChange: func(namespace, group, dataId, data string) { fmt.Println("group:" + group + ", dataId:" + dataId + ", data:" + data) @@ -512,7 +512,7 @@ func TestListen(t *testing.T) { t.Run("TestListenConfigWithMultipleClientsMultipleConfig", func(t *testing.T) { ch := make(chan string) listenConfigParam := vo.ConfigParam{ - DataId: localConfigTest.DataId, + DataId: "MultipleClientsMultipleConfig", Group: localConfigTest.Group, OnChange: func(namespace, group, dataId, data string) { fmt.Println("group:" + group + ", dataId:" + dataId + ", data:" + data) From 26ecf00c86ad4509279de30035b81bfa72dfec99 Mon Sep 17 00:00:00 2001 From: sanxun0325 Date: Thu, 24 Sep 2020 13:29:36 +0800 Subject: [PATCH 10/15] update --- clients/config_client/config_client_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/config_client/config_client_test.go b/clients/config_client/config_client_test.go index f361d931..752fd3f8 100644 --- a/clients/config_client/config_client_test.go +++ b/clients/config_client/config_client_test.go @@ -493,7 +493,7 @@ func TestListen(t *testing.T) { client1.ListenConfig(listenConfigParam) success, err := client.PublishConfig(vo.ConfigParam{ - DataId: localConfigTest.DataId, + DataId: "MultipleClients", Group: localConfigTest.Group, Content: localConfigTest.Content}) @@ -528,7 +528,7 @@ func TestListen(t *testing.T) { client1.ListenConfig(listenConfigParam) success, err := client.PublishConfig(vo.ConfigParam{ - DataId: localConfigTest.DataId, + DataId: "MultipleClientsMultipleConfig", Group: localConfigTest.Group, Content: localConfigTest.Content}) From 5619551919f4abb329d4538b92ee1f370929e69f Mon Sep 17 00:00:00 2001 From: sanxun0325 Date: Thu, 24 Sep 2020 14:08:04 +0800 Subject: [PATCH 11/15] update --- clients/config_client/config_client_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/clients/config_client/config_client_test.go b/clients/config_client/config_client_test.go index 752fd3f8..1f732c8e 100644 --- a/clients/config_client/config_client_test.go +++ b/clients/config_client/config_client_test.go @@ -554,7 +554,7 @@ func TestCancelListenConfig(t *testing.T) { var success bool var context, context1 string listenConfigParam := vo.ConfigParam{ - DataId: "dataId", + DataId: "CancelOne", Group: "group", OnChange: func(namespace, group, dataId, data string) { fmt.Println("group:" + group + ", dataId:" + dataId + ", data:" + data) @@ -563,7 +563,7 @@ func TestCancelListenConfig(t *testing.T) { } listenConfigParam1 := vo.ConfigParam{ - DataId: "dataId1", + DataId: "CancelOne1", Group: "group1", OnChange: func(namespace, group, dataId, data string) { fmt.Println("group1:" + group + ", dataId1:" + dataId + ", data:" + data) @@ -582,14 +582,14 @@ func TestCancelListenConfig(t *testing.T) { for i := 1; i <= 5; i++ { go func() { success, err = client.PublishConfig(vo.ConfigParam{ - DataId: "dataId", + DataId: "CancelOne", Group: "group", Content: "abcd" + strconv.Itoa(i)}) }() go func() { success, err = client.PublishConfig(vo.ConfigParam{ - DataId: "dataId1", + DataId: "CancelOne1", Group: "group1", Content: "abcd" + strconv.Itoa(i)}) }() From bd278571b40e4a50cf7179ec02b95b672e7a792d Mon Sep 17 00:00:00 2001 From: sanxun0325 Date: Sat, 26 Sep 2020 21:34:52 +0800 Subject: [PATCH 12/15] fix ci --- clients/config_client/config_client_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/config_client/config_client_test.go b/clients/config_client/config_client_test.go index 1f732c8e..06d3067e 100644 --- a/clients/config_client/config_client_test.go +++ b/clients/config_client/config_client_test.go @@ -453,7 +453,7 @@ func TestListen(t *testing.T) { go func() { err = client.ListenConfig(vo.ConfigParam{ - DataId: localConfigTest.DataId, + DataId: "ConfigNoChange", Group: localConfigTest.Group, OnChange: func(namespace, group, dataId, data string) { content = "data" @@ -465,7 +465,7 @@ func TestListen(t *testing.T) { time.Sleep(2 * time.Second) success, err = client.PublishConfig(vo.ConfigParam{ - DataId: localConfigTest.DataId, + DataId: "ConfigNoChange", Group: localConfigTest.Group, Content: localConfigTest.Content}) From 2420d1517f8abc64b2428316cdeb361c48e46a9f Mon Sep 17 00:00:00 2001 From: sanxun0325 Date: Sat, 26 Sep 2020 21:52:30 +0800 Subject: [PATCH 13/15] fix ci --- clients/config_client/config_client_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/clients/config_client/config_client_test.go b/clients/config_client/config_client_test.go index 06d3067e..818958b7 100644 --- a/clients/config_client/config_client_test.go +++ b/clients/config_client/config_client_test.go @@ -451,6 +451,11 @@ func TestListen(t *testing.T) { var success bool var content string + success, err = client.PublishConfig(vo.ConfigParam{ + DataId: "ConfigNoChange", + Group: localConfigTest.Group, + Content: localConfigTest.Content}) + go func() { err = client.ListenConfig(vo.ConfigParam{ DataId: "ConfigNoChange", From 5a49286c2c95fab54bc52692e07e40b7fc5dad41 Mon Sep 17 00:00:00 2001 From: sanxun0325 Date: Sat, 26 Sep 2020 22:29:21 +0800 Subject: [PATCH 14/15] fix ci --- clients/config_client/config_client_test.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/clients/config_client/config_client_test.go b/clients/config_client/config_client_test.go index 818958b7..209928fc 100644 --- a/clients/config_client/config_client_test.go +++ b/clients/config_client/config_client_test.go @@ -445,17 +445,12 @@ func TestListen(t *testing.T) { // ListenConfig no change t.Run("TestListenConfigNoChange", func(t *testing.T) { client := cretateConfigClientTest() - key := util.GetConfigCacheKey(localConfigTest.DataId, localConfigTest.Group, clientConfigTest.NamespaceId) + key := util.GetConfigCacheKey("ConfigNoChange", localConfigTest.Group, clientConfigTest.NamespaceId) cache.WriteConfigToFile(key, client.configCacheDir, localConfigTest.Content) var err error var success bool var content string - success, err = client.PublishConfig(vo.ConfigParam{ - DataId: "ConfigNoChange", - Group: localConfigTest.Group, - Content: localConfigTest.Content}) - go func() { err = client.ListenConfig(vo.ConfigParam{ DataId: "ConfigNoChange", @@ -607,8 +602,6 @@ func TestCancelListenConfig(t *testing.T) { assert.Nil(t, err) assert.Equal(t, true, success) } - - assert.Equal(t, "abcd2", context) assert.Equal(t, "abcd5", context1) }) t.Run("TestCancelListenConfig", func(t *testing.T) { From 3dbdc5d371d56df5e461a0e941c975b76254f4d1 Mon Sep 17 00:00:00 2001 From: sanxun0325 Date: Sat, 26 Sep 2020 22:36:27 +0800 Subject: [PATCH 15/15] fix ci --- clients/config_client/config_client_test.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/clients/config_client/config_client_test.go b/clients/config_client/config_client_test.go index 209928fc..d7b047a0 100644 --- a/clients/config_client/config_client_test.go +++ b/clients/config_client/config_client_test.go @@ -552,13 +552,12 @@ func TestCancelListenConfig(t *testing.T) { client := cretateConfigClientTest() var err error var success bool - var context, context1 string + var context string listenConfigParam := vo.ConfigParam{ DataId: "CancelOne", Group: "group", OnChange: func(namespace, group, dataId, data string) { fmt.Println("group:" + group + ", dataId:" + dataId + ", data:" + data) - context = data }, } @@ -567,7 +566,7 @@ func TestCancelListenConfig(t *testing.T) { Group: "group1", OnChange: func(namespace, group, dataId, data string) { fmt.Println("group1:" + group + ", dataId1:" + dataId + ", data:" + data) - context1 = data + context = data }, } go func() { @@ -602,7 +601,7 @@ func TestCancelListenConfig(t *testing.T) { assert.Nil(t, err) assert.Equal(t, true, success) } - assert.Equal(t, "abcd5", context1) + assert.Equal(t, "abcd5", context) }) t.Run("TestCancelListenConfig", func(t *testing.T) { var context string