fix(ci): fix lint errors and pin CI to Go 1.25

- Run gofmt on all files
- Export SetupUPnP to fix unused lint error
- Remove Go 1.26 from CI matrix (only test with 1.25)
This commit is contained in:
Deivid Soto 2026-03-31 22:15:12 +02:00
parent 3e0f3a5a64
commit d0dbfc3d12
10 changed files with 31 additions and 31 deletions

View file

@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
go-version: ["1.25", "1.26"] go-version: ["1.25"]
steps: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@v6

View file

@ -531,7 +531,7 @@ func TestBatchDownload(t *testing.T) {
t.Errorf("path = %s", r.URL.Path) t.Errorf("path = %s", r.URL.Path)
} }
json.NewEncoder(w).Encode(BatchDownloadResponse{ json.NewEncoder(w).Encode(BatchDownloadResponse{
Queued: 3, Queued: 3,
NotFound: 1, NotFound: 1,
}) })
})) }))

View file

@ -9,8 +9,8 @@ func TestDeriveWSURL(t *testing.T) {
want string want string
}{ }{
{"https://torrentclaw.com", "agent-123", "wss://unarr.torrentclaw.com/ws/agent-123"}, {"https://torrentclaw.com", "agent-123", "wss://unarr.torrentclaw.com/ws/agent-123"},
{"http://localhost:3000", "a1", ""}, // localhost skipped {"http://localhost:3000", "a1", ""}, // localhost skipped
{"http://127.0.0.1:3000", "a1", ""}, // 127.0.0.1 skipped {"http://127.0.0.1:3000", "a1", ""}, // 127.0.0.1 skipped
{"https://torrentclaw.com/", "a1", "wss://unarr.torrentclaw.com/ws/a1"}, {"https://torrentclaw.com/", "a1", "wss://unarr.torrentclaw.com/ws/a1"},
{"https://api.example.io", "x", "wss://unarr.api.example.io/ws/x"}, {"https://api.example.io", "x", "wss://unarr.api.example.io/ws/x"},
{"", "agent-123", ""}, {"", "agent-123", ""},

View file

@ -301,6 +301,6 @@ func (m *slowMockDownloader) Download(ctx context.Context, _ *Task, _ string, _
<-ctx.Done() <-ctx.Done()
return nil, ctx.Err() return nil, ctx.Err()
} }
func (m *slowMockDownloader) Pause(_ string) error { return nil } func (m *slowMockDownloader) Pause(_ string) error { return nil }
func (m *slowMockDownloader) Cancel(_ string) error { return nil } func (m *slowMockDownloader) Cancel(_ string) error { return nil }
func (m *slowMockDownloader) Shutdown(_ context.Context) error { return nil } func (m *slowMockDownloader) Shutdown(_ context.Context) error { return nil }

View file

@ -41,10 +41,10 @@ type ProgressReporter struct {
onStreamRequested ActionFunc onStreamRequested ActionFunc
onWatchingChanged func(watching bool) onWatchingChanged func(watching bool)
mu sync.Mutex mu sync.Mutex
latest map[string]*Task // taskID -> task with latest progress latest map[string]*Task // taskID -> task with latest progress
lastReported map[string]TaskStatus // taskID -> last status sent to API lastReported map[string]TaskStatus // taskID -> last status sent to API
lastCheckAt time.Time // last time we reported for control-signal polling lastCheckAt time.Time // last time we reported for control-signal polling
} }
// NewProgressReporter creates a reporter that flushes every interval. // NewProgressReporter creates a reporter that flushes every interval.

View file

