Skip to content

Commit

Permalink
Merge pull request #31 from zendesk/gurney/AddReportCardTravis
Browse files Browse the repository at this point in the history
Add golangci-lint
  • Loading branch information
ragurney authored Oct 1, 2019
2 parents 5fffa6a + 3fea702 commit 2129217
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 14 deletions.
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,15 @@ go:
env:
- GO111MODULE=on

jobs:
include:
- stage: "Code Quality"
before_script:
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.19.1
- go mod download
script: golangci-lint run
- stage: "Test"
script: "make"

branches:
only: master
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Term Check [![Build Status](https://travis-ci.org/zendesk/term-check.svg?branch=master)](https://travis-ci.org/zendesk/term-check) [![Go Report Card](https://goreportcard.com/badge/github.com/zendesk/term-check)](https://goreportcard.com/report/github.com/zendesk/term-check) [![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/github.com/zendesk/term-check)
# Term Check [![Build Status](https://travis-ci.org/zendesk/term-check.svg?branch=master)](https://travis-ci.org/zendesk/term-check) [![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/github.com/zendesk/term-check) [![GolangCI](https://golangci.com/badges/github.com/golangci/golangci-lint.svg)](https://golangci.com)

This bot is for our Inclusive Language initiative inside Zendesk Engineering.

Expand Down
6 changes: 1 addition & 5 deletions internal/bot/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ var (
type Bot struct {
client *gh.Client
server *gh.Server
privateKeyPath string
webhookSecretKey string
appID int
termList []string
checkName string
Expand Down Expand Up @@ -178,8 +176,6 @@ func (b *Bot) HandleEvent(event interface{}) {
default:
log.Debug().Msgf("Unhandled event received: %s. Discarding...", reflect.TypeOf(event).Elem().Name())
}

return
}

func (b *Bot) createCheckRun(ctx context.Context, pr *github.PullRequest, r *github.Repository, ghc *github.Client) {
Expand All @@ -197,7 +193,7 @@ func (b *Bot) createCheckRun(ctx context.Context, pr *github.PullRequest, r *git
HeadBranch: pr.GetHead().GetRef(),
HeadSHA: headSHA,
Status: github.String("completed"),
CompletedAt: &github.Timestamp{time.Now()},
CompletedAt: &github.Timestamp{Time: time.Now()},
Output: &github.CheckRunOutput{
Title: github.String(b.checkName),
Text: github.String(b.checkDetails),
Expand Down
24 changes: 17 additions & 7 deletions internal/config/config.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// Package config provides objects containing configuration for specific parts of the applicaiton.
// Package config provides objects containing configuration for specific parts of the application.
// It also encapsulates the logic needed to read the configuration from the environment.
package config

import (
"context"
"errors"
"gopkg.in/yaml.v2"
"io/ioutil"
"net/http"

"gopkg.in/yaml.v2"

"github.com/google/go-github/v18/github"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
Expand Down Expand Up @@ -48,7 +49,7 @@ type RepoConfig struct {
Ignore []string `yaml:"ignore"`
}

// Config holds all config values for the applicaiton, separated by module
// Config holds all config values for the application, separated by module
type Config struct {
ForBot *BotConfig
ForClient *ClientConfig
Expand Down Expand Up @@ -117,7 +118,10 @@ func GetRepoConfig(ctx context.Context, repo *github.Repository, head string, cl

// Store empty configuration if error or file is not there
if err == nil && resp.StatusCode == http.StatusOK {
yaml.Unmarshal([]byte(rawConfig), &config)
err = yaml.Unmarshal([]byte(rawConfig), &config)
if err != nil {
panic(err)
}
}

return &config
Expand All @@ -133,7 +137,10 @@ func (c *Config) getBotConfig(config []byte) (*BotConfig, error) {
}

d := driver{}
yaml.Unmarshal(config, &d)
err := yaml.Unmarshal(config, &d)
if err != nil {
panic(err)
}
bc := d.B

if len(bc.TermList) == 0 {
Expand All @@ -149,7 +156,10 @@ func (c *Config) getClientConfig(config []byte) (*ClientConfig, error) {
}

d := driver{}
yaml.Unmarshal(config, &d)
err := yaml.Unmarshal(config, &d)
if err != nil {
panic(err)
}
cc := d.C

return &cc, nil
Expand All @@ -158,7 +168,7 @@ func (c *Config) getClientConfig(config []byte) (*ClientConfig, error) {
func (c *Config) getServerConfig(config []byte) (*ServerConfig, error) {
ws, ok := c.secretHash["WEBHOOK_SECRET_KEY"]

if ok != true {
if !ok {
return &ServerConfig{}, errors.New("WEBHOOK_SECRET_KEY not present in secrets hash")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/github/client.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package GitHub provides both a server and a client that can be used to interact with the GitHub API
// Package github provides both a server and a client that can be used to interact with the GitHub API
package github

import (
Expand Down

0 comments on commit 2129217

Please sign in to comment.