diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 837a793..6ecddeb 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,16 +1,32 @@ name: Test -on: [push, pull_request] +on: + push: + branches: + - main + pull_request: +permissions: + contents: read jobs: test: runs-on: ubuntu-latest steps: - - name: Set up Go - uses: actions/setup-go@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 with: - go-version: 1.21 - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - name: Get dependencies - run: go mod download - - name: Test - run: go test -v -race ./... + go-version-file: "./go.mod" + - run: go test -v -race ./... + lint: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version-file: "./go.mod" + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + # Require: The version of golangci-lint to use. + # When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version. + # When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit. + version: v1.54 diff --git a/backend.go b/backend.go index 01b6ee3..768690b 100644 --- a/backend.go +++ b/backend.go @@ -97,14 +97,6 @@ func (b *Backend) AddMatchFunction(profile *pb.MatchProfile, mmf MatchFunction) func (b *Backend) Start(ctx context.Context, tickRate time.Duration) error { ticker := time.NewTicker(tickRate) defer ticker.Stop() - - b.mmfMu.RLock() - mmfs := b.mmfs - b.mmfMu.RUnlock() - profiles := make([]string, 0, len(mmfs)) - for profile := range mmfs { - profiles = append(profiles, profile.Name) - } for { select { case <-ctx.Done(): diff --git a/filter.go b/filter.go index f65ed8b..5c69009 100644 --- a/filter.go +++ b/filter.go @@ -72,7 +72,6 @@ func (pf *poolFilter) In(entity filteredEntity) bool { return false } } - } else { } } diff --git a/pkg/statestore/redis.go b/pkg/statestore/redis.go index 2da06df..933f4e9 100644 --- a/pkg/statestore/redis.go +++ b/pkg/statestore/redis.go @@ -356,6 +356,7 @@ func (s *RedisStore) deIndexTickets(ticketIDs []string) []rueidis.Completed { } } +//nolint:unused func (s *RedisStore) releaseTimeoutTicketsByNow(ctx context.Context) error { return s.releaseTimeoutTickets(ctx, time.Now().Add(-s.opts.pendingReleaseTimeout)) } diff --git a/pkg/statestore/ticketcache_test.go b/pkg/statestore/ticketcache_test.go index 658369b..fc2a6b0 100644 --- a/pkg/statestore/ticketcache_test.go +++ b/pkg/statestore/ticketcache_test.go @@ -33,6 +33,6 @@ func TestTicketCache(t *testing.T) { time.Sleep(ttl + 10*time.Millisecond) - t1, err = store.GetTicket(ctx, "t1") + _, err = store.GetTicket(ctx, "t1") require.Error(t, err, ErrTicketNotFound) } diff --git a/tests/intergration_test.go b/tests/intergration_test.go index 7a22033..ae25f88 100644 --- a/tests/intergration_test.go +++ b/tests/intergration_test.go @@ -54,20 +54,20 @@ func TestFrontend(t *testing.T) { c := s.DialFrontend(t) ctx := context.Background() - resp, err := c.GetTicket(ctx, &pb.GetTicketRequest{TicketId: "invalid"}) + _, err := c.GetTicket(ctx, &pb.GetTicketRequest{TicketId: "invalid"}) require.Error(t, err) requireErrorCode(t, err, codes.NotFound) t1 := mustCreateTicket(ctx, t, c, &pb.Ticket{}) - resp, err = c.GetTicket(ctx, &pb.GetTicketRequest{TicketId: t1.Id}) + resp, err := c.GetTicket(ctx, &pb.GetTicketRequest{TicketId: t1.Id}) require.NoError(t, err) require.Equal(t, resp.Id, t1.Id) _, err = c.DeleteTicket(ctx, &pb.DeleteTicketRequest{TicketId: t1.Id}) require.NoError(t, err) - resp, err = c.GetTicket(ctx, &pb.GetTicketRequest{TicketId: t1.Id}) + _, err = c.GetTicket(ctx, &pb.GetTicketRequest{TicketId: t1.Id}) requireErrorCode(t, err, codes.NotFound) }