Skip to content

Commit

Permalink
ci: move to github actions from travis
Browse files Browse the repository at this point in the history
* change ci service to github actions
* update golangci-lint version
* update linters-rules
  • Loading branch information
Shivam010 committed Jan 17, 2021
1 parent 85dc0dc commit 4a9c631
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 51 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: code-analysis
on: [push, pull_request]

jobs:
golangci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.35
skip-go-installation: true

staticcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: check
uses: grandcolline/[email protected]
with:
run: staticcheck
token: ${{ secrets.GITHUB_TOKEN }}
37 changes: 37 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: test
on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
go_version: [ 1.13, 1.14, 1.15 ]

services:
redis-rejson:
image: redislabs/rejson
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379

steps:
- name: set up go ${{ matrix.go_version }}
uses: actions/[email protected]
with:
go-version: ${{ matrix.go_version }}
id: go
- uses: actions/checkout@v2
- name: go test
run: |
go test -race -v -covermode=atomic -coverprofile=profile.cov ./...
- name: send coverage to Coveralls
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
GO111MODULE=off go get -u github.com/mattn/goveralls
$(go env GOPATH)/bin/goveralls -coverprofile=profile.cov -service=github
28 changes: 20 additions & 8 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ linters-settings:
golint:
min-confidence: 0
gocyclo:
min-complexity: 15
min-complexity: 25
maligned:
suggest-new: true
goconst:
Expand All @@ -16,15 +16,27 @@ linters-settings:
line-length: 120

linters:
enable-all: true
disable:
- goimports
- scopelint
- gochecknoglobals
- dupl
- unparam
enable:
- lll
- gofmt
- gosec
- govet
- golint
- gocyclo
- goconst
- misspell
- maligned
- errcheck
- deadcode
- unconvert
- megacheck
- staticcheck
- gochecknoinits

run:
skip-dirs:
- vendor

issues:
exclude:
- 'shadow: declaration of "(err|ctx)" shadows declaration at'
33 changes: 0 additions & 33 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions clients/goredis.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (r *GoRedis) JSONGet(key, path string, opts ...rjs.GetOption) (res interfac
func (r *GoRedis) JSONMGet(path string, keys ...string) (res interface{}, err error) {

if len(keys) == 0 {
return nil, rjs.ErrNeedAtleastOneArg
return nil, rjs.ErrNeedAtLeastOneArg
}
args := make([]interface{}, 0)
for _, key := range keys {
Expand Down Expand Up @@ -243,7 +243,7 @@ func (r *GoRedis) JSONStrLen(key, path string) (res interface{}, err error) {
func (r *GoRedis) JSONArrAppend(key, path string, values ...interface{}) (res interface{}, err error) {

if len(values) == 0 {
return nil, rjs.ErrNeedAtleastOneArg
return nil, rjs.ErrNeedAtLeastOneArg
}
args := make([]interface{}, 0)
args = append(args, key, path)
Expand Down Expand Up @@ -342,7 +342,7 @@ func (r *GoRedis) JSONArrTrim(key, path string, start, end int) (res interface{}
func (r *GoRedis) JSONArrInsert(key, path string, index int, values ...interface{}) (res interface{}, err error) {

if len(values) == 0 {
return nil, rjs.ErrNeedAtleastOneArg
return nil, rjs.ErrNeedAtLeastOneArg
}
args := make([]interface{}, 0)
args = append(args, key, path, index)
Expand Down
6 changes: 3 additions & 3 deletions clients/redigo.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (r *Redigo) JSONGet(key, path string, opts ...rjs.GetOption) (res interface
func (r *Redigo) JSONMGet(path string, keys ...string) (res interface{}, err error) {

if len(keys) == 0 {
return nil, rjs.ErrNeedAtleastOneArg
return nil, rjs.ErrNeedAtLeastOneArg
}
args := make([]interface{}, 0)
for _, key := range keys {
Expand Down Expand Up @@ -182,7 +182,7 @@ func (r *Redigo) JSONStrLen(key, path string) (res interface{}, err error) {
func (r *Redigo) JSONArrAppend(key, path string, values ...interface{}) (res interface{}, err error) {

if len(values) == 0 {
return nil, rjs.ErrNeedAtleastOneArg
return nil, rjs.ErrNeedAtLeastOneArg
}
args := make([]interface{}, 0)
args = append(args, key, path)
Expand Down Expand Up @@ -271,7 +271,7 @@ func (r *Redigo) JSONArrTrim(key, path string, start, end int) (res interface{},
func (r *Redigo) JSONArrInsert(key, path string, index int, values ...interface{}) (res interface{}, err error) {

if len(values) == 0 {
return nil, rjs.ErrNeedAtleastOneArg
return nil, rjs.ErrNeedAtLeastOneArg
}
args := make([]interface{}, 0)
args = append(args, key, path, index)
Expand Down
1 change: 0 additions & 1 deletion rejson_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ func TestUnsupportedCommand(t *testing.T) {
_, _, err := rjs.CommandBuilder(1234, nil)
if err == nil {
t.Errorf("TestUnsupportedCommand() returned nil error")
return
}
}

Expand Down
1 change: 0 additions & 1 deletion rjs/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ func commandJSONDebug(argsIn ...interface{}) (argsOut []interface{}, err error)
func CommandBuilder(commandNameIn ReJSONCommandID, argsIn ...interface{}) (commandNameOut string, argsOut []interface{}, err error) { // nolint: lll

cmd, commandNameOut, err := commandNameIn.Details()

if err != nil {
return
}
Expand Down
2 changes: 1 addition & 1 deletion rjs/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var (
ErrInternal = fmt.Errorf("error: internal client error")
ErrNoClientSet = fmt.Errorf("no redis client is set")
ErrTooManyOptionals = fmt.Errorf("error: too many optional arguments")
ErrNeedAtleastOneArg = fmt.Errorf("error: need atleast one argument in varing field")
ErrNeedAtLeastOneArg = fmt.Errorf("error: need atleast one argument in varying field")

// GoRedis specific Nil error
ErrGoRedisNil = fmt.Errorf("redis: nil")
Expand Down
2 changes: 1 addition & 1 deletion set_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (r *Handler) SetRedigoClient(conn redigo.Conn) {
// SetGoRedisClient sets Go-Redis (https://github.com/go-redis/redis) client to
// the handler. It is left for backward compatibility.
func (r *Handler) SetGoRedisClient(conn *goredis.Client) {
r.SetGoRedisClientWithContext(nil, conn)
r.SetGoRedisClientWithContext(context.TODO(), conn)
}

// SetGoRedisClientWithContext sets Go-Redis (https://github.com/go-redis/redis) client to
Expand Down

0 comments on commit 4a9c631

Please sign in to comment.