Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.24"
go-version: "1.25.6"

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v9
with:
version: v1.64.8
version: v2.6
args: --timeout=5m

- name: Check for modernization opportunities
Expand All @@ -37,7 +37,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.24"
go-version: "1.25.6"

- name: Download dependencies
run: go mod download
Expand All @@ -54,7 +54,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.24"
go-version: "1.25.6"

- name: Run tests
run: go test -v -race ./...
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@
ghcr.io/${{ env.repo }}:${{ steps.version.outputs.version }}
ghcr.io/${{ env.repo }}:latest
build-args: |
GOLANG_TAG=1.24-alpine
GOLANG_TAG=1.25.6-alpine
VERSION=${{ steps.version.outputs.version }}
COMMIT=${{ github.sha }}
9 changes: 6 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
issues:
exclude-dirs:
- docs
version: "2"

linters:
exclusions:
paths:
- docs
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Choose Go version
ARG GOLANG_TAG=1.24-alpine
ARG GOLANG_TAG=1.25.6-alpine

FROM golang:${GOLANG_TAG} AS builder

Expand All @@ -22,7 +22,7 @@ COPY . .
# Build the application with version info (CGO_ENABLED=1 for SQLite)
RUN CGO_ENABLED=1 GOOS=linux go build \
-o blockbusterr \
-ldflags="-s -w -X 'main.Version=${VERSION}' -X 'main.Timestamp=${COMMIT}'" \
-ldflags="-s -w -X 'main.Version=${VERSION}' -X 'main.Commit=${COMMIT}'" \
./cmd/app/main.go

# Runtime stage
Expand Down
26 changes: 10 additions & 16 deletions cmd/app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
)

var (
Version = "dev"
Timestamp = "unknown"
Version = "dev"
Commit = "none"
)

func main() {
Expand All @@ -31,12 +31,9 @@ func main() {
}
}

