Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update dependency golangci/golangci-lint to v1.55.2 #1188

Merged
merged 5 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---
run:
skip-files:
- "mock\\.go$"
- "mock_[^/]*\\.go$"
linters:
enable-all: true
disable:
Expand All @@ -17,3 +21,4 @@ linters:
- godox
- varnamelen
- ireturn
- depguard
24 changes: 12 additions & 12 deletions aqua/aqua-checksums.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
{
"checksums": [
{
"id": "github_release/github.com/golangci/golangci-lint/v1.51.2/golangci-lint-1.51.2-darwin-amd64.tar.gz",
"checksum": "0549CBAA2DF451CF3A2011A9D73A9CB127784D26749D9CD14C9F4818AF104D44",
"id": "github_release/github.com/golangci/golangci-lint/v1.55.2/golangci-lint-1.55.2-darwin-amd64.tar.gz",
"checksum": "632E96E6D5294FBBE7B2C410A49C8FA01C60712A0AF85A567DE85BCC1623EA21",
"algorithm": "sha256"
},
{
"id": "github_release/github.com/golangci/golangci-lint/v1.51.2/golangci-lint-1.51.2-darwin-arm64.tar.gz",
"checksum": "36E69882205A0E42A63AD57EC3015639C11051E03F0BEB9CF7949C6451408960",
"id": "github_release/github.com/golangci/golangci-lint/v1.55.2/golangci-lint-1.55.2-darwin-arm64.tar.gz",
"checksum": "234463F059249F82045824AFDCDD5DB5682D0593052F58F6A3039A0A1C3899F6",
"algorithm": "sha256"
},
{
"id": "github_release/github.com/golangci/golangci-lint/v1.51.2/golangci-lint-1.51.2-linux-amd64.tar.gz",
"checksum": "4DE479EB9D9BC29DA51AEC1834E7C255B333723D38DBD56781C68E5DDDC6A90B",
"id": "github_release/github.com/golangci/golangci-lint/v1.55.2/golangci-lint-1.55.2-linux-amd64.tar.gz",
"checksum": "CA21C961A33BE3BC15E4292DC40C98C8DCC5463A7B6768A3AFC123761630C09C",
"algorithm": "sha256"
},
{
"id": "github_release/github.com/golangci/golangci-lint/v1.51.2/golangci-lint-1.51.2-linux-arm64.tar.gz",
"checksum": "9E03C47B7628D49F950445D74881A0E3CB3A1E6B3C5AC3B67672D600124C1B08",
"id": "github_release/github.com/golangci/golangci-lint/v1.55.2/golangci-lint-1.55.2-linux-arm64.tar.gz",
"checksum": "8EB0CEE9B1DBF0EAA49871798C7F8A5B35F2960C52D776A5F31EB7D886B92746",
"algorithm": "sha256"
},
{
"id": "github_release/github.com/golangci/golangci-lint/v1.51.2/golangci-lint-1.51.2-windows-amd64.zip",
"checksum": "AAC163D9BF3F79457399C2852CFAE550CD250F23DF9B324966F9C54E767FF42D",
"id": "github_release/github.com/golangci/golangci-lint/v1.55.2/golangci-lint-1.55.2-windows-amd64.zip",
"checksum": "F57D434D231D43417DFA631587522F8C1991220B43C8FFADB9C7BD279508BF81",
"algorithm": "sha256"
},
{
"id": "github_release/github.com/golangci/golangci-lint/v1.51.2/golangci-lint-1.51.2-windows-arm64.zip",
"checksum": "DA25A1202B10FCFAA5FBA02FF1D41A2D81562BEC52231F3239FFD8AF7CD3E143",
"id": "github_release/github.com/golangci/golangci-lint/v1.55.2/golangci-lint-1.55.2-windows-arm64.zip",
"checksum": "FD7DC8F4C6829EE6FAFB252A4D81D2155CD35DA7833665CBB25D53CE7CECD990",
"algorithm": "sha256"
},
{
Expand Down
2 changes: 1 addition & 1 deletion aqua/imports/golangci-lint.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
packages:
- name: golangci/golangci-lint@v1.51.2
- name: golangci/golangci-lint@v1.55.2
2 changes: 1 addition & 1 deletion pkg/api/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type CommentController struct {
Platform Platform
}

func (ctrl *CommentController) Post(ctx context.Context, cmt *github.Comment, hiddenParam map[string]interface{}) error {
func (ctrl *CommentController) Post(ctx context.Context, cmt *github.Comment) error {
if err := ctrl.GitHub.CreateComment(ctx, cmt); err != nil {
return fmt.Errorf("send a comment: %w", err)
}
Expand Down
58 changes: 58 additions & 0 deletions pkg/api/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
# skip_no_token: true
# base:
# org:
# repo:
# vars:
# foo: bar
# zoo:
# foo: hello
# templates:
# header: "# {{.Org}}/{{.Repo}}"
# post:
# default:
# template: |
# {{template "header" .}}
# {{.Vars.foo}} {{.Vars.zoo.foo}}
# {{.Org}} {{.Repo}} {{.PRNumber}} {{.SHA1}} {{.TemplateKey}}
# hello:
# template: hello
# exec:
# hello:
# - when: true
# template: |
# {{template "header" .}}
# {{.Vars.foo}} {{.Vars.zoo.foo}}
# {{.Org}} {{.Repo}} {{.PRNumber}} {{.SHA1}} {{.TemplateKey}}
# exit code: {{.ExitCode}}
#
# ```console
# $ {{.Command}}
# ```
#
# Stdout:
#
# ```
# {{.Stdout}}
# ```
#
# Stderr:
#
# ```
# {{.Stderr}}
# ```
#
# CombinedOutput:
#
# ```
# {{.CombinedOutput}}
# ```
# template_for_too_long: |
# {{template "header" .}}
# {{.Vars.foo}} {{.Vars.zoo.foo}}
# {{.Org}} {{.Repo}} {{.PRNumber}} {{.SHA1}} {{.TemplateKey}}
# exit code: {{.ExitCode}}
#
# ```console
# $ {{.Command}}
# ```
11 changes: 1 addition & 10 deletions pkg/api/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,5 @@ func (ctrl *ExecController) post(
Expr: ctrl.Expr,
Getenv: ctrl.Getenv,
}
return cmtCtrl.Post(ctx, cmt, map[string]interface{}{
"Command": map[string]interface{}{
"ExitCode": cmtParams.ExitCode,
"JoinCommand": cmtParams.JoinCommand,
"Command": cmtParams.Command,
"Stdout": cmtParams.Stdout,
"Stderr": cmtParams.Stderr,
"CombinedOutput": cmtParams.CombinedOutput,
},
})
return cmtCtrl.Post(ctx, cmt)
}
4 changes: 2 additions & 2 deletions pkg/api/exec_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ func TestExecController_getExecConfig(t *testing.T) { //nolint:funlen
t.Parallel()
execConfig, f, err := d.ctrl.getExecConfig(d.execConfigs, d.cmtParams)
if d.isErr {
require.NotNil(t, err)
require.Error(t, err)
return
}
require.Nil(t, err)
require.NoError(t, err)
require.Equal(t, d.exp, execConfig)
require.Equal(t, d.f, f)
})
Expand Down
68 changes: 6 additions & 62 deletions pkg/api/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,82 +2,26 @@ package api

import (
"context"
_ "embed"
"strings"
)

const cfgTemplate = `---
# skip_no_token: true
# base:
# org:
# repo:
# vars:
# foo: bar
# zoo:
# foo: hello
# templates:
# header: "# {{.Org}}/{{.Repo}}"
# post:
# default:
# template: |
# {{template "header" .}}
# {{.Vars.foo}} {{.Vars.zoo.foo}}
# {{.Org}} {{.Repo}} {{.PRNumber}} {{.SHA1}} {{.TemplateKey}}
# hello:
# template: hello
# exec:
# hello:
# - when: true
# template: |
# {{template "header" .}}
# {{.Vars.foo}} {{.Vars.zoo.foo}}
# {{.Org}} {{.Repo}} {{.PRNumber}} {{.SHA1}} {{.TemplateKey}}
# exit code: {{.ExitCode}}
#
# ` + "```" + `
# $ {{.Command}}
# ` + "```" + `
#
# Stdout:
#
# ` + "```" + `
# {{.Stdout}}
# ` + "```" + `
#
# Stderr:
#
# ` + "```" + `
# {{.Stderr}}
# ` + "```" + `
#
# CombinedOutput:
#
# ` + "```" + `
# {{.CombinedOutput}}
# ` + "```" + `
# template_for_too_long: |
# {{template "header" .}}
# {{.Vars.foo}} {{.Vars.zoo.foo}}
# {{.Org}} {{.Repo}} {{.PRNumber}} {{.SHA1}} {{.TemplateKey}}
# exit code: {{.ExitCode}}
#
# ` + "```" + `
# $ {{.Command}}
# ` + "```" + `
`
//go:embed config.yaml
var cfgTemplate []byte

type Fsys interface {
Exist(string) bool
Exist(path string) bool
Write(path string, content []byte) error
}

type InitController struct {
Fsys Fsys
}

func (ctrl InitController) Run(ctx context.Context) error {
func (ctrl InitController) Run(_ context.Context) error {
dst := "github-comment.yaml"
if ctrl.Fsys.Exist(dst) {
return nil
}
return ctrl.Fsys.Write(dst, []byte(strings.Trim(cfgTemplate, "\n"))) //nolint:wrapcheck
return ctrl.Fsys.Write(dst, []byte(strings.TrimSpace(string(cfgTemplate))+"\n")) //nolint:wrapcheck
}
2 changes: 1 addition & 1 deletion pkg/api/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (ctrl *PostController) Post(ctx context.Context, opts *option.PostOptions)
Expr: ctrl.Expr,
Getenv: ctrl.Getenv,
}
return cmtCtrl.Post(ctx, cmt, nil)
return cmtCtrl.Post(ctx, cmt)
}

func (ctrl *PostController) setUpdatedCommentID(ctx context.Context, cmt *github.Comment, updateCondition string) error { //nolint:funlen
Expand Down
8 changes: 4 additions & 4 deletions pkg/api/post_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ func TestPostController_getCommentParams(t *testing.T) { //nolint:funlen
t.Parallel()
cmt, err := d.ctrl.getCommentParams(ctx, d.opts)
if d.isErr {
require.NotNil(t, err)
require.Error(t, err)
return
}
require.Nil(t, err)
require.NoError(t, err)
cmt.Body = ""
cmt.BodyForTooLong = ""
require.Equal(t, d.exp, cmt)
Expand Down Expand Up @@ -237,10 +237,10 @@ func TestPostController_readTemplateFromStdin(t *testing.T) {
t.Parallel()
tpl, err := d.ctrl.readTemplateFromStdin()
if d.isErr {
require.NotNil(t, err)
require.Error(t, err)
return
}
require.Nil(t, err)
require.NoError(t, err)
require.Equal(t, d.exp, tpl)
})
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/expr/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ type Expr struct{}
func (*Expr) Match(expression string, params interface{}) (bool, error) {
prog, err := expr.Compile(expression, expr.Env(params), expr.AsBool())
if err != nil {
return false, fmt.Errorf("compile an expression: "+expression+": %w", err)
return false, fmt.Errorf("compile an expression: %s: %w", expression, err)
}
output, err := expr.Run(prog, params)
if err != nil {
return false, fmt.Errorf("evaluate an expression with params: "+expression+": %w", err)
return false, fmt.Errorf("evaluate an expression with params: %s: %w", expression, err)
}
if f, ok := output.(bool); !ok || !f {
return false, nil
Expand Down