Skip to content

Commit

Permalink
use github actions, update go and golangci-lint version
Browse files Browse the repository at this point in the history
  • Loading branch information
ysugimoto committed Apr 27, 2024
1 parent bdd179e commit 1250777
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 18 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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


5 changes: 0 additions & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ linters:
- staticcheck
- unused
- gosimple
- structcheck
- varcheck
- ineffassign
- interfacer
- deadcode
- dogsled
- dupl
- funlen
Expand All @@ -41,7 +37,6 @@ linters:
- gofmt
- gomnd
- lll
- maligned
- misspell
- whitespace
- unparam
Expand Down
4 changes: 2 additions & 2 deletions graphql/graphql.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion protoc-gen-graphql/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion protoc-gen-graphql/spec/enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 5 additions & 5 deletions protoc-gen-graphql/spec/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -80,15 +80,15 @@ 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() {
p := make([]int, len(paths))
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
Expand Down
2 changes: 1 addition & 1 deletion protoc-gen-graphql/spec/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 0 additions & 1 deletion protoc-gen-graphql/spec/mutation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion protoc-gen-graphql/spec/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion protoc-gen-graphql/spec/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 1250777

Please sign in to comment.