Skip to content

Commit 673fc2c

Browse files
authored
Use go 1.24 and golangci-lint v2 (#330)
1 parent e59502a commit 673fc2c

File tree

13 files changed

+65
-50
lines changed

13 files changed

+65
-50
lines changed

.github/workflows/pull_request.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,13 @@ jobs:
88
build-test:
99
name: Build, lint, test
1010
runs-on: ubuntu-latest
11-
strategy:
12-
matrix:
13-
go: ['1.23']
1411

1512
steps:
1613
- uses: actions/checkout@v3
1714
- name: Set up Go
1815
uses: actions/setup-go@v3
1916
with:
20-
go-version: ${{ matrix.go }}
17+
go-version: '1.24'
2118
- name: Install make
2219
run: sudo apt -y install make
2320
- name: run build
@@ -27,7 +24,6 @@ jobs:
2724
- name: check clean vendors
2825
run: go mod vendor
2926
- name: Report coverage
30-
if: ${{ matrix.go == '1.23' }}
3127
uses: codecov/codecov-action@v4
3228
env:
3329
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/pull_request_e2e.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: set up go 1.x
2424
uses: actions/setup-go@v3
2525
with:
26-
go-version: '1.23'
26+
go-version: '1.24'
2727
- name: checkout
2828
uses: actions/checkout@v3
2929
- name: get kernel version

.github/workflows/push_image.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,13 @@ jobs:
1313
push-image:
1414
name: push image
1515
runs-on: ubuntu-latest
16-
strategy:
17-
matrix:
18-
go: ['1.23']
1916
steps:
2017
- name: install make
2118
run: sudo apt-get install make
2219
- name: set up go 1.x
2320
uses: actions/setup-go@v3
2421
with:
25-
go-version: ${{ matrix.go }}
22+
go-version: '1.24'
2623
- name: checkout
2724
uses: actions/checkout@v3
2825
- name: docker login to quay.io
@@ -44,16 +41,13 @@ jobs:
4441
codecov:
4542
name: Codecov upload
4643
runs-on: ubuntu-latest
47-
strategy:
48-
matrix:
49-
go: ['1.23']
5044
steps:
5145
- name: install make
5246
run: sudo apt-get install make
5347
- name: set up go 1.x
5448
uses: actions/setup-go@v3
5549
with:
56-
go-version: ${{ matrix.go }}
50+
go-version: '1.24'
5751
- name: checkout
5852
uses: actions/checkout@v3
5953
- name: Test

.github/workflows/push_image_pr.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,13 @@ jobs:
1414
if: ${{ github.event.label.name == 'ok-to-test' }}
1515
name: push PR image
1616
runs-on: ubuntu-latest
17-
strategy:
18-
matrix:
19-
go: ['1.23']
2017
steps:
2118
- name: install make
2219
run: sudo apt-get install make
2320
- name: set up go 1.x
2421
uses: actions/setup-go@v3
2522
with:
26-
go-version: ${{ matrix.go }}
23+
go-version: '1.24'
2724
- name: checkout
2825
uses: actions/checkout@v3
2926
with:

.github/workflows/release.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ jobs:
1212
push-image:
1313
name: push image and prepare release
1414
runs-on: ubuntu-latest
15-
strategy:
16-
matrix:
17-
go: ['1.23']
1815
steps:
1916
- name: checkout
2017
uses: actions/checkout@v3
@@ -34,7 +31,7 @@ jobs:
3431
- name: set up go 1.x
3532
uses: actions/setup-go@v3
3633
with:
37-
go-version: ${{ matrix.go }}
34+
go-version: '1.24'
3835
- name: docker login to quay.io
3936
uses: docker/login-action@v2
4037
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ cli-e2e-img.tar
88
e2e/commands
99
e2e/output
1010
e2e-logs
11+
bin/

.golangci.yml

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,59 @@
1+
version: "2"
2+
run:
3+
go: "1.23"
14
linters:
25
enable:
3-
- errcheck
4-
- errorlint
6+
- copyloopvar
57
- cyclop
8+
- errcheck
69
- errname
10+
- errorlint
711
- exhaustive
8-
- copyloopvar
912
- gocritic
10-
- gofmt
11-
- gosimple
1213
- govet
1314
- ineffassign
1415
- revive
1516
- staticcheck
16-
- stylecheck
17-
- typecheck
1817
- unused
19-
- ginkgolinter
20-
run:
21-
go: "1.22"
22-
linters-settings:
23-
gocritic:
24-
enabled-checks:
25-
- hugeParam
26-
- rangeExprCopy
27-
- rangeValCopy
28-
- indexAlloc
29-
settings:
30-
ifElseChain:
31-
minThreshold: 3
32-
cyclop:
33-
max-complexity: 150 # TODO: reduce that to 20
18+
settings:
19+
cyclop:
20+
max-complexity: 20
21+
gocritic:
22+
enabled-checks:
23+
- hugeParam
24+
- rangeExprCopy
25+
- rangeValCopy
26+
- indexAlloc
27+
settings:
28+
ifElseChain:
29+
minThreshold: 3
30+
exclusions:
31+
generated: lax
32+
presets:
33+
- comments
34+
- common-false-positives
35+
- legacy
36+
- std-error-handling
37+
paths:
38+
- third_party$
39+
- builtin$
40+
- examples$
41+
rules:
42+
- linters:
43+
- staticcheck
44+
text: "QF1003:"
45+
- linters:
46+
- staticcheck
47+
text: "QF1008:"
48+
- linters:
49+
- revive
50+
text: "avoid meaningless package names"
51+
formatters:
52+
enable:
53+
- gofmt
54+
exclusions:
55+
generated: lax
56+
paths:
57+
- third_party$
58+
- builtin$
59+
- examples$

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
ARG TARGETARCH=amd64
33

44
# Build the manager binary
5-
FROM docker.io/library/golang:1.23 as builder
5+
FROM docker.io/library/golang:1.24 as builder
66

77
ARG TARGETARCH
88
ARG LDFLAGS

Dockerfile.downstream

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ARG BUILDVERSION
44
FROM registry.redhat.io/openshift4/ose-cli-rhel9:v4.18.0-202502040032.p0.ga50d4c0.assembly.stream.el9 as ose-cli
55

66
# Build the manager binary
7-
FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:v1.23 as builder
7+
FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:v1.24 as builder
88
ARG BUILDVERSION
99
ARG IMAGE=registry.redhat.io/network-observability/network-observability-cli-rhel9:${BUILDVERSION}
1010
ARG AGENT_IMAGE=registry.redhat.io/network-observability/network-observability-ebpf-agent-rhel9:${BUILDVERSION}

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ ifneq ($(CLEAN_BUILD),)
5151
LDFLAGS ?= -X 'main.buildVersion=${VERSION}-${BUILD_SHA}' -X 'main.buildDate=${BUILD_DATE}'
5252
endif
5353

54-
GOLANGCI_LINT_VERSION = v1.64.6
54+
GOLANGCI_LINT_VERSION = v2.2.1
5555
BASH_VERSION = v4.2.0
5656
YQ_VERSION = v4.45.1
5757

@@ -83,7 +83,9 @@ prepare:
8383
.PHONY: prereqs
8484
prereqs: ## Install dependencies
8585
@echo "### Installing dependencies"
86-
GOFLAGS="" go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}
86+
test -f ./bin/golangci-lint-${GOLANGCI_LINT_VERSION} || ( \
87+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s ${GOLANGCI_LINT_VERSION} \
88+
&& mv ./bin/golangci-lint ./bin/golangci-lint-${GOLANGCI_LINT_VERSION})
8789
GOFLAGS="" go install github.com/mikefarah/yq/v4@${YQ_VERSION}
8890

8991
.PHONY: vendors
@@ -134,7 +136,7 @@ fmt: ## Run go fmt against code.
134136
.PHONY: lint
135137
lint: prereqs ## Lint code
136138
@echo "### Linting code"
137-
golangci-lint run ./... --timeout=3m
139+
./bin/golangci-lint-${GOLANGCI_LINT_VERSION} run ./... --timeout=3m
138140
ifeq (, $(shell which shellcheck))
139141
@echo "### shellcheck could not be found, skipping shell lint"
140142
else

0 commit comments

Comments
 (0)