// If Timestamp wasn't set at build time via ldflags, use env var or current time
if Timestamp == "unknown" || Timestamp == "" {
if t := os.Getenv("TIMESTAMP"); t != "" {
Timestamp = t
} else {
Timestamp = time.Now().Format(time.RFC3339)
if Commit == "none" || Commit == "" {
if c := os.Getenv("COMMIT"); c != "" {
Commit = c
}
}

Expand All @@ -54,9 +51,9 @@ func main() {
slog.SetDefault(logger)

if Version == "dev" {
slog.Info("Starting in development mode", "version", Version, "timestamp", Timestamp)
slog.Info("Starting in development mode", "version", Version, "commit", Commit)
} else {
slog.Info("Starting in production mode", "version", Version, "timestamp", Timestamp)
slog.Info("Starting in production mode", "version", Version, "commit", Commit)
}

cfg, err := config.New(Version)
Expand All @@ -77,7 +74,7 @@ func main() {
cfg,
db,
Version,
Timestamp,
Commit,
))

interrupt := make(chan os.Signal, 1)
Expand Down Expand Up @@ -117,17 +114,14 @@ func main() {
close(done)
}()

wg.Add(1)
go func() {
defer wg.Done()

wg.Go(func() {
slog.Info("api", "status", "starting")
if err := rest.New(gctx); err != nil {
slog.Error("api", "status", "errored", "error", err)
os.Exit(1)
}
slog.Info("api", "status", "started")
}()
})

<-done
slog.Info("Shutdown complete")
Expand Down
5 changes: 4 additions & 1 deletion cmd/test-scoring/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ func main() {
fmt.Println("=== Content Scoring System Demo (LIVE DATA) ===")

// Set to dev mode to load config.dev.yaml
os.Setenv("VERSION", "dev")
err := os.Setenv("VERSION", "dev")
if err != nil {
log.Fatalf("Failed to set env var: %v", err)
}

// Load actual configuration
cfg, err := config.New("dev")
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/mahcks/blockbusterr

go 1.24.5
go 1.25.6

require (
github.com/gofiber/fiber/v2 v2.52.10
Expand Down
9 changes: 6 additions & 3 deletions internal/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ func New(dataDir string) (*Database, error) {

// Initialize schema
if err := database.initSchema(); err != nil {
db.Close()
err := db.Close()
if err != nil {
return nil, fmt.Errorf("failed to initialize schema and close db: %w", err)
}
return nil, err
}

Expand Down Expand Up @@ -183,7 +186,7 @@ func (d *Database) GetRecentActivity(limit int) ([]ActivityLog, error) {
if err != nil {
return nil, err
}
defer rows.Close()
defer func() { _ = rows.Close() }()

var logs []ActivityLog
for rows.Next() {
Expand Down Expand Up @@ -273,7 +276,7 @@ func (d *Database) GetRecentActivityFiltered(limit int, status, mediaType, jobTy
if err != nil {
return nil, err
}
defer rows.Close()
defer func() { _ = rows.Close() }()

var logs []ActivityLog
for rows.Next() {
Expand Down
11 changes: 5 additions & 6 deletions internal/global/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
)

type Metadata struct {
Version string
Timestamp string
Version string
Commit string
}

type Context interface {
Expand Down Expand Up @@ -61,15 +61,14 @@ func New(
ctx context.Context,
cfg *config.Config,
db *database.Database,
Version string,
Timestamp string,
Version, Commit string,
) Context {
return &gCtx{
cfg: cfg,
Context: ctx,
metadata: Metadata{
Version: Version,
Timestamp: Timestamp,
Version: Version,
Commit: Commit,
},
db: db,
}
Expand Down
12 changes: 6 additions & 6 deletions internal/integrations/jellyseerr.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (j *Jellyseerr) login() error {
if err != nil {
return fmt.Errorf("failed to execute login request: %w", err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
Expand Down Expand Up @@ -222,7 +222,7 @@ func (j *Jellyseerr) GetStatus() (*StatusResponse, error) {
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
Expand Down Expand Up @@ -256,7 +256,7 @@ func (j *Jellyseerr) RequestMovie(tmdbID int) (*RequestResponse, error) {
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

body, _ := io.ReadAll(resp.Body)

Expand Down Expand Up @@ -296,7 +296,7 @@ func (j *Jellyseerr) RequestShow(tmdbID int) (*RequestResponse, error) {
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

body, _ := io.ReadAll(resp.Body)

Expand Down Expand Up @@ -341,7 +341,7 @@ func (j *Jellyseerr) GetMovieInfo(tmdbID int) (*MediaInfo, error) {
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode == http.StatusNotFound {
// Movie not found in Jellyseerr = not requested
Expand All @@ -368,7 +368,7 @@ func (j *Jellyseerr) GetShowInfo(tmdbID int) (*MediaInfo, error) {
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode == http.StatusNotFound {
// Show not found in Jellyseerr = not requested
Expand Down
12 changes: 6 additions & 6 deletions internal/integrations/radarr.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (r *Radarr) GetSystemStatus(ctx context.Context) (*SystemStatus, error) {
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
Expand All @@ -161,7 +161,7 @@ func (r *Radarr) GetQualityProfiles(ctx context.Context) ([]QualityProfile, erro
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
Expand All @@ -182,7 +182,7 @@ func (r *Radarr) GetRootFolders(ctx context.Context) ([]RootFolder, error) {
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
Expand All @@ -203,7 +203,7 @@ func (r *Radarr) AddMovie(ctx context.Context, movie RadarrMovie) (*RadarrMovie,
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode != http.StatusCreated && resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
Expand All @@ -224,7 +224,7 @@ func (r *Radarr) GetMovies(ctx context.Context) ([]RadarrMovie, error) {
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
Expand All @@ -247,7 +247,7 @@ func (r *Radarr) LookupMovie(ctx context.Context, term string) ([]RadarrMovie, e
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
Expand Down
12 changes: 6 additions & 6 deletions internal/integrations/sonarr.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (s *Sonarr) GetSystemStatus(ctx context.Context) (*SonarrSystemStatus, erro
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
Expand All @@ -165,7 +165,7 @@ func (s *Sonarr) GetQualityProfiles(ctx context.Context) ([]SonarrQualityProfile
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
Expand All @@ -186,7 +186,7 @@ func (s *Sonarr) GetRootFolders(ctx context.Context) ([]SonarrRootFolder, error)
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
Expand All @@ -207,7 +207,7 @@ func (s *Sonarr) AddSeries(ctx context.Context, series SonarrSeries) (*SonarrSer
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode != http.StatusCreated && resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
Expand All @@ -228,7 +228,7 @@ func (s *Sonarr) GetSeries(ctx context.Context) ([]SonarrSeries, error) {
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
Expand All @@ -251,7 +251,7 @@ func (s *Sonarr) LookupSeries(ctx context.Context, term string) ([]SonarrSeries,
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
Expand Down
4 changes: 2 additions & 2 deletions internal/integrations/tmdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (t *TMDB) GetMoviePosterURL(ctx context.Context, tmdbID int) (string, error
if err != nil {
return "", fmt.Errorf("request failed: %w", err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode != http.StatusOK {
return "", fmt.Errorf("TMDB API returned status %d", resp.StatusCode)
Expand Down Expand Up @@ -108,7 +108,7 @@ func (t *TMDB) GetShowPosterURL(ctx context.Context, tmdbID int) (string, error)
if err != nil {
return "", fmt.Errorf("request failed: %w", err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode != http.StatusOK {
return "", fmt.Errorf("TMDB API returned status %d", resp.StatusCode)
Expand Down
Loading