From dca65fca3b44377efc85ee786b60e4df4bc5caf8 Mon Sep 17 00:00:00 2001 From: Maksim Konovalov Date: Mon, 26 Aug 2024 19:58:23 +0300 Subject: [PATCH 1/2] init/linter: add linter to github workflow jobs --- .github/workflows/main.yml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c77e49c..c4dc5ac 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,4 +28,25 @@ jobs: uses: codecov/codecov-action@v4.0.1 with: token: ${{ secrets.CODECOV_TOKEN }} - slug: KaymeKaydex/go-vshard-router \ No newline at end of file + slug: KaymeKaydex/go-vshard-router + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v2 + + - uses: actions/checkout@v2 + + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + continue-on-error: true + with: + # The first run is for GitHub Actions error format. + args: --config=.golangci.yaml + + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + # The second run is for human-readable error format with a file name + # and a line number. + args: --out-${NO_FUTURE}format colored-line-number --config=.golangci.yaml \ No newline at end of file From 0933a4ec0aa7dd2d05287783ecaafca156dbf0a0 Mon Sep 17 00:00:00 2001 From: Maksim Konovalov Date: Mon, 26 Aug 2024 19:58:23 +0300 Subject: [PATCH 2/2] init/linter: add linter to github workflow jobs and fix lint for provider --- .github/workflows/main.yml | 23 ++++++++++++++++++++++- CHANGELOG.md | 2 ++ providers/static/provider_test.go | 3 ++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c77e49c..c4dc5ac 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,4 +28,25 @@ jobs: uses: codecov/codecov-action@v4.0.1 with: token: ${{ secrets.CODECOV_TOKEN }} - slug: KaymeKaydex/go-vshard-router \ No newline at end of file + slug: KaymeKaydex/go-vshard-router + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v2 + + - uses: actions/checkout@v2 + + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + continue-on-error: true + with: + # The first run is for GitHub Actions error format. + args: --config=.golangci.yaml + + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + # The second run is for human-readable error format with a file name + # and a line number. + args: --out-${NO_FUTURE}format colored-line-number --config=.golangci.yaml \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index ddd66c7..2204454 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,12 +12,14 @@ FEATURES: * Added etcd v2 topology provider implementation (#16) * Add TopologyController mock for testing improve +* Add linter job (#33) REFACTOR: * Refactored docs (add QuickStart doc) and that library base on vhsard router * Several linters are enabled because they are usefull * Ignore .tmp files +* Refactored provider creation test caused by golang-ci lint (#33) diff --git a/providers/static/provider_test.go b/providers/static/provider_test.go index 06ffe37..bd8ae4a 100644 --- a/providers/static/provider_test.go +++ b/providers/static/provider_test.go @@ -26,7 +26,8 @@ func TestNewProvider(t *testing.T) { for _, tc := range tCases { t.Run("provider", func(t *testing.T) { - if tc.Source == nil || len(tc.Source) == 0 { + if len(tc.Source) == 0 { + require.Panics(t, func() { NewProvider(tc.Source) })