Skip to content

Commit

Permalink
chore(ci): update dependencies (gin-gonic#2827)
Browse files Browse the repository at this point in the history
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Matthieu MOREL <mmorel-35@users.noreply.github.com>
  • Loading branch information
2 people authored and daheige committed Apr 18, 2022
1 parent fa20891 commit 9624093
Show file tree
Hide file tree
Showing 18 changed files with 411 additions and 143 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
- package-ecosystem: gomod
directory: /
schedule:
interval: weekly
41 changes: 31 additions & 10 deletions .github/workflows/gin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,31 @@ on:
- master

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: '^1.16'
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.41.1
args: --verbose
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
go: [1.13, 1.14, 1.15, 1.16]
test-tags: ['', nomsgpack]
include:
- os: ubuntu-latest
go-build: ~/.cache/go-build
- os: macos-latest
go-build: ~/Library/Caches/go-build
name: ${{ matrix.os }} @ Go ${{ matrix.go }} ${{ matrix.test-tags }}
runs-on: ${{ matrix.os }}
env:
Expand All @@ -31,21 +50,23 @@ jobs:
uses: actions/checkout@v2
with:
ref: ${{ github.ref }}

- name: Install Dependencies
run: make tools

- name: Run Check
run: |
make vet
make fmt-check
make misspell-check
- uses: actions/cache@v2
with:
path: |
${{ matrix.go-build }}
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run Tests
run: make test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v2
with:
flags: ${{ matrix.os }},go-${{ matrix.go }},${{ matrix.test-tags }}
notification-gitter:
needs: test
runs-on: ubuntu-latest
Expand Down
23 changes: 23 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
linters:
enable:
- gofmt
- misspell
- revive
issues:
exclude-rules:
- linters:
- deadcode
text: "`static` is unused"
- linters:
- structcheck
- unused
text: "`data` is unused"
- linters:
- staticcheck
text: "SA1019:"
- linters:
- revive
text: "var-naming:"
- linters:
- revive
text: "exported:"
3 changes: 1 addition & 2 deletions binding/binding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"time"

"github.com/gin-gonic/gin/testdata/protoexample"
"github.com/golang/protobuf/proto"
"github.com/stretchr/testify/assert"
"google.golang.org/protobuf/proto"
)

type appkey struct {
Expand Down Expand Up @@ -832,7 +832,6 @@ func testFormBindingEmbeddedStruct(t *testing.T, method, path, badPath, body, ba
assert.Equal(t, 1, obj.Page)
assert.Equal(t, 2, obj.Size)
assert.Equal(t, "test-appkey", obj.Appkey)

}

func testFormBinding(t *testing.T, method, path, badPath, body, badBody string) {
Expand Down
5 changes: 2 additions & 3 deletions binding/form_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var (
ErrConvertToMapString = errors.New("can not convert to map of strings")
)

func mapUri(ptr interface{}, m map[string][]string) error {
func mapURI(ptr interface{}, m map[string][]string) error {
return mapFormByTag(ptr, m, "uri")
}

Expand Down Expand Up @@ -84,7 +84,7 @@ func mapping(value reflect.Value, field reflect.StructField, setter setter, tag
return false, nil
}

var vKind = value.Kind()
vKind := value.Kind()

if vKind == reflect.Ptr {
var isNew bool
Expand Down Expand Up @@ -311,7 +311,6 @@ func setTimeField(val string, structField reflect.StructField, value reflect.Val
t := time.Unix(tv/int64(d), tv%int64(d))
value.Set(reflect.ValueOf(t))
return nil

}

if val == "" {
Expand Down
2 changes: 1 addition & 1 deletion binding/form_mapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func TestMappingURI(t *testing.T) {
var s struct {
F int `uri:"field"`
}
err := mapUri(&s, map[string][]string{"field": {"6"}})
err := mapURI(&s, map[string][]string{"field": {"6"}})
assert.NoError(t, err)
assert.Equal(t, int(6), s.F)
}
Expand Down
2 changes: 1 addition & 1 deletion binding/protobuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"io/ioutil"
"net/http"

"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"
)

type protobufBinding struct{}
Expand Down
2 changes: 1 addition & 1 deletion binding/uri.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func (uriBinding) Name() string {
}

func (uriBinding) BindUri(m map[string][]string, obj interface{}) error {
if err := mapUri(obj, m); err != nil {
if err := mapURI(obj, m); err != nil {
return err
}
return validate(obj)
Expand Down
24 changes: 11 additions & 13 deletions context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (

"github.com/gin-contrib/sse"
"github.com/gin-gonic/gin/binding"
"github.com/golang/protobuf/proto"
"github.com/stretchr/testify/assert"
"google.golang.org/protobuf/proto"

testdata "github.com/gin-gonic/gin/testdata/protoexample"
)
Expand Down Expand Up @@ -234,7 +234,6 @@ func TestContextSetGetValues(t *testing.T) {
assert.Exactly(t, c.MustGet("float32").(float32), float32(4.2))
assert.Exactly(t, c.MustGet("float64").(float64), 4.2)
assert.Exactly(t, c.MustGet("intInterface").(int), 1)

}

func TestContextGetString(t *testing.T) {
Expand Down Expand Up @@ -300,7 +299,7 @@ func TestContextGetStringSlice(t *testing.T) {

func TestContextGetStringMap(t *testing.T) {
c, _ := CreateTestContext(httptest.NewRecorder())
var m = make(map[string]interface{})
m := make(map[string]interface{})
m["foo"] = 1
c.Set("map", m)

Expand All @@ -310,7 +309,7 @@ func TestContextGetStringMap(t *testing.T) {

func TestContextGetStringMapString(t *testing.T) {
c, _ := CreateTestContext(httptest.NewRecorder())
var m = make(map[string]string)
m := make(map[string]string)
m["foo"] = "bar"
c.Set("map", m)

Expand All @@ -320,7 +319,7 @@ func TestContextGetStringMapString(t *testing.T) {

func TestContextGetStringMapStringSlice(t *testing.T) {
c, _ := CreateTestContext(httptest.NewRecorder())
var m = make(map[string][]string)
m := make(map[string][]string)
m["foo"] = []string{"foo"}
c.Set("map", m)

Expand Down Expand Up @@ -369,15 +368,12 @@ func TestContextHandlerNames(t *testing.T) {
}

func handlerNameTest(c *Context) {

}

func handlerNameTest2(c *Context) {

}

var handlerTest HandlerFunc = func(c *Context) {

}

func TestContextHandler(t *testing.T) {
Expand Down Expand Up @@ -659,8 +655,7 @@ func TestContextBodyAllowedForStatus(t *testing.T) {
assert.True(t, true, bodyAllowedForStatus(http.StatusInternalServerError))
}

type TestPanicRender struct {
}
type TestPanicRender struct{}

func (*TestPanicRender) Render(http.ResponseWriter) error {
return errors.New("TestPanicRender")
Expand Down Expand Up @@ -1329,7 +1324,7 @@ func TestContextAbortWithStatusJSON(t *testing.T) {
_, err := buf.ReadFrom(w.Body)
assert.NoError(t, err)
jsonStringBody := buf.String()
assert.Equal(t, fmt.Sprint("{\"foo\":\"fooValue\",\"bar\":\"barValue\"}"), jsonStringBody)
assert.Equal(t, "{\"foo\":\"fooValue\",\"bar\":\"barValue\"}", jsonStringBody)
}

func TestContextError(t *testing.T) {
Expand Down Expand Up @@ -1545,6 +1540,7 @@ func TestContextBindWithJSON(t *testing.T) {
assert.Equal(t, "bar", obj.Foo)
assert.Equal(t, 0, w.Body.Len())
}

func TestContextBindWithXML(t *testing.T) {
w := httptest.NewRecorder()
c, _ := CreateTestContext(w)
Expand Down Expand Up @@ -2100,6 +2096,8 @@ func TestContextWithFallbackErrFromRequestContext(t *testing.T) {
assert.EqualError(t, c2.Err(), context.Canceled.Error())
}

type contextKey string

func TestContextWithFallbackValueFromRequestContext(t *testing.T) {
tests := []struct {
name string
Expand All @@ -2122,8 +2120,8 @@ func TestContextWithFallbackValueFromRequestContext(t *testing.T) {
getContextAndKey: func() (*Context, interface{}) {
c := &Context{}
c.Request, _ = http.NewRequest("POST", "/", nil)
c.Request = c.Request.WithContext(context.WithValue(context.TODO(), "key", "value"))
return c, "key"
c.Request = c.Request.WithContext(context.WithValue(context.TODO(), contextKey("key"), "value"))
return c, contextKey("key")
},
value: "value",
},
Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ go 1.13

require (
github.com/gin-contrib/sse v0.1.0
github.com/go-playground/validator/v10 v10.6.1
github.com/goccy/go-json v0.5.1
github.com/golang/protobuf v1.3.3
github.com/json-iterator/go v1.1.9
github.com/mattn/go-isatty v0.0.12
github.com/stretchr/testify v1.4.0
github.com/go-playground/validator/v10 v10.9.0
github.com/goccy/go-json v0.7.6
github.com/json-iterator/go v1.1.11
github.com/mattn/go-isatty v0.0.13
github.com/stretchr/testify v1.7.0
github.com/ugorji/go/codec v1.2.6
gopkg.in/yaml.v2 v2.2.8
google.golang.org/protobuf v1.27.1
gopkg.in/yaml.v2 v2.4.0
)

0 comments on commit 9624093

Please sign in to comment.