Skip to content

Commit

Permalink
Merge pull request #14 from castaneai/linter-on-ci
Browse files Browse the repository at this point in the history
add linter job
  • Loading branch information
castaneai authored Dec 25, 2023
2 parents 62548a6 + 166de10 commit 2b2d81b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 23 deletions.
36 changes: 26 additions & 10 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 0 additions & 8 deletions backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
1 change: 0 additions & 1 deletion filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ func (pf *poolFilter) In(entity filteredEntity) bool {
return false
}
}
} else {
}
}

Expand Down
1 change: 1 addition & 0 deletions pkg/statestore/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/statestore/ticketcache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
6 changes: 3 additions & 3 deletions tests/intergration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 2b2d81b

Please sign in to comment.