@ -230,10 +230,10 @@ func TestProgressReporter_HandleResponseDeleteFiles(t *testing.T) {
var deletedID string var deletedID string
pr := &ProgressReporter{ pr := &ProgressReporter{
reporter: reporter, reporter: reporter,
interval: time.Second, interval: time.Second,
latest: make(map[string]*Task), latest: make(map[string]*Task),
lastReported: make(map[string]TaskStatus), lastReported: make(map[string]TaskStatus),
onDeleteFiles: func(id string) { deletedID = id }, onDeleteFiles: func(id string) { deletedID = id },
} }
@ -254,10 +254,10 @@ func TestProgressReporter_HandleResponseStream(t *testing.T) {
var streamID string var streamID string
pr := &ProgressReporter{ pr := &ProgressReporter{
reporter: reporter, reporter: reporter,
interval: time.Second, interval: time.Second,
latest: make(map[string]*Task), latest: make(map[string]*Task),
lastReported: make(map[string]TaskStatus), lastReported: make(map[string]TaskStatus),
onStreamRequested: func(id string) { streamID = id }, onStreamRequested: func(id string) { streamID = id },
} }

View file

@ -17,9 +17,9 @@ type UPnPMapping struct {
device upnp.Device device upnp.Device
} }
// setupUPnP discovers the gateway, maps the port, and gets the public IP. // SetupUPnP discovers the gateway, maps the port, and gets the public IP.
// Returns nil if UPnP is not available or fails. // Returns nil if UPnP is not available or fails.
func setupUPnP(internalPort int) (*UPnPMapping, error) { func SetupUPnP(internalPort int) (*UPnPMapping, error) {
log.Println("stream: discovering UPnP gateway (10s timeout)...") log.Println("stream: discovering UPnP gateway (10s timeout)...")
devices := upnp.Discover(0, 10*time.Second, alog.Logger{}) devices := upnp.Discover(0, 10*time.Second, alog.Logger{})
if len(devices) == 0 { if len(devices) == 0 {

View file

@ -275,7 +275,7 @@ func TestFormatTimeAgo(t *testing.T) {
now := time.Now() now := time.Now()
tests := []struct { tests := []struct {
name string name string
input string input string
want string want string
}{ }{
@ -356,6 +356,6 @@ func TestPtr(t *testing.T) {
} }
} }
func ptr[T any](v T) *T { return &v } func ptr[T any](v T) *T { return &v }
func intPtr(v int) *int { return &v } func intPtr(v int) *int { return &v }
func strPtr(v string) *string { return &v } func strPtr(v string) *string { return &v }

View file

@ -753,9 +753,9 @@ func TestIsSampleFile(t *testing.T) {
{"movie-sample-video.mkv", true}, {"movie-sample-video.mkv", true},
{"movie_sample.mkv", true}, {"movie_sample.mkv", true},
{"sample.mkv", true}, {"sample.mkv", true},
{"resampled.mkv", false}, // "sample" is part of "resampled" {"resampled.mkv", false}, // "sample" is part of "resampled"
{"movie.mkv", false}, {"movie.mkv", false},
{"my.samples.zip", false}, // "sample" followed by 's' (alphanumeric) {"my.samples.zip", false}, // "sample" followed by 's' (alphanumeric)
} }
for _, tt := range tests { for _, tt := range tests {
if got := isSampleFile(tt.name); got != tt.want { if got := isSampleFile(tt.name); got != tt.want {
@ -880,15 +880,15 @@ func TestIsRarFile_Extended(t *testing.T) {
name string name string
want bool want bool
}{ }{
{"file.RAR", true}, // case insensitive {"file.RAR", true}, // case insensitive
{"file.Rar", true}, {"file.Rar", true},
{"file.s01", true}, {"file.s01", true},
{"file.s99", true}, {"file.s99", true},
{"file.002", true}, {"file.002", true},
{"file.999", true}, {"file.999", true},
{"file.r0", false}, // too short extension {"file.r0", false}, // too short extension
{"file.rXX", false}, // non-numeric {"file.rXX", false}, // non-numeric
{"file", false}, // no extension {"file", false}, // no extension
{"file.mp4", false}, {"file.mp4", false},
} }
for _, tt := range tests { for _, tt := range tests {

View file

@ -14,12 +14,12 @@ func TestFindPar2File(t *testing.T) {
vol1 := filepath.Join(dir, "content.vol000+01.par2") vol1 := filepath.Join(dir, "content.vol000+01.par2")
vol2 := filepath.Join(dir, "content.vol001+02.par2") vol2 := filepath.Join(dir, "content.vol001+02.par2")
os.WriteFile(mainPar2, make([]byte, 100), 0o644) // smallest os.WriteFile(mainPar2, make([]byte, 100), 0o644) // smallest
os.WriteFile(vol1, make([]byte, 10000), 0o644) os.WriteFile(vol1, make([]byte, 10000), 0o644)
os.WriteFile(vol2, make([]byte, 50000), 0o644) os.WriteFile(vol2, make([]byte, 50000), 0o644)
files := map[string]string{ files := map[string]string{
"content.par2": mainPar2, "content.par2": mainPar2,
"content.vol000+01.par2": vol1, "content.vol000+01.par2": vol1,
"content.vol001+02.par2": vol2, "content.vol001+02.par2": vol2,
} }