Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Go 1.22.3 #1041

Merged
merged 5 commits into from
May 31, 2024
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
26 changes: 15 additions & 11 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
run:
# Until https://github.com/golangci/golangci-lint/issues/2649
go: 1.17
go: 1.20
tests: true
modules-download-mode: vendor
skip-dirs:
- vendor
- internal/rgbmatrix-rpi
- internal/proto
timeout: 5m
linters:
disable-all: true
enable:
- asciicheck
- bodyclose
- deadcode
- durationcheck
- errcheck
- errorlint
- exportloopref
- importas
- ineffassign
- goconst
- gofumpt
- goimports
- gosimple
- govet
- misspell
- nakedret
- nilerr
- noctx
- nonamedreturns
- nosprintfhostport
- paralleltest
- predeclared
- promlinter
- revive
- sqlclosecheck
- staticcheck
- structcheck
- tparallel
- unconvert
- unused
- unparam
- varcheck
- whitespace
linters-settings:
govet:
check-shadowing: true
enabled-all: true
enable-all: true
disable:
- fieldalignment
goimports:
local-prefixes: github.com/robbydyer/sports
revive:
Expand All @@ -49,6 +49,10 @@ linters-settings:
disabled: true
issues:
exclude-use-default: false
exclude-dirs:
- vendor
- internal/rgbmatrix-rpi
- internal/proto
exclude:
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked
- 'shadow: declaration of "err" shadows declaration at line (\d+)'
2 changes: 1 addition & 1 deletion Dockerfile.lint
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ COPY ./internal/rgbmatrix-rpi/lib/rpi-rgb-led-matrix.BASE /tmp/rpi-rgb-led-matri
RUN cd /tmp/rpi-rgb-led-matrix && \
make

FROM golangci/golangci-lint:v1.57.2
FROM golangci/golangci-lint:v1.59.0

COPY --from=builder /tmp/rpi-rgb-led-matrix /sportslibs/rpi-rgb-led-matrix
2 changes: 1 addition & 1 deletion Dockerfile.pibuilder
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM $BASE
# Replace shell with bash so we can source files
SHELL ["/bin/bash", "--login", "-ce"]

ARG GOVERSION=1.22.2
ARG GOVERSION=1.22.3

RUN apt-get update --allow-unauthenticated --allow-insecure-repositories && \
apt-get install --allow-unauthenticated -y debian-archive-keyring && \
Expand Down
1 change: 1 addition & 0 deletions internal/board/calendar/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func (s *CalendarBoard) Render(ctx context.Context, canvas board.Canvas) error {
}

// Render ...
// nolint:contextcheck
func (s *CalendarBoard) render(ctx context.Context, canvas board.Canvas) error {
s.boardCtx, s.boardCancel = context.WithCancel(ctx)

Expand Down
2 changes: 2 additions & 0 deletions internal/board/image/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ type jumpRequest struct {
}

// GetHTTPHandlers ...
//
//nolint:contextcheck
func (i *ImageBoard) GetHTTPHandlers() ([]*board.HTTPHandler, error) {
return []*board.HTTPHandler{
{
Expand Down
4 changes: 4 additions & 0 deletions internal/board/image/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
)

func TestFilenameCompare(t *testing.T) {
t.Parallel()
tests := []struct {
name string
a string
Expand Down Expand Up @@ -61,12 +62,14 @@ func TestFilenameCompare(t *testing.T) {
test := test

t.Run(test.name, func(t *testing.T) {
t.Parallel()
require.Equal(t, test.expected, filenameCompare(test.a, test.b))
})
}
}

func TestReverseStrs(t *testing.T) {
t.Parallel()
tests := []struct {
name string
in []string
Expand All @@ -93,6 +96,7 @@ func TestReverseStrs(t *testing.T) {
test := test

t.Run(test.name, func(t *testing.T) {
t.Parallel()
require.Equal(t, test.expected, reverseStrs(test.in))
})
}
Expand Down
2 changes: 2 additions & 0 deletions internal/board/racing/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ func (s *RacingBoard) Render(ctx context.Context, canvas board.Canvas) error {
}

// Render ...
//
//nolint:contextcheck
func (s *RacingBoard) render(ctx context.Context, canvas board.Canvas) error {
s.boardCtx, s.boardCancel = context.WithCancel(ctx)

Expand Down
2 changes: 2 additions & 0 deletions internal/board/sport/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
)

// GetHTTPHandlers ...
//
//nolint:contextcheck
func (s *SportBoard) GetHTTPHandlers() ([]*board.HTTPHandler, error) {
return []*board.HTTPHandler{
{
Expand Down
9 changes: 8 additions & 1 deletion internal/canvas/canvas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,29 @@ import (
)

func TestNewCanvas(t *testing.T) {
t.Parallel()
canvas := NewCanvas(NewMatrixMock(64, 32))
require.NotNil(t, canvas)
require.Equal(t, 64, canvas.w)
require.Equal(t, 32, canvas.h)
}

func TestRender(t *testing.T) {
t.Parallel()
m := NewMatrixMock(10, 20)
canvas := &Canvas{m: m}
err := canvas.Render(context.Background())
require.NoError(t, err)
}

func TestColorModel(t *testing.T) {
t.Parallel()
canvas := &Canvas{}
require.Equal(t, color.RGBAModel, canvas.ColorModel())
}

func TestBounds(t *testing.T) {
t.Parallel()
canvas := &Canvas{w: 10, h: 20}

b := canvas.Bounds()
Expand All @@ -41,6 +45,7 @@ func TestBounds(t *testing.T) {
}

func TestSet(t *testing.T) {
t.Parallel()
m := NewMatrixMock(10, 20)
canvas := &Canvas{w: 10, h: 20, m: m}
canvas.Set(5, 15, color.White)
Expand All @@ -49,6 +54,7 @@ func TestSet(t *testing.T) {
}

func TestClear(t *testing.T) {
t.Parallel()
m := NewMatrixMock(10, 20)

canvas := &Canvas{w: 10, h: 20, m: m}
Expand All @@ -61,6 +67,7 @@ func TestClear(t *testing.T) {
}

func TestClose(t *testing.T) {
t.Parallel()
m := NewMatrixMock(10, 20)
canvas := &Canvas{w: 10, h: 20, m: m}
err := canvas.Close()
Expand All @@ -85,7 +92,7 @@ func NewMatrixMock(w int, h int) *MatrixMock {
}
}

func (m *MatrixMock) Geometry() (width, height int) {
func (m *MatrixMock) Geometry() (int, int) {
return 64, 32
}

Expand Down
1 change: 1 addition & 0 deletions internal/espnboard/espnboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func (e *ESPNBoard) logoCacheDir() (string, error) {
}

// New ...
// nolint:contextcheck
func New(ctx context.Context, leaguer Leaguer, logger *zap.Logger, r rankSetter, rec rankSetter, opts ...Option) (*ESPNBoard, error) {
e := &ESPNBoard{
leaguer: leaguer,
Expand Down
2 changes: 1 addition & 1 deletion internal/matrix/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (c *ConsoleMatrix) render(leds []uint32) error {

rendered = append(rendered, strings.Repeat("_ ", c.width+1)+"|")

fmt.Fprintln(c.out, strings.Join(rendered, "\n"))
_, _ = fmt.Fprintln(c.out, strings.Join(rendered, "\n"))

c.Reset()

Expand Down
1 change: 1 addition & 0 deletions internal/rgbrender/grid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func TestGridLayout(t *testing.T) {
}

func TestGrid(t *testing.T) {
t.Parallel()
log, err := zap.NewDevelopment()
require.NoError(t, err)
canvas := board.NewBlankCanvas(100, 100, log)
Expand Down
3 changes: 3 additions & 0 deletions internal/rgbrender/layer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ func TestPriorities(t *testing.T) {
}

func TestRender(t *testing.T) {
t.Parallel()
layers, err := NewLayerDrawer(60*time.Second, nil)
require.NoError(t, err)

Expand Down Expand Up @@ -203,6 +204,7 @@ func TestRender(t *testing.T) {
}

func TestBadPrepare(t *testing.T) {
t.Parallel()
layers, err := NewLayerDrawer(60*time.Second, nil)
require.NoError(t, err)

Expand All @@ -219,6 +221,7 @@ func TestBadPrepare(t *testing.T) {
}

func TestBadRender(t *testing.T) {
t.Parallel()
layers, err := NewLayerDrawer(60*time.Second, nil)
require.NoError(t, err)

Expand Down
1 change: 1 addition & 0 deletions internal/rgbrender/rgbrender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ func TestZoomImageSize(t *testing.T) {
}

func TestNegativeImagePoint(t *testing.T) {
t.Parallel()
i := image.NewRGBA(image.Rect(-10, -10, 10, 10))

i.Set(-5, -5, color.Gray16{0xffff})
Expand Down
2 changes: 2 additions & 0 deletions internal/rgbrender/text_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
)

func TestBreakText(t *testing.T) {
t.Parallel()
tests := []struct {
name string
in string
Expand Down Expand Up @@ -53,6 +54,7 @@ func TestBreakText(t *testing.T) {
for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
require.Equal(t, test.expected, breakText(test.max, test.in))
})
}
Expand Down
1 change: 1 addition & 0 deletions internal/scrollcanvas/scroll_canvas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
)

func TestScrollCanvas(t *testing.T) {
t.Parallel()
l := zaptest.NewLogger(t)
m := matrix.NewConsoleMatrix(64, 32, io.Discard, l)
c, err := NewScrollCanvas(m, l)
Expand Down
1 change: 1 addition & 0 deletions internal/sportsmatrix/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ func (s *SportsMatrix) startHTTP() chan error {
return errChan
}

//nolint:contextcheck
func (s *SportsMatrix) httpHandlers() []*board.HTTPHandler {
return []*board.HTTPHandler{
{
Expand Down
4 changes: 3 additions & 1 deletion internal/sportsmatrix/sportsmatrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package sportsmatrix

import (
"context"
"errors"
"fmt"
"net/http"
_ "net/http/pprof"
Expand Down Expand Up @@ -122,6 +123,7 @@ func (c *Config) Defaults() {
}

// New ...
// nolint:contextcheck
func New(ctx context.Context, logger *zap.Logger, cfg *Config, canvases []board.Canvas, boards ...board.Board) (*SportsMatrix, error) {
cfg.Defaults()

Expand Down Expand Up @@ -329,7 +331,7 @@ func (s *SportsMatrix) startWebBoard(ctx context.Context) {
default:
}
if err := s.launchWebBoard(ctx); err != nil {
if err == context.Canceled {
if errors.Is(err, context.Canceled) {
s.log.Warn("web board context canceled, closing", zap.Error(err))
return
}
Expand Down
2 changes: 2 additions & 0 deletions internal/sportsmatrix/sportsmatrix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func (b *TestBoard) ScrollMode() bool {
func (b *TestBoard) SetStateChangeNotifier(st board.StateChangeNotifier) {
}

// nolint: paralleltest
func TestSportsMatrix(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down Expand Up @@ -151,6 +152,7 @@ func TestSportsMatrix(t *testing.T) {
}

func TestScreenSwitch(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

Expand Down
2 changes: 1 addition & 1 deletion script/common
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -euo pipefail

ROOT="$(dirname $( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd ))"
DOCKERCONF="${ROOT}/.dockerconfig"
GO_VERSION="1.22.2"
GO_VERSION="1.22.3"

getsha() {
if uname -s | grep -i darwin &> /dev/null; then
Expand Down
1 change: 1 addition & 0 deletions script/lint
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ if [ "${IN_DOCKER}" = "no" ]; then
-v "${ROOT}":/src${MOUNTOPTION} \
-w /src \
-e GOCACHE="/src/.cache" \
-e GOFLAGS="-buildvcs=false" \
-e GOLANGCI_LINT_CACHE="/src/.cache" \
-e GO111MODULE=on \
-e CGO_ENABLED=1 \
Expand Down