diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..a87b5ad --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,28 @@ +# This workflow will build a golang project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go + +name: Go + +on: + push: + branches: [ "main", "dev" ] + pull_request: + branches: [ "main" ] + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.23' + + - name: Build + run: go build -v ./... + + - name: Test + run: go test -v ./... diff --git a/README.md b/README.md index 420a3fa..877ffb1 100644 --- a/README.md +++ b/README.md @@ -61,8 +61,13 @@ If you want to use Beacon you currently have to run, host and potentially (gasp) - this is an inconvenience for potential users - 🔴 notifications - currently needs updates after refactors of other parts - - +- 🟡 dev workflow + - 🟢 basic github setup + - want CI for building/testing +- 🟡 testing + - 🟢 unit tests for storage + - want at least one end-to-end test + - want more automation, related to "dev workflow" ## 🚀 Run diff --git a/cmd/monitor/web.go b/cmd/monitor/web.go index 6d3be91..37011ac 100644 --- a/cmd/monitor/web.go +++ b/cmd/monitor/web.go @@ -5,9 +5,9 @@ package main import ( "fmt" + "github.com/davidmasek/beacon/monitor" + "github.com/davidmasek/beacon/storage" "github.com/spf13/viper" - "optimisticotter.me/heartbeat-monitor/monitor" - "optimisticotter.me/heartbeat-monitor/storage" ) func main() { diff --git a/cmd/notify/notify.go b/cmd/notify/notify.go index 04948d5..6ac9569 100644 --- a/cmd/notify/notify.go +++ b/cmd/notify/notify.go @@ -9,11 +9,11 @@ import ( "log" "time" + "github.com/davidmasek/beacon/handlers" + "github.com/davidmasek/beacon/monitor" + "github.com/davidmasek/beacon/status" + "github.com/davidmasek/beacon/storage" "github.com/spf13/viper" - "optimisticotter.me/heartbeat-monitor/handlers" - "optimisticotter.me/heartbeat-monitor/monitor" - "optimisticotter.me/heartbeat-monitor/status" - "optimisticotter.me/heartbeat-monitor/storage" ) func main() { @@ -75,11 +75,7 @@ func main() { log.Println("[ERROR]", err) continue } - timestamps := make([]time.Time, 0) - if healthCheck != nil { - timestamps = append(timestamps, healthCheck.Timestamp) - } - serviceStatus, err := config.GetServiceStatus(timestamps) + serviceStatus, err := config.GetServiceStatus(healthCheck) if err != nil { log.Println("[ERROR]", err) continue diff --git a/cmd/server/server.go b/cmd/server/server.go index f3e7d5b..e1735bb 100644 --- a/cmd/server/server.go +++ b/cmd/server/server.go @@ -13,9 +13,9 @@ import ( _ "github.com/mattn/go-sqlite3" - "optimisticotter.me/heartbeat-monitor/monitor" - "optimisticotter.me/heartbeat-monitor/status" - "optimisticotter.me/heartbeat-monitor/storage" + "github.com/davidmasek/beacon/monitor" + "github.com/davidmasek/beacon/status" + "github.com/davidmasek/beacon/storage" ) func main() { diff --git a/handlers/common.go b/handlers/common.go index 707c566..f35efd8 100644 --- a/handlers/common.go +++ b/handlers/common.go @@ -4,8 +4,8 @@ import ( "encoding/json" "fmt" - "optimisticotter.me/heartbeat-monitor/monitor" - "optimisticotter.me/heartbeat-monitor/storage" + "github.com/davidmasek/beacon/monitor" + "github.com/davidmasek/beacon/storage" ) type ServiceReport struct { diff --git a/handlers/log.go b/handlers/log.go index 2b992ee..b956db0 100644 --- a/handlers/log.go +++ b/handlers/log.go @@ -4,7 +4,7 @@ import ( "fmt" "log" - "optimisticotter.me/heartbeat-monitor/monitor" + "github.com/davidmasek/beacon/monitor" ) const ( diff --git a/monitor/heartbeat_listener.go b/monitor/heartbeat_listener.go index a10306c..70ba7e9 100644 --- a/monitor/heartbeat_listener.go +++ b/monitor/heartbeat_listener.go @@ -9,7 +9,7 @@ import ( _ "github.com/mattn/go-sqlite3" "github.com/spf13/viper" - "optimisticotter.me/heartbeat-monitor/storage" + "github.com/davidmasek/beacon/storage" ) type HeartbeatListener struct { diff --git a/monitor/monitor.go b/monitor/monitor.go index af72b17..1cb970f 100644 --- a/monitor/monitor.go +++ b/monitor/monitor.go @@ -1,8 +1,8 @@ package monitor import ( + "github.com/davidmasek/beacon/storage" "github.com/spf13/viper" - "optimisticotter.me/heartbeat-monitor/storage" ) type Monitor interface { diff --git a/monitor/web_pinger.go b/monitor/web_pinger.go index cbaecad..be5ebb8 100644 --- a/monitor/web_pinger.go +++ b/monitor/web_pinger.go @@ -10,8 +10,8 @@ import ( "slices" "strings" + "github.com/davidmasek/beacon/storage" "github.com/spf13/viper" - "optimisticotter.me/heartbeat-monitor/storage" ) type WebPinger struct { diff --git a/status/ui_server.go b/status/ui_server.go index 88e1246..b4eb734 100644 --- a/status/ui_server.go +++ b/status/ui_server.go @@ -10,8 +10,8 @@ import ( "sort" "time" - "optimisticotter.me/heartbeat-monitor/monitor" - "optimisticotter.me/heartbeat-monitor/storage" + "github.com/davidmasek/beacon/monitor" + "github.com/davidmasek/beacon/storage" ) type HeartbeatConfig struct {