Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: setup golangci-lint #50

Merged
merged 11 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,32 @@ jobs:
/tmp/cc-test-reporter after-build \
--id ${{ secrets.CC_TEST_REPORTER_ID }} \
--prefix "github.com/six78/2-story-points-cli" \
--exit-code $?
--exit-code $?

golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.20'

- name: Install dependencies
run: |
go install go.uber.org/mock/mockgen@latest

- name: Generate
run: make generate

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.56.2

permissions:
contents: read # Required: allow read access to the content for analysis.
pull-requests: read # Optional: allow read access to pull request. Use with `only-new-issues` option.
checks: write
10 changes: 10 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
linters:
disable-all: true
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
- testifylint
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ generate:
@go generate ./...

test: generate
@gotestsum
@gotestsum

lint:
golangci-lint run ./...
3 changes: 1 addition & 2 deletions internal/testcommon/matchers/message_matcher.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package matchers

import (
"fmt"
"github.com/six78/2-story-points-cli/pkg/protocol"
"testing"
)
Expand Down Expand Up @@ -35,5 +34,5 @@ func (m *MessageMatcher) Matches(x interface{}) bool {
}

func (m *MessageMatcher) String() string {
return fmt.Sprintf("is protocol message")
return "is protocol message"
}
3 changes: 1 addition & 2 deletions internal/testcommon/matchers/online_matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package matchers

import (
"encoding/json"
"fmt"
"github.com/six78/2-story-points-cli/internal/config"
"github.com/six78/2-story-points-cli/pkg/protocol"
"go.uber.org/zap"
Expand Down Expand Up @@ -48,7 +47,7 @@ func (m *OnlineMatcher) Matches(x interface{}) bool {
}

func (m *OnlineMatcher) String() string {
return fmt.Sprintf("is user online protocol message")
return "is user online protocol message"
}

func (m *OnlineMatcher) Wait() protocol.PlayerOnlineMessage {
Expand Down
3 changes: 1 addition & 2 deletions internal/testcommon/matchers/state_matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package matchers

import (
"encoding/json"
"fmt"
"github.com/six78/2-story-points-cli/pkg/protocol"
"testing"
)
Expand Down Expand Up @@ -49,7 +48,7 @@ func (m *StateMatcher) Matches(x interface{}) bool {
}

func (m *StateMatcher) String() string {
return fmt.Sprintf("is state message matching custom condition")
return "is state message matching custom condition"
}

func (m *StateMatcher) State() protocol.State {
Expand Down
3 changes: 1 addition & 2 deletions internal/testcommon/matchers/vote_matcher.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package matchers

import (
"fmt"
"github.com/six78/2-story-points-cli/pkg/protocol"
)

Expand Down Expand Up @@ -41,5 +40,5 @@ func (m *VoteMatcher) Matches(x interface{}) bool {
}

func (m *VoteMatcher) String() string {
return fmt.Sprintf("is any state message")
return "is any state message"
}
8 changes: 4 additions & 4 deletions pkg/game/game_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (s *Suite) TestStateSize() {
s.Require().NoError(err)

fmt.Println("state size", "bytes", len(stateMessage))
s.Require().True(len(stateMessage) < 100*1024, "state size should be less than 100 kilobytes")
s.Require().Less(len(stateMessage), 100*1024, "state size should be less than 100 kilobytes")
}

func (s *Suite) TestSimpleGame() {
Expand Down Expand Up @@ -194,7 +194,7 @@ func (s *Suite) TestSimpleGame() {
state = stateMatcher.Wait()
item := checkIssues(state.Issues)
s.Require().Nil(item.Result)
s.Require().Len(item.Votes, 0)
s.Require().Empty(item.Votes)
s.Logger.Info("match on deal first item")
}

Expand Down Expand Up @@ -263,7 +263,7 @@ func (s *Suite) TestSimpleGame() {
state = stateMatcher.Wait()
item := checkIssues(state.Issues)
s.Require().NotNil(item.Result)
s.Require().Equal(*item.Result, votingResult)
s.Require().Equal(votingResult, *item.Result)
s.Require().Len(item.Votes, 1)

vote, ok := item.Votes[s.dealer.Player().ID]
Expand Down Expand Up @@ -301,7 +301,7 @@ func (s *Suite) TestSimpleGame() {
state = stateMatcher.Wait()
item := checkIssues(state.Issues)
s.Require().Nil(item.Result)
s.Require().Len(item.Votes, 0)
s.Require().Empty(item.Votes)
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/game/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import (
)

func TestOptions(t *testing.T) {
ctx := context.WithValue(context.Background(), gofakeit.LetterN(3), gofakeit.LetterN(3))
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
transport := &mocktransport.MockService{}
storage := &mockstorage.MockService{}
logger := zap.NewNop()
Expand Down Expand Up @@ -72,7 +73,6 @@ func TestNoClock(t *testing.T) {

func TestNoContext(t *testing.T) {
options := []Option{
WithContext(nil),
WithTransport(&mocktransport.MockService{}),
WithClock(clockwork.NewFakeClock()),
}
Expand Down
Loading