diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml new file mode 100644 index 0000000..4c25ec2 --- /dev/null +++ b/.github/workflows/goreleaser.yml @@ -0,0 +1,15 @@ +name: Go CI and Release + +on: + push: + branches: + - '**' + tags: + - '*' + pull_request: + branches: + - '**' + +jobs: + build: + uses: TheCacophonyProject/github-actions-templates/.github/workflows/go-ci-release.yml@v0.1.1 diff --git a/.goreleaser.yml b/.goreleaser.yml index 3244624..2d7a3d2 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,5 +1,7 @@ project_name: modemd +version: 2 + release: github: owner: TheCacophonyProject diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c6486b6..0000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: go - -go: - - "1.22.x" - -script: - - go mod tidy - - git diff --exit-code || (echo "Please run 'go mod tidy' to clean up the 'go.mod' and 'go.sum' files. Your go version should match the one used with travis."; false) - - go vet ./... - - go test ./... - - curl -sL https://git.io/goreleaser | bash -s check - -# calls goreleaser -deploy: -- provider: script - skip_cleanup: true - script: curl -sL https://git.io/goreleaser | bash - on: - tags: true - go: "1.22.x" diff --git a/_release/modemd.service b/_release/modemd.service index b84fd25..7e88b9d 100644 --- a/_release/modemd.service +++ b/_release/modemd.service @@ -1,6 +1,7 @@ [Unit] Description=Cacophony Project USB modem controller After=multi-user.target +ConditionPathExists=/etc/salt/minion_id [Service] Type=simple diff --git a/cmd/check-gps/main.go b/cmd/check-gps/main.go index 6211afa..0be1292 100644 --- a/cmd/check-gps/main.go +++ b/cmd/check-gps/main.go @@ -3,7 +3,6 @@ package main import ( "bufio" "fmt" - "os" "strconv" "strings" "time" @@ -211,7 +210,7 @@ func runATCommand(atCommand string) (string, error) { // ConvertLong converts a longitude in format dddmm.mmmmmm to degrees. func ConvertLong(long string) (float64, error) { if len(long) < 7 { - return 0, fmt.Errorf("Invalid longitude format") + return 0, fmt.Errorf("invalid longitude format") } // Split the longitude string into degrees and minutes. @@ -237,7 +236,7 @@ func ConvertLong(long string) (float64, error) { // ConvertLat converts a latitude in format ddmm.mmmmmm to degrees. func ConvertLat(lat string) (float64, error) { if len(lat) < 6 { - return 0, fmt.Errorf("Invalid latitude format") + return 0, fmt.Errorf("invalid latitude format") } // Split the latitude string into degrees and minutes. @@ -260,6 +259,7 @@ func ConvertLat(lat string) (float64, error) { return degrees + minutesInDegrees, nil } +/* func appendToFile(filename string, data string) error { // Open the file in append mode or create if it doesn't exist file, err := os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) @@ -272,3 +272,4 @@ func appendToFile(filename string, data string) error { _, err = file.WriteString(data + "\n") return err } +*/ diff --git a/cmd/modemd/modemController.go b/cmd/modemd/modemController.go index 9e8dffd..0b44f57 100644 --- a/cmd/modemd/modemController.go +++ b/cmd/modemd/modemController.go @@ -32,6 +32,7 @@ import ( "github.com/TheCacophonyProject/event-reporter/v3/eventclient" goconfig "github.com/TheCacophonyProject/go-config" + "github.com/TheCacophonyProject/go-utils/saltutil" "github.com/tarm/serial" "periph.io/x/periph/conn/gpio" "periph.io/x/periph/conn/gpio/gpioreg" @@ -886,6 +887,9 @@ func saltCommandsRunning() bool { ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second) defer cancel() + if !saltutil.IsSaltIdSet() { + return false + } cmd := exec.CommandContext(ctx, "salt-call", "--local", "saltutil.running") stdout, err := cmd.Output() diff --git a/cmd/reception-logger/main.go b/cmd/reception-logger/main.go index ceafe41..36d0cca 100644 --- a/cmd/reception-logger/main.go +++ b/cmd/reception-logger/main.go @@ -15,14 +15,14 @@ var log = logging.NewLogger("info") func main() { for { - out, err := runATCommand("AT") + _, err := runATCommand("AT") if err != nil { log.Fatal(err) } reception := readReception() band, _ := readBand() t := time.Now().Format("2006-01-02 15:04:05") - out = fmt.Sprintf("%s, %s, %s", t, reception, band) + out := fmt.Sprintf("%s, %s, %s", t, reception, band) log.Println(out) appendToFile("/home/pi/reception", out) time.Sleep(5 * time.Second) diff --git a/go.mod b/go.mod index 061d2ad..c54cdec 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.22.3 require ( github.com/TheCacophonyProject/event-reporter/v3 v3.8.0 github.com/TheCacophonyProject/go-config v1.9.1 - github.com/TheCacophonyProject/go-utils v0.1.1 + github.com/TheCacophonyProject/go-utils v0.1.3 github.com/alexflint/go-arg v1.4.2 github.com/godbus/dbus v4.1.0+incompatible github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07 diff --git a/go.sum b/go.sum index 02f8fa6..914a84f 100644 --- a/go.sum +++ b/go.sum @@ -57,8 +57,8 @@ github.com/TheCacophonyProject/go-config v0.0.0-20190922224052-7c2a21bc6b88/go.m github.com/TheCacophonyProject/go-config v1.9.0/go.mod h1:+y80PSRZudMYuVrYTGOvzc66NxVJWKS4TuU442vmvhY= github.com/TheCacophonyProject/go-config v1.9.1 h1:TCeogtNYg5eHx2q97DQ1B+RsbjacW+jr7h1TCv1FpAk= github.com/TheCacophonyProject/go-config v1.9.1/go.mod h1:XZwQmNl2wQXhYR18RQtwZ6LwFwgAx73yzJfymYLz68s= -github.com/TheCacophonyProject/go-utils v0.1.1 h1:VOt9EphEqRUYMqKJlJeliIarIMlCVKYGb1fdqM6b4YM= -github.com/TheCacophonyProject/go-utils v0.1.1/go.mod h1:jZPUZ4GtYVxnlTtqiYKMFWDT//kmxdbwjLW3HCyCmCE= +github.com/TheCacophonyProject/go-utils v0.1.3 h1:DSuDeJz7ZM00yQRLsoukWH0fnC+8X8+ziYxOl6l3wEY= +github.com/TheCacophonyProject/go-utils v0.1.3/go.mod h1:jZPUZ4GtYVxnlTtqiYKMFWDT//kmxdbwjLW3HCyCmCE= github.com/TheCacophonyProject/modemd v0.0.0-20190605010435-ae5b0f2eb760/go.mod h1:bfwJ/WcvDY9XtHKC5tcRfVrU8RWaW8DLYAAUfsrJr/4= github.com/TheCacophonyProject/modemd v1.6.0/go.mod h1:0M7yJCdqhvoI5dVeDjOH6vsmbOBr1YhZ8DpAK4AkOA0= github.com/TheCacophonyProject/window v0.0.0-20190821235241-ab92c2ee24b6/go.mod h1:Vww417iimOb0s46Ndsm8U/vYtwc0dZUet4uW8QzBo4M=