1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Another actions test (#889)

* Another actions test

Signed-off-by: Chris Cummer <chriscummer@me.com>

* Add BuildTest action

Signed-off-by: Chris Cummer <chriscummer@me.com>

* Remove lint check for the time being (so many issues)

Signed-off-by: Chris Cummer <chriscummer@me.com>

* Fix issues found by errcheck

Signed-off-by: Chris Cummer <chriscummer@me.com>

* Fix errors found by staticcheck

Signed-off-by: Chris Cummer <chriscummer@me.com>

* Fix issues found by goimports

Signed-off-by: Chris Cummer <chriscummer@me.com>

* Comment out the  action for the time being

Signed-off-by: Chris Cummer <chriscummer@me.com>

* Fix shadowed variables

Signed-off-by: Chris Cummer <chriscummer@me.com>

* go mod tidy

Signed-off-by: Chris Cummer <chriscummer@me.com>

* Remove buildtest.yml

Signed-off-by: Chris Cummer <chriscummer@me.com>

* go mod tidy

Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
Chris Cummer
2020-05-09 12:51:08 -07:00
committed by GitHub
parent 0384258032
commit f0ca3b8a58
31 changed files with 155 additions and 94 deletions

View File

@@ -1,10 +1,11 @@
package buildkite
import (
"os"
"github.com/olebedev/config"
"github.com/wtfutil/wtf/cfg"
"github.com/wtfutil/wtf/utils"
"os"
)
const (

View File

@@ -2,6 +2,7 @@ package buildkite
import (
"fmt"
"github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
)

View File

@@ -85,21 +85,3 @@ func (widget *Widget) displayStatus() string {
}
return content
}
func getStatusColor(status string) string {
switch status {
case sdk.StatusSuccess:
return "green"
case sdk.StatusBuilding, sdk.StatusWaiting:
return "blue"
case sdk.StatusFail:
return "red"
case sdk.StatusStopped:
return "red"
case sdk.StatusSkipped:
return "grey"
case sdk.StatusDisabled:
return "grey"
}
return "red"
}

View File

@@ -128,8 +128,8 @@ func runCommandLoop(widget *Widget) {
// The command has exited, print any error messages
if err != nil {
widget.m.Lock()
_, err := widget.buffer.WriteString(err.Error())
if err != nil {
_, writeErr := widget.buffer.WriteString(err.Error())
if writeErr != nil {
return
}
widget.m.Unlock()

View File

@@ -60,8 +60,8 @@ func (widget *Widget) Fetch() ([]*CalEvent, error) {
calendarIDs, err := widget.getCalendarIdList(srv)
for _, calendarID := range calendarIDs {
calendarEvents, err := srv.Events.List(calendarID).TimeZone(timezone).ShowDeleted(false).TimeMin(startTime).MaxResults(eventLimit).SingleEvents(true).OrderBy("startTime").Do()
if err != nil {
calendarEvents, listErr := srv.Events.List(calendarID).TimeZone(timezone).ShowDeleted(false).TimeMin(startTime).MaxResults(eventLimit).SingleEvents(true).OrderBy("startTime").Do()
if listErr != nil {
break
}
events.Items = append(events.Items, calendarEvents.Items...)

View File

@@ -43,7 +43,7 @@ func (widget *Widget) content() (string, string, bool) {
timestamp = ""
}
title := fmt.Sprintf("[%s]%s",
title = fmt.Sprintf("[%s]%s",
widget.titleColor(calEvent),
widget.eventSummary(calEvent, calEvent.ConflictsWith(calEvents)),
)

View File

@@ -12,10 +12,9 @@ import (
const (
pullRequestsPath = "/pulls"
issuesPath = "/issues"
issuesPath = "/issues"
)
// GithubRepo defines a new GithubRepo structure
type GithubRepo struct {
apiKey string

View File

@@ -19,12 +19,12 @@ func newContext(settings *Settings) (*context, error) {
return nil, err
}
context := context{
ctx := &context{
client: gitlabClient,
user: user,
}
return &context, nil
return ctx, nil
}
type GitlabProject struct {

View File

@@ -125,8 +125,10 @@ func (widget *Widget) markAsDone() {
sel := widget.GetSelected()
if sel >= 0 && widget.todos != nil && sel < len(widget.todos) {
todo := widget.todos[sel]
widget.gitlabClient.Todos.MarkTodoAsDone(todo.ID)
widget.Refresh()
_, err := widget.gitlabClient.Todos.MarkTodoAsDone(todo.ID)
if err == nil {
widget.Refresh()
}
}
}

View File

@@ -16,7 +16,6 @@ import (
"os"
"os/user"
"path/filepath"
"strings"
"github.com/wtfutil/wtf/utils"
"golang.org/x/oauth2"
@@ -39,29 +38,25 @@ func (widget *Widget) Fetch() ([]*sheets.ValueRange, error) {
}
config, err := google.ConfigFromJSON(b, "https://www.googleapis.com/auth/spreadsheets.readonly")
if err != nil {
log.Fatalf("Unable to get config from JSON. %v", err)
return nil, err
}
client := getClient(ctx, config)
srv, err := sheets.NewService(context.Background(), option.WithHTTPClient(client))
if err != nil {
log.Fatalf("Unable to get create server. %v", err)
return nil, err
}
cells := utils.ToStrs(widget.settings.cellAddresses)
addresses := strings.Join(cells[:], ";")
responses := make([]*sheets.ValueRange, len(cells))
for i := 0; i < len(cells); i++ {
resp, err := srv.Spreadsheets.Values.Get(widget.settings.sheetID, cells[i]).Do()
if err != nil {
log.Fatalf("Error fetching cells %s", addresses)
return nil, err
resp, getErr := srv.Spreadsheets.Values.Get(widget.settings.sheetID, cells[i]).Do()
if getErr != nil {
return nil, getErr
}
responses[i] = resp
}

View File

@@ -128,7 +128,7 @@ func getMyIP() (ip net.IP, v6 bool) {
if err != nil {
return
}
defer conn.Close()
defer func() { _ = conn.Close() }()
addr := conn.LocalAddr().(*net.TCPAddr)
ip = addr.IP

View File

@@ -45,7 +45,7 @@ func (widget *Widget) Create(jenkinsURL string, username string, apiKey string)
return view, err
}
respJobs := make([]Job, 0, len(view.Jobs) + len(view.ActiveConfigurations))
respJobs := make([]Job, 0, len(view.Jobs)+len(view.ActiveConfigurations))
respJobs = append(append(respJobs, view.Jobs...), view.ActiveConfigurations...)
jobs := make([]Job, 0)

View File

@@ -1,9 +1,9 @@
package jenkins
type View struct {
Description string `json:"description"`
Jobs []Job `json:"jobs"`
ActiveConfigurations []Job `json:"activeConfigurations"`
Name string `json:"name"`
Url string `json:"url"`
Description string `json:"description"`
Jobs []Job `json:"jobs"`
ActiveConfigurations []Job `json:"activeConfigurations"`
Name string `json:"name"`
Url string `json:"url"`
}

View File

@@ -2,10 +2,11 @@ package jenkins
import (
"fmt"
"net/url"
"github.com/rivo/tview"
"github.com/wtfutil/wtf/utils"
"github.com/wtfutil/wtf/view"
"net/url"
)
type Widget struct {

View File

@@ -12,7 +12,7 @@ type Issue struct {
type IssueFields struct {
Summary string `json:"summary"`
IssueType *IssueType `json:"issuetype"`
IssueType *IssueType `json:"issuetype"`
IssueStatus *IssueStatus `json:"status"`
}
@@ -26,7 +26,7 @@ type IssueType struct {
}
type IssueStatus struct {
ISelf string `json:"self"`
IDescription string `json:"description"`
IName string `json:"name"`
ISelf string `json:"self"`
IDescription string `json:"description"`
IName string `json:"name"`
}

View File

@@ -59,7 +59,7 @@ func getStatus(c http.Client, apiURL string) (status Status, err error) {
}
defer func() {
if err := resp.Body.Close(); err != nil {
if closeErr := resp.Body.Close(); closeErr != nil {
return
}
}()
@@ -72,7 +72,7 @@ func getStatus(c http.Client, apiURL string) (status Status, err error) {
var rBody []byte
if rBody, err = ioutil.ReadAll(resp.Body); err != nil {
return status, fmt.Errorf(" failed to read status response\n")
return status, fmt.Errorf(" failed to read status response")
}
if err = json.Unmarshal(rBody, &status); err != nil {
@@ -120,7 +120,7 @@ func getTopItems(c http.Client, settings *Settings) (ti TopItems, err error) {
}
defer func() {
if err := resp.Body.Close(); err != nil {
if closeErr := resp.Body.Close(); closeErr != nil {
return
}
}()
@@ -186,7 +186,7 @@ func getTopClients(c http.Client, settings *Settings) (tc TopClients, err error)
}
defer func() {
if err := resp.Body.Close(); err != nil {
if closeErr := resp.Body.Close(); closeErr != nil {
return
}
}()
@@ -220,13 +220,13 @@ func getQueryTypes(c http.Client, settings *Settings) (qt QueryTypes, err error)
var url *url2.URL
if url, err = url2.Parse(settings.apiUrl); err != nil {
return qt, fmt.Errorf(" failed to parse API URL\n %s\n", parseError(err))
return qt, fmt.Errorf(" failed to parse API URL\n %s", parseError(err))
}
var query url2.Values
if query, err = url2.ParseQuery(url.RawQuery); err != nil {
return qt, fmt.Errorf(" failed to parse query\n %s\n", parseError(err))
return qt, fmt.Errorf(" failed to parse query\n %s", parseError(err))
}
query.Add("getQueryTypes", strconv.Itoa(settings.showTopClients))
@@ -245,7 +245,7 @@ func getQueryTypes(c http.Client, settings *Settings) (qt QueryTypes, err error)
}
defer func() {
if err := resp.Body.Close(); err != nil {
if closeErr := resp.Body.Close(); closeErr != nil {
return
}
}()
@@ -285,7 +285,7 @@ func checkServer(c http.Client, apiURL string) error {
if req, err = http.NewRequest("GET", fmt.Sprintf("%s?version",
url.String()), nil); err != nil {
return fmt.Errorf("invalid request: %s\n", parseError(err))
return fmt.Errorf("invalid request: %s", parseError(err))
}
var resp *http.Response

View File

@@ -1,8 +1,9 @@
package spacex
import (
"github.com/wtfutil/wtf/utils"
"net/http"
"github.com/wtfutil/wtf/utils"
)
const (

View File

@@ -2,17 +2,17 @@ package spacex
import (
"fmt"
"time"
"github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
"github.com/wtfutil/wtf/wtf"
"time"
)
type Widget struct {
view.TextWidget
settings *Settings
err error
launch Launch
}
func NewWidget(app *tview.Application, settings *Settings) *Widget {

View File

@@ -170,12 +170,13 @@ func (widget *Widget) HelpText() string {
}
func (w *Widget) createOutput() (string, string, bool) {
err := w.refreshSpotifyInfos()
var output string
err := w.refreshSpotifyInfos()
if err != nil {
output = err.Error()
} else {
output := utils.CenterText(fmt.Sprintf("[green]Now %v [white]\n", w.Info.Status), w.CommonSettings().Width)
output += utils.CenterText(fmt.Sprintf("[green]Now %v [white]\n", w.Info.Status), w.CommonSettings().Width)
output += utils.CenterText(fmt.Sprintf("[green]Title:[white] %v\n", w.Info.Title), w.CommonSettings().Width)
output += utils.CenterText(fmt.Sprintf("[green]Artist:[white] %v\n", w.Info.Artists), w.CommonSettings().Width)
output += utils.CenterText(fmt.Sprintf("[green]Album:[white] %v\n", w.Info.Album), w.CommonSettings().Width)

View File

@@ -44,16 +44,16 @@ func (widget *Widget) Refresh() {
widget.links = nil
widget.SetItemCount(0)
} else {
if len(links) <= widget.settings.numberOfPosts {
widget.links = links
widget.SetItemCount(len(widget.links))
widget.err = nil
} else {
widget.links = links[:widget.settings.numberOfPosts]
widget.SetItemCount(len(widget.links))
widget.err = nil
}
}
if len(links) <= widget.settings.numberOfPosts {
widget.links = links
widget.SetItemCount(len(widget.links))
widget.err = nil
} else {
widget.links = links[:widget.settings.numberOfPosts]
widget.SetItemCount(len(widget.links))
widget.err = nil
}
}
widget.Render()
}

View File

@@ -2,6 +2,7 @@ package twitch
import (
"fmt"
"github.com/nicklaw5/helix"
)

View File

@@ -1,10 +1,11 @@
package twitch
import (
"os"
"github.com/olebedev/config"
"github.com/wtfutil/wtf/cfg"
"github.com/wtfutil/wtf/utils"
"os"
)
const (

View File

@@ -3,6 +3,7 @@ package twitch
import (
"errors"
"fmt"
"github.com/nicklaw5/helix"
"github.com/rivo/tview"
"github.com/wtfutil/wtf/utils"

View File

@@ -2,6 +2,7 @@ package arpansagovau
import (
"fmt"
"github.com/rivo/tview"
"github.com/wtfutil/wtf/view"
)