From 1250777a7265d9df98dc2623e7178abe33cdf4b0 Mon Sep 17 00:00:00 2001 From: ysugimoto Date: Sun, 28 Apr 2024 02:05:35 +0900 Subject: [PATCH] use github actions, update go and golangci-lint version --- .github/workflows/build.yml | 40 +++++++++++++++++++++++ .golangci.yml | 5 --- graphql/graphql.pb.go | 4 +-- protoc-gen-graphql/generator/generator.go | 2 +- protoc-gen-graphql/spec/enum.go | 2 +- protoc-gen-graphql/spec/file.go | 10 +++--- protoc-gen-graphql/spec/message.go | 2 +- protoc-gen-graphql/spec/mutation.go | 1 - protoc-gen-graphql/spec/params.go | 2 +- protoc-gen-graphql/spec/service.go | 2 +- 10 files changed, 52 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..69af6e8 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,40 @@ +name: Build application + +on: + push: {} + +env: + PROTOC_VERSION: 3.14.0 + GO_VERSION: 1.21.1 + +jobs: + build: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup go + uses: actions/setup-go@v4 + with: + go-version: ${{ env.GO_VERSION }} + - name: Setup protobuf + run: | + PROTOC_ZIP=protoc-${{ env.PROTOC_VERSION }}-linux-x86_64.zip + curl -OL https://github.com/google/protobuf/releases/download/v${{ env.PROTOC_VERSION }}/$PROTOC_ZIP + sudo unzip -o $PROTOC_ZIP -d /usr/local/protoc + sudo chmod +xr -R /usr/local/protoc + sudo ln -s /usr/local/protoc/bin/protoc /usr/local/bin + sudo ln -s /usr/local/protoc/include/google /usr/local/include/google + go get -u github.com/golang/protobuf/protoc-gen-go + - name: Lint programs + uses: golangci/golangci-lint-action@v3 + with: + version: v1.54 + skip-pkg-cache: true + skip-build-cache: true + skip-go-installation: true + - name: Build app + run: make all tag=ci + + diff --git a/.golangci.yml b/.golangci.yml index fde4c23..a9e59aa 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -26,11 +26,7 @@ linters: - staticcheck - unused - gosimple - - structcheck - - varcheck - ineffassign - - interfacer - - deadcode - dogsled - dupl - funlen @@ -41,7 +37,6 @@ linters: - gofmt - gomnd - lll - - maligned - misspell - whitespace - unparam diff --git a/graphql/graphql.pb.go b/graphql/graphql.pb.go index 943032e..6d22913 100644 --- a/graphql/graphql.pb.go +++ b/graphql/graphql.pb.go @@ -7,8 +7,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 -// protoc v3.17.3 +// protoc-gen-go v1.27.1 +// protoc v3.21.12 // source: graphql.proto package graphql diff --git a/protoc-gen-graphql/generator/generator.go b/protoc-gen-graphql/generator/generator.go index 9464a97..b9fe70b 100644 --- a/protoc-gen-graphql/generator/generator.go +++ b/protoc-gen-graphql/generator/generator.go @@ -247,7 +247,7 @@ func (g *Generator) generateFile(file *spec.File, tmpl string, services []*spec. out, err := format.Source(buf.Bytes()) if err != nil { - ioutil.WriteFile("/tmp/"+root.Name+".go", buf.Bytes(), 0666) // nolint: errcheck + ioutil.WriteFile("/tmp/"+root.Name+".go", buf.Bytes(), 0o666) // nolint: gomnd,errcheck return nil, err } diff --git a/protoc-gen-graphql/spec/enum.go b/protoc-gen-graphql/spec/enum.go index a359ff7..15c1873 100644 --- a/protoc-gen-graphql/spec/enum.go +++ b/protoc-gen-graphql/spec/enum.go @@ -37,7 +37,7 @@ func NewEnum( for i, v := range d.GetValue() { ps := make([]int, len(paths)) copy(ps, paths) - e.values = append(e.values, NewEnumValue(v, f, append(ps, 2, i)...)) + e.values = append(e.values, NewEnumValue(v, f, append(ps, 2, i)...)) // nolint: gomnd } return e } diff --git a/protoc-gen-graphql/spec/file.go b/protoc-gen-graphql/spec/file.go index bc093aa..be628f4 100644 --- a/protoc-gen-graphql/spec/file.go +++ b/protoc-gen-graphql/spec/file.go @@ -42,13 +42,13 @@ func NewFile( isCamel: isCamel, } for i, s := range d.GetService() { - f.services = append(f.services, NewService(s, f, 6, i)) + f.services = append(f.services, NewService(s, f, 6, i)) // nolint: gomnd } for i, m := range d.GetMessageType() { - f.messages = append(f.messages, f.messagesRecursive(m, []string{}, 4, i)...) + f.messages = append(f.messages, f.messagesRecursive(m, []string{}, 4, i)...) // nolint: gomnd } for i, e := range d.GetEnumType() { - f.enums = append(f.enums, NewEnum(e, f, []string{}, 5, i)) + f.enums = append(f.enums, NewEnum(e, f, []string{}, 5, i)) // nolint: gomnd } return f } @@ -80,7 +80,7 @@ func (f *File) messagesRecursive(d *descriptor.DescriptorProto, prefix []string, for i, e := range d.GetEnumType() { p := make([]int, len(paths)) copy(p, paths) - f.enums = append(f.enums, NewEnum(e, f, prefix, append(p, 5, i)...)) + f.enums = append(f.enums, NewEnum(e, f, prefix, append(p, 5, i)...)) // nolint: gomnd } for i, m := range d.GetNestedType() { @@ -88,7 +88,7 @@ func (f *File) messagesRecursive(d *descriptor.DescriptorProto, prefix []string, copy(p, paths) messages = append( messages, - f.messagesRecursive(m, prefix, append(p, 3, i)...)..., + f.messagesRecursive(m, prefix, append(p, 3, i)...)..., // nolint: gomnd ) } return messages diff --git a/protoc-gen-graphql/spec/message.go b/protoc-gen-graphql/spec/message.go index b4cbbd4..65795d6 100644 --- a/protoc-gen-graphql/spec/message.go +++ b/protoc-gen-graphql/spec/message.go @@ -41,7 +41,7 @@ func NewMessage( for i, field := range d.GetField() { ps := make([]int, len(paths)) copy(ps, paths) - ff := NewField(field, f, isCamel, append(ps, 2, i)...) + ff := NewField(field, f, isCamel, append(ps, 2, i)...) // nolint: gomnd if !ff.IsOmit() { m.fields = append(m.fields, ff) } diff --git a/protoc-gen-graphql/spec/mutation.go b/protoc-gen-graphql/spec/mutation.go index cdfce74..fa69dd0 100644 --- a/protoc-gen-graphql/spec/mutation.go +++ b/protoc-gen-graphql/spec/mutation.go @@ -159,7 +159,6 @@ func (m *Mutation) OutputName() string { return typeName } -// func (m *Mutation) InputType() string { if m.Method.GoPackage() != m.Input.GoPackage() { return m.Input.StructName(false) diff --git a/protoc-gen-graphql/spec/params.go b/protoc-gen-graphql/spec/params.go index 5fb89e0..fd99c34 100644 --- a/protoc-gen-graphql/spec/params.go +++ b/protoc-gen-graphql/spec/params.go @@ -29,7 +29,7 @@ func NewParams(p string) (*Params, error) { } for _, v := range strings.Split(p, ",") { - kv := strings.SplitN(v, "=", 2) + kv := strings.SplitN(v, "=", 2) // nolint: gomnd switch kv[0] { case "verbose": params.Verbose = true diff --git a/protoc-gen-graphql/spec/service.go b/protoc-gen-graphql/spec/service.go index 5a3e577..a54b89d 100644 --- a/protoc-gen-graphql/spec/service.go +++ b/protoc-gen-graphql/spec/service.go @@ -47,7 +47,7 @@ func NewService( for i, m := range d.GetMethod() { ps := make([]int, len(paths)) copy(ps, paths) - s.methods = append(s.methods, NewMethod(m, s, append(ps, 4, i)...)) + s.methods = append(s.methods, NewMethod(m, s, append(ps, 4, i)...)) // nolint: gomnd } return s }