Skip to content

Commit

Permalink
Merge pull request #156 from rerost/rerost/set-linter
Browse files Browse the repository at this point in the history
Setup golangci-lint
  • Loading branch information
rerost authored Aug 29, 2024
2 parents 8a38db1 + 66ad729 commit a841dfb
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 8 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,15 @@ jobs:
- uses: actions/checkout@v4
- name: Check Renovate config
run: npx --yes --package renovate -- renovate-config-validator --strict
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.60
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
linters:
disable:
- errcheck

7 changes: 5 additions & 2 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,13 @@ func NewConfig() (Config, error) {
pflag.StringP("check-before-create-issue", "", "", "")

viper.AutomaticEnv()
viper.BindPFlags(pflag.CommandLine)
err := viper.BindPFlags(pflag.CommandLine)
if err != nil {
return Config{}, errors.WithStack(err)
}

var cfg Config
pflag.Parse()
err := viper.Unmarshal(&cfg)
err = viper.Unmarshal(&cfg)
return cfg, errors.WithStack(err)
}
2 changes: 1 addition & 1 deletion cmd/schedule/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func NewApplyCommand(ctx context.Context, templateFilePath string, srv schedule.
RunE: func(_ *cobra.Command, args []string) error {
b, err := os.ReadFile(templateFilePath)
if err != nil {
errors.WithStack(err)
return errors.WithStack(err)
}

templateFile := string(b)
Expand Down
2 changes: 1 addition & 1 deletion cmd/schedule/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func NewRenderCommand(ctx context.Context, templateFilePath string, srv schedule
zap.L().Debug("template path", zap.String("templateFilePath", templateFilePath))
b, err := os.ReadFile(templateFilePath)
if err != nil {
errors.WithStack(err)
return errors.WithStack(err)
}

templateFile := string(b)
Expand Down
9 changes: 6 additions & 3 deletions domain/issue/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ func (is *issueServiceImpl) render(ctx context.Context, templateIssueURL string)
if err != nil {
return types.Issue{}, errors.Wrap(err, "Failed to render title")
}
title := string(tw.Bytes())
title := tw.String()

bw := bytes.NewBufferString("")
err = bodyTmpl.Execute(bw, TemplateData{CurrentTime: is.ct, LastIssue: lastIssue, AddDay: func(d int) time.Time { return is.ct.AddDate(0, 0, d) }})
if err != nil {
return types.Issue{}, errors.Wrap(err, "Failed to render body")
}
body := string(bw.Bytes())
body := bw.String()

if lastIssue.URL == nil {
return types.Issue{}, errors.New("Invalid last issue passed(empty URL)")
Expand Down Expand Up @@ -126,7 +126,10 @@ func (is *issueServiceImpl) Create(ctx context.Context, templateURL string) (typ
if err != nil {
return types.Issue{}, errors.WithStack(err)
}
f.Chmod(0755)
err = f.Chmod(0755)
if err != nil {
return types.Issue{}, errors.WithStack(err)
}
f.Close()

out, err := exec.Command("sh", f.Name()).Output()
Expand Down
1 change: 0 additions & 1 deletion repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ func (ir *issueRepositoryImpl) FindLastIssue(ctx context.Context, templateIssue
var (
// State
closed = "closed"
open = "open"
)

func (ir *issueRepositoryImpl) CloseByURL(ctx context.Context, issueURL string) error {
Expand Down

0 comments on commit a841dfb

Please sign in to comment.