Skip to content

Commit 9f2c2ac

Browse files
committed
fix build.yml
1 parent 09c95c7 commit 9f2c2ac

File tree

11 files changed

+41
-40
lines changed

11 files changed

+41
-40
lines changed

.github/workflows/build.yml

+13-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
name: Build Go binaries
77

88
on:
9-
push:
10-
paths-ignore:
11-
- 'docs/release.svg'
12-
- 'README.md'
13-
- 'CHANGELOG.md'
9+
push:
10+
paths-ignore:
11+
- 'docs/screenshot.png'
12+
- 'README.md'
13+
- 'CHANGELOG.md'
14+
- 'LICENSE'
15+
- 'Dockerfile'
1416

1517
jobs:
1618
build:
@@ -25,3 +27,9 @@ jobs:
2527
SRCPATH: ./cmd/go-up
2628
with:
2729
args: darwin/amd64/1 darwin/arm64/1 linux/amd64 linux/386 linux/arm64 linux/arm7 linux/arm6 linux/arm5 windows/amd64/1 windows/386/1 freebsd/amd64/1
30+
31+
- name: Upload Artifacts
32+
uses: actions/upload-artifact@v4
33+
with:
34+
name: go-up
35+
path: ./release/go-up_*

go.mod

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ go 1.23
55
require (
66
github.com/gizak/termui/v3 v3.1.0
77
github.com/spf13/cobra v1.8.1
8+
github.com/spf13/viper v1.19.0
9+
gorm.io/driver/sqlite v1.5.6
10+
gorm.io/gorm v1.25.12
811
)
912

1013
require (
@@ -20,7 +23,6 @@ require (
2023
github.com/sourcegraph/conc v0.3.0 // indirect
2124
github.com/spf13/afero v1.11.0 // indirect
2225
github.com/spf13/cast v1.6.0 // indirect
23-
github.com/spf13/viper v1.19.0 // indirect
2426
github.com/subosito/gotenv v1.6.0 // indirect
2527
go.uber.org/atomic v1.9.0 // indirect
2628
go.uber.org/multierr v1.9.0 // indirect
@@ -29,14 +31,12 @@ require (
2931
golang.org/x/text v0.14.0 // indirect
3032
gopkg.in/ini.v1 v1.67.0 // indirect
3133
gopkg.in/yaml.v3 v3.0.1 // indirect
32-
gorm.io/driver/sqlite v1.5.6 // indirect
33-
gorm.io/gorm v1.25.12 // indirect
3434
)
3535

3636
require (
3737
github.com/inconshreveable/mousetrap v1.1.0 // indirect
3838
github.com/mattn/go-runewidth v0.0.15 // indirect
39-
github.com/mattn/go-sqlite3 v1.14.24
39+
github.com/mattn/go-sqlite3 v1.14.24 // indirect
4040
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect
4141
github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d // indirect
4242
github.com/rivo/uniseg v0.4.7 // indirect

go.sum

+17
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
22
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
33
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
5+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
6+
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
7+
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
48
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
59
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
610
github.com/gizak/termui/v3 v3.1.0 h1:ZZmVDgwHl7gR7elfKf1xc4IudXZ5qqfDh4wExk4Iajc=
711
github.com/gizak/termui/v3 v3.1.0/go.mod h1:bXQEBkJpzxUAKf0+xq9MSWAvWZlE7c+aidmyFlkYTrY=
12+
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
13+
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
814
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
915
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
1016
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
@@ -13,6 +19,10 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD
1319
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
1420
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
1521
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
22+
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
23+
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
24+
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
25+
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
1626
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
1727
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
1828
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
@@ -29,9 +39,13 @@ github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d/go.mod h1:IuKpRQcYE
2939
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
3040
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
3141
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
42+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
43+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
3244
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
3345
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
3446
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
47+
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
48+
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
3549
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
3650
github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ=
3751
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
@@ -57,6 +71,7 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
5771
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
5872
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
5973
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
74+
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
6075
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
6176
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
6277
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
@@ -71,6 +86,8 @@ golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
7186
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
7287
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
7388
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
89+
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
90+
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
7491
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
7592
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
7693
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

internal/daemon/service.go

-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/watzon/go-up/internal/types"
1212
)
1313

14-
// Service represents the RPC service that will handle requests
1514
type Service struct {
1615
db *database.DB
1716
}
@@ -20,7 +19,6 @@ func NewService(db *database.DB) *Service {
2019
return &Service{db: db}
2120
}
2221

23-
// ListMonitors handles the RPC call to list monitors
2422
func (s *Service) ListMonitors(_ struct{}, reply *[]types.Monitor) error {
2523
monitors, err := s.db.ListMonitors()
2624
if err != nil {
@@ -37,7 +35,6 @@ func (s *Service) AddMonitor(args struct{ Name, URL string }, reply *string) err
3735
return err
3836
}
3937

40-
// Fetch initial stats immediately
4138
responseTime, isUp, certExpiry := checkService(args.URL)
4239
if err := s.db.AddStats(args.Name, int(responseTime.Milliseconds()), isUp, certExpiry); err != nil {
4340
log.Printf("Warning: Failed to fetch initial stats for %s: %v", args.Name, err)

internal/database/database.go

-6
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,15 @@ func (db *DB) GetStats(monitorName string, duration time.Duration) (types.Servic
108108
return status, err
109109
}
110110

111-
// Create a separate struct for aggregated stats
112111
var stats struct {
113112
AvgResponseTime float64
114113
Uptime24h float64
115114
Uptime30d float64
116115
}
117116

118-
// Get averages and uptimes
119117
dayAgo := time.Now().AddDate(0, 0, -1)
120118
monthAgo := time.Now().AddDate(0, 0, -30)
121119

122-
// Calculate average response time
123120
err := db.Model(&Check{}).
124121
Where("monitor_id = ? AND timestamp >= ?", monitor.ID, monthAgo).
125122
Select("COALESCE(AVG(response_time), 0) as avg_response_time").
@@ -129,7 +126,6 @@ func (db *DB) GetStats(monitorName string, duration time.Duration) (types.Servic
129126
return status, err
130127
}
131128

132-
// Calculate 24h uptime
133129
var upCount24h, totalCount24h int64
134130
err = db.Model(&Check{}).
135131
Where("monitor_id = ? AND timestamp >= ?", monitor.ID, dayAgo).
@@ -144,7 +140,6 @@ func (db *DB) GetStats(monitorName string, duration time.Duration) (types.Servic
144140
stats.Uptime24h = float64(upCount24h) * 100.0 / float64(totalCount24h)
145141
}
146142

147-
// Calculate 30d uptime
148143
var upCount30d, totalCount30d int64
149144
err = db.Model(&Check{}).
150145
Where("monitor_id = ? AND timestamp >= ?", monitor.ID, monthAgo).
@@ -159,7 +154,6 @@ func (db *DB) GetStats(monitorName string, duration time.Duration) (types.Servic
159154
stats.Uptime30d = float64(upCount30d) * 100.0 / float64(totalCount30d)
160155
}
161156

162-
// Get latest check separately
163157
var lastCheck Check
164158
if err := db.Where("monitor_id = ?", monitor.ID).
165159
Order("timestamp DESC").

internal/tui/app.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type App struct {
1717
debug *widgets.DebugView
1818
help *widgets.HelpBar
1919
monitors []types.Monitor
20-
currentMonitorID int // Add this field
20+
currentMonitorID int
2121
}
2222

2323
func NewApp(debugMode bool, daemonAddr string) (*App, error) {
@@ -47,7 +47,7 @@ func NewApp(debugMode bool, daemonAddr string) (*App, error) {
4747

4848
func (app *App) Run() error {
4949
defer termui.Close()
50-
defer app.Close() // Make sure we close the RPC client
50+
defer app.Close()
5151

5252
// Initial data fetch and setup
5353
if err := app.initialSetup(); err != nil {
@@ -278,15 +278,13 @@ func (app *App) refreshData() error {
278278
return nil
279279
}
280280

281-
// Add this method to App struct
282281
func (app *App) Close() error {
283282
if app.client != nil {
284283
return app.client.close()
285284
}
286285
return nil
287286
}
288287

289-
// Update the updateSelectedMonitor method
290288
func (app *App) updateSelectedMonitor(index int) {
291289
if index >= len(app.monitors) {
292290
return

internal/tui/client.go

-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ func (c *RPCClient) resumeMonitor(name string) error {
9898
return c.call("Service.ResumeMonitor", name, &reply)
9999
}
100100

101-
// Update the getHistoricalStats method
102101
func (c *RPCClient) getHistoricalStats(monitorID int, count int, debug *widgets.DebugView) ([]types.HistoricalStat, error) {
103102
var stats []types.HistoricalStat
104103
args := struct {

internal/tui/widgets/details_panel.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type DetailsPanel struct {
1818
}
1919

2020
func NewDetailsPanel() *DetailsPanel {
21-
container := termui.NewBlock() // Changed from widgets.NewBlock() to termui.NewBlock()
21+
container := termui.NewBlock()
2222
container.Border = true
2323
container.BorderStyle = termui.NewStyle(termui.ColorWhite)
2424

@@ -79,17 +79,12 @@ func (d *DetailsPanel) Draw(buf *termui.Buffer) {
7979
d.Stats.Draw(buf)
8080
}
8181

82-
// GetRect implements termui.Drawable interface
8382
func (d *DetailsPanel) GetRect() image.Rectangle {
8483
d.Lock()
8584
defer d.Unlock()
8685
return d.Container.GetRect()
8786
}
8887

89-
// Lock is already implemented by embedding sync.Mutex
90-
// Unlock is already implemented by embedding sync.Mutex
91-
92-
// Add this method to DetailsPanel
9388
func (d *DetailsPanel) InitializeChart(stats []types.HistoricalStat, debug *DebugView) {
9489
d.Lock()
9590
defer d.Unlock()

internal/tui/widgets/response_chart.go

+4-8
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type ResponseChart struct {
1010
*widgets.BarChart
1111
data []float64
1212
labels []string
13-
statuses []bool // Add this field to track up/down status
13+
statuses []bool
1414
storedStats []types.HistoricalStat
1515
debug *DebugView
1616
}
@@ -27,15 +27,15 @@ func NewResponseChart() *ResponseChart {
2727
BarChart: chart,
2828
data: make([]float64, 0),
2929
labels: make([]string, 0),
30-
statuses: make([]bool, 0), // Initialize the statuses slice
30+
statuses: make([]bool, 0),
3131
}
3232
}
3333

3434
func (c *ResponseChart) Update(status types.ServiceStatus) {
3535
// Add new data point
3636
responseValue := float64(status.ResponseTime)
3737
if !status.CurrentStatus {
38-
responseValue = 0 // Use 0 for down status
38+
responseValue = 0
3939
}
4040

4141
c.data = append(c.data, responseValue)
@@ -94,12 +94,10 @@ func (c *ResponseChart) Update(status types.ServiceStatus) {
9494
c.Labels = c.labels
9595
}
9696

97-
// Add method to store stats for later initialization
9897
func (c *ResponseChart) StoreHistoricalStats(stats []types.HistoricalStat) {
9998
c.storedStats = stats
10099
}
101100

102-
// Add method to initialize with current width
103101
func (c *ResponseChart) InitializeWithCurrentWidth() {
104102
if len(c.storedStats) > 0 {
105103
width := c.GetRect().Dx()
@@ -115,15 +113,13 @@ func (c *ResponseChart) InitializeWithCurrentWidth() {
115113
}
116114
}
117115

118-
// Add new method to calculate how many bars can fit
119116
func (c *ResponseChart) CalculateMaxBars(containerWidth int) int {
120-
width := containerWidth - 2 // Subtract 2 for padding
117+
width := containerWidth - 2
121118
// Each bar takes BarWidth + 1 space (bar + gap)
122119
// We also need 1 space at the start for padding
123120
return (width - 1) / (c.BarWidth + 1)
124121
}
125122

126-
// Update InitializeHistory to handle the data in the same way
127123
func (c *ResponseChart) InitializeHistory(stats []types.HistoricalStat, containerWidth int, debug *DebugView) {
128124
c.debug = debug
129125
if debug != nil {

internal/tui/widgets/service_list.go

-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ func (s *ServiceList) MoveSelection(delta int, maxIndex int) {
8080
}
8181
}
8282

83-
// Add these methods to ServiceList
84-
8583
func (s *ServiceList) IsPaused(serviceName string) bool {
8684
return s.pausedMonitors[serviceName]
8785
}

internal/types/types.go

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ type Monitor struct {
2424
IsActive bool
2525
}
2626

27-
// Add this new type
2827
type HistoricalStat struct {
2928
ResponseTime int
3029
IsUp bool

0 commit comments

Comments
 (0)