Skip to content

Commit 55db07d

Browse files
authored
Merge pull request #1703 from go-redis/feature/workflow
Replace travis with workflows
2 parents 1b77706 + 02a9c81 commit 55db07d

File tree

19 files changed

+109
-127
lines changed

19 files changed

+109
-127
lines changed

.github/workflows/build.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Go
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
build:
11+
name: build
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
go-version: [1.15.x, 1.16.x]
16+
17+
services:
18+
redis:
19+
image: redis
20+
options: >-
21+
--health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
22+
ports:
23+
- 6379:6379
24+
25+
steps:
26+
- name: Set up ${{ matrix.go-version }}
27+
uses: actions/setup-go@v2
28+
with:
29+
go-version: ${{ matrix.go-version }}
30+
31+
- name: Checkout code
32+
uses: actions/checkout@v2
33+
34+
- name: Test
35+
run: make test

.github/workflows/go.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.

.github/workflows/golangci-lint.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: golangci-lint
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
branches:
8+
- master
9+
- main
10+
pull_request:
11+
12+
jobs:
13+
golangci:
14+
name: lint
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: golangci-lint
19+
uses: golangci/golangci-lint-action@v2

.golangci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ linters:
2222
- exhaustivestruct
2323
- wrapcheck
2424
- errorlint
25+
- cyclop
26+
- forcetypeassert

.travis.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
all: testdeps
1+
test: testdeps
22
go test ./...
33
go test ./... -short -race
44
go test ./... -run=NONE -bench=. -benchmem
55
env GOOS=linux GOARCH=386 go test ./...
66
go vet
7-
golangci-lint run
87

98
testdeps: testdata/redis/src/redis-server
109

@@ -15,7 +14,7 @@ bench: testdeps
1514

1615
testdata/redis:
1716
mkdir -p $@
18-
wget -qO- https://download.redis.io/releases/redis-6.2-rc3.tar.gz | tar xvz --strip-components=1 -C $@
17+
wget -qO- https://download.redis.io/releases/redis-6.2.1.tar.gz | tar xvz --strip-components=1 -C $@
1918

2019
testdata/redis/src/redis-server: testdata/redis
2120
cd $< && make all

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# Redis client for Golang
88

9-
[![Build Status](https://travis-ci.org/go-redis/redis.png?branch=master)](https://travis-ci.org/go-redis/redis)
9+
![build workflow](https://github.com/go-redis/redis/actions/workflows/build.yml/badge.svg)
1010
[![PkgGoDev](https://pkg.go.dev/badge/github.com/go-redis/redis/v8)](https://pkg.go.dev/github.com/go-redis/redis/v8?tab=doc)
1111
[![Documentation](https://img.shields.io/badge/redis-documentation-informational)](https://redis.uptrace.dev/)
1212
[![Chat](https://discordapp.com/api/guilds/752070105847955518/widget.png)](https://discord.gg/rWtp5Aj)

cluster.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,9 @@ func (c *clusterNodes) Close() error {
295295

296296
func (c *clusterNodes) Addrs() ([]string, error) {
297297
var addrs []string
298+
298299
c.mu.RLock()
299-
closed := c.closed
300+
closed := c.closed //nolint:ifshort
300301
if !closed {
301302
if len(c.activeAddrs) > 0 {
302303
addrs = c.activeAddrs
@@ -649,14 +650,15 @@ func (c *clusterStateHolder) LazyReload() {
649650

650651
func (c *clusterStateHolder) Get(ctx context.Context) (*clusterState, error) {
651652
v := c.state.Load()
652-
if v != nil {
653-
state := v.(*clusterState)
654-
if time.Since(state.createdAt) > 10*time.Second {
655-
c.LazyReload()
656-
}
657-
return state, nil
653+
if v == nil {
654+
return c.Reload(ctx)
658655
}
659-
return c.Reload(ctx)
656+
657+
state := v.(*clusterState)
658+
if time.Since(state.createdAt) > 10*time.Second {
659+
c.LazyReload()
660+
}
661+
return state, nil
660662
}
661663

662664
func (c *clusterStateHolder) ReloadOrGet(ctx context.Context) (*clusterState, error) {

commands.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,12 +1989,10 @@ func (c cmdable) ZIncrBy(ctx context.Context, key string, increment float64, mem
19891989
}
19901990

19911991
func (c cmdable) ZInterStore(ctx context.Context, destination string, store *ZStore) *IntCmd {
1992-
args := make([]interface{}, 3+len(store.Keys))
1993-
args[0] = "zinterstore"
1994-
args[1] = destination
1995-
args[2] = len(store.Keys)
1996-
for i, key := range store.Keys {
1997-
args[3+i] = key
1992+
args := make([]interface{}, 0, 3+len(store.Keys))
1993+
args = append(args, "zinterstore", destination, len(store.Keys))
1994+
for _, key := range store.Keys {
1995+
args = append(args, key)
19981996
}
19991997
if len(store.Weights) > 0 {
20001998
args = append(args, "weights")
@@ -2237,12 +2235,10 @@ func (c cmdable) ZScore(ctx context.Context, key, member string) *FloatCmd {
22372235
}
22382236

22392237
func (c cmdable) ZUnionStore(ctx context.Context, dest string, store *ZStore) *IntCmd {
2240-
args := make([]interface{}, 3+len(store.Keys))
2241-
args[0] = "zunionstore"
2242-
args[1] = dest
2243-
args[2] = len(store.Keys)
2244-
for i, key := range store.Keys {
2245-
args[3+i] = key
2238+
args := make([]interface{}, 0, 3+len(store.Keys))
2239+
args = append(args, "zunionstore", dest, len(store.Keys))
2240+
for _, key := range store.Keys {
2241+
args = append(args, key)
22462242
}
22472243
if len(store.Weights) > 0 {
22482244
args = append(args, "weights")

extra/redisotel/go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ replace github.com/go-redis/redis/extra/rediscmd => ../rediscmd
88

99
require (
1010
github.com/go-redis/redis/extra/rediscmd v0.2.0
11-
github.com/go-redis/redis/v8 v8.5.0
12-
go.opentelemetry.io/otel v0.17.0
13-
go.opentelemetry.io/otel/trace v0.17.0
11+
github.com/go-redis/redis/v8 v8.7.1
12+
go.opentelemetry.io/otel v0.19.0
13+
go.opentelemetry.io/otel/trace v0.19.0
1414
)

0 commit comments

Comments
 (0)