diff --git a/Gopkg.lock b/Gopkg.lock index d3680b9..09c5758 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -128,6 +128,12 @@ packages = ["."] revision = "a61a99592b77c9ba629d254a693acffaeb4b7e28" +[[projects]] + name = "github.com/stvp/rollbar" + packages = ["."] + revision = "b20261800d8cda3be14dcef0d1a8320779bba61a" + version = "v0.5.1" + [[projects]] name = "github.com/ulikunitz/xz" packages = [ @@ -180,6 +186,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "c52cf21009f65e59e23de87241a797c6c48d7e018aafc1f37edf1f9403ba9387" + inputs-digest = "66f216da55122e2bdeccb44d15182200ff48bee768ba3ab20b617c7a06af102d" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index b468c86..6b25cf6 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -33,3 +33,7 @@ [[constraint]] branch = "master" name = "golang.org/x/oauth2" + +[[constraint]] + name = "github.com/stvp/rollbar" + version = "0.5.1" diff --git a/cmd/version-scraper/main.go b/cmd/version-scraper/main.go index c030c4c..fa0cdc6 100644 --- a/cmd/version-scraper/main.go +++ b/cmd/version-scraper/main.go @@ -7,6 +7,7 @@ import ( "github.com/garyburd/redigo/redis" "github.com/google/go-github/github" "github.com/heroku/herald" + "github.com/stvp/rollbar" "golang.org/x/oauth2" "log" "os" @@ -15,6 +16,7 @@ import ( // GithubToken is Personal GitHub token. TODO: Create a bot account. var GithubToken = os.Getenv("GITHUB_TOKEN") +var RollbarToken = os.Getenv("ROLLBAR_ACCESS_TOKEN") // Opens an issue on GitHub for the given buildpack and new target. // @@ -57,6 +59,10 @@ func main() { // Redis stuff. Redis := herald.NewRedis("") + // Rollbar stuff. + rollbar.Token = RollbarToken + rollbar.Environment = "production" + // Color Stuff. color.NoColor = false @@ -96,7 +102,10 @@ func main() { exe.EnsureExecutable() // Execute the executable, print the results. - results := exe.Execute() + results, err := exe.Execute() + if err != nil { + rollbar.Error(rollbar.ERR, err) + } for _, result := range results { key := fmt.Sprintf("%s:%s:%s", bp, exe, result) @@ -104,6 +113,9 @@ func main() { // Store the results in Redis. result, err := Redis.Connection.Do("SETNX", key, value) + if err != nil { + rollbar.Error(rollbar.ERR, err) + } // The insert was successful (e.g. it didn't exist already) if result.(int64) != int64(0) { @@ -116,7 +128,9 @@ func main() { if !success { // If writing out the issue was unsuccessful, delete the key from Redis. _, err := Redis.Connection.Do("DEL", key) - _ = err + if err != nil { + rollbar.Error(rollbar.ERR, err) + } } } else { fmt.Println("New target, skipping GitHub notifications.") @@ -125,6 +139,7 @@ func main() { } if err != nil { + rollbar.Error(rollbar.ERR, err) log.Fatal(err) } diff --git a/herald.go b/herald.go index 4604c64..f5dad40 100644 --- a/herald.go +++ b/herald.go @@ -148,13 +148,13 @@ func (e Executable) EnsureExecutable() { } // Execute Executes the given executable, and returns results. -func (e Executable) Execute() []string { +func (e Executable) Execute() ([]string, error) { out, err := exec.Command(e.Path).Output() if err != nil { // TODO: Update this to return, etc. log.Fatal(err) } - return strings.Split(strings.Trim(string(out), "\n"), "\n") + return strings.Split(strings.Trim(string(out), "\n"), "\n"), err }