Skip to content

Commit

Permalink
Update go to 1.23 (#177)
Browse files Browse the repository at this point in the history
* Update go to 1.23

Signed-off-by: Vladislav Byrgazov <[email protected]>

* Update copyright-holder regexp

Signed-off-by: Vladislav Byrgazov <[email protected]>

* Fix set of enabled linters

Signed-off-by: Vladislav Byrgazov <[email protected]>

* Fix go-version

Signed-off-by: Vladislav Byrgazov <[email protected]>

* Reuse jobs from .github

Signed-off-by: Vladislav Byrgazov <[email protected]>

* Fix estrict-nsm-deps workflow

Signed-off-by: Vladislav Byrgazov <[email protected]>

* Improve golangci config

Signed-off-by: Vladislav Byrgazov <[email protected]>

---------

Signed-off-by: Vladislav Byrgazov <[email protected]>
Co-authored-by: Vladislav Byrgazov <[email protected]>
  • Loading branch information
Ex4amp1e and Vladislav Byrgazov authored Nov 14, 2024
1 parent fdbfcd8 commit df76555
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 158 deletions.
104 changes: 17 additions & 87 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,90 +7,28 @@ on:
- 'release/**'
jobs:
yamllint:
name: yamllint
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: yaml-lint
uses: ibiqlik/action-yamllint@v1
with:
config_file: .ci/yamllint.yml
strict: true
uses: networkservicemesh/.github/.github/workflows/yamllint.yaml@main
with:
config_file: .ci/yamllint.yml

build-and-test:
name: build and test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v1
with:
go-version: 1.20.5
- name: Build
run: go build -race ./...
- name: Test
run: go test -race ./...
uses: networkservicemesh/.github/.github/workflows/build-and-test.yaml@main
with:
os: '["ubuntu-latest", "macos-latest", "windows-latest"]'

golangci-lint:
name: golangci-lint
runs-on: ubuntu-latest
if: github.repository != 'networkservicemesh/cmd-template'
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v1
with:
go-version: 1.20.5
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.53.3
uses: networkservicemesh/.github/.github/workflows/golangci-lint.yaml@main

excludeFmtErrorf:
name: exclude fmt.Errorf
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Exclude fmt.Errorf
run: |
if grep -r --include=*.go fmt.Errorf . ; then
echo "Please use errors.Errorf (or errors.New or errors.Wrap or errors.Wrapf) as appropriate rather than fmt.Errorf"
exit 1
fi
exclude-fmt-errorf:
uses: networkservicemesh/.github/.github/workflows/exclude-fmt-errorf.yaml@main

restrictNSMDeps:
name: Restrict dependencies on github.com/networkservicemesh/*
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Restrict dependencies on github.com/networkservicemesh/*
run: |
for i in $(grep github.com/networkservicemesh/ go.mod | grep -v '^module' | sed 's;.*\(github.com\/networkservicemesh\/[^ ]*\).*;\1;g');do
echo Dependency on "${i}" is forbidden
exit 1
done
restrict-nsm-deps:
uses: networkservicemesh/.github/.github/workflows/restrict-nsm-deps.yaml@main
with:
allowed_repositories: ""

checkgomod:
name: check go.mod and go.sum
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.20.5
- run: go mod tidy
- name: Check for changes in go.mod or go.sum
run: |
git diff --name-only --exit-code go.mod || ( echo "Run go tidy" && false )
git diff --name-only --exit-code go.sum || ( echo "Run go tidy" && false )
uses: networkservicemesh/.github/.github/workflows/checkgomod.yaml@main

gogenerate:
name: Check generated files
Expand All @@ -102,20 +40,12 @@ jobs:
version: '3.14.0'
- uses: actions/setup-go@v1
with:
go-version: 1.20.5
go-version: 1.23.3
- name: Generate files
run: go generate ./...
- name: Check for changes in generated code
run: |
git diff -- '*.pb.go' || (echo "Rerun go generate ./... locally and resubmit" && exit -1)
excludereplace:
name: Exclude replace in go.mod
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v2
- name: Exclude replace in go.mod
run: |
grep ^replace go.mod || exit 0
exit 1
exclude-replace:
uses: networkservicemesh/.github/.github/workflows/exclude-replace.yaml@main
113 changes: 44 additions & 69 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
run:
# concurrency: 6
go: "1.17"
go: "1.23"
timeout: 2m
issues-exit-code: 1
tests: true
Expand All @@ -11,41 +11,61 @@ linters-settings:
values:
regexp:
company: .*
copyright-holder: Copyright \(c\) ({{year-range}}) {{company}}\n\n
copyright-holder: Copyright \(c\) ({{mod-year-range}}) {{company}}\n\n
copyright-holders: ({{copyright-holder}})+
errcheck:
check-type-assertions: false
check-blank: false
govet:
check-shadowing: true
enable:
- shadow
settings:
printf:
funcs:
- (github.com/sirupsen/logrus.FieldLogger).Infof
- (github.com/sirupsen/logrus.FieldLogger).Warnf
- (github.com/sirupsen/logrus.FieldLogger).Errorf
- (github.com/sirupsen/logrus.FieldLogger).Fatalf
golint:
min-confidence: 0.8
depguard:
rules:
main:
deny:
- pkg: "errors"
desc: "Please use \"github.com/pkg/errors\" instead of \"errors\" in go imports"
revive:
confidence: 0.8
rules:
- name: exported
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: exported
- name: increment-decrement
- name: var-naming
- name: package-comments
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
- name: superfluous-else
- name: unreachable-code
goimports:
local-prefixes: github.com/networkservicemesh/api
gocyclo:
min-complexity: 15
maligned:
suggest-new: true
dupl:
threshold: 150
goconst:
min-len: 2
min-occurrences: 2
depguard:
list-type: blacklist
include-go-root: false
packages:
- errors
packages-with-error-message:
# specify an error message to output when a blacklisted package is used
- errors: "Please use \"github.com/pkg/errors\" instead of \"errors\" in go imports"
lll:
line-length: 160
misspell:
locale: US
unparam:
Expand All @@ -58,79 +78,47 @@ linters-settings:
for-loops: false
gocritic:
enabled-checks:
- appendAssign
- assignOp
- appendCombine
- argOrder
- badCall
- badCond
- boolExprSimplify
- builtinShadow
- captLocal
- caseOrder
- codegenComment
- commentFormatting
- commentedOutCode
- commentedOutImport
- defaultCaseOrder
- deprecatedComment
- docStub
- dupArg
- dupBranchBody
- dupCase
- dupImport
- dupSubExpr
- elseif
- emptyFallthrough
- emptyStringTest
- equalFold
- evalOrder
- exitAfterDefer
- flagDeref
- flagName
- hexLiteral
- hugeParam
- ifElseChain
- importShadow
- indexAlloc
- initClause
- methodExprCall
- nestingReduce
- newDeref
- nilValReturn
- octalLiteral
- offBy1
- paramTypeCombine
- ptrToRefParam
- rangeExprCopy
- rangeValCopy
- regexpMust
- regexpPattern
- singleCaseSwitch
- sloppyLen
- sloppyReassign
- stringXbytes
- switchTrue
- typeAssertChain
- typeSwitchVar
- typeUnparen
- unlabelStmt
- unnamedResult
- unnecessaryBlock
- underef
- unlambda
- unslice
- valSwap
- weakCond
- wrapperFunc
- yodaStyleExpr
linters:
disable-all: true
enable:
# - rowserrcheck
- depguard
- revive
- rowserrcheck
- goheader
- bodyclose
- deadcode
- dogsled
- dupl
- errcheck
Expand All @@ -141,43 +129,30 @@ linters:
- gocyclo
- gofmt
- goimports
- golint
- gosec
- gosimple
- govet
- ineffassign
- interfacer
# - lll
- lll
- misspell
- nakedret
- scopelint
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
# - unused
- varcheck
- unused
- whitespace
issues:
exclude-use-default: false
max-issues-per-linter: 0
max-same-issues: 0
exclude-rules:
- path: pkg/api/networkservice/mechanism_helpers.go
linters:
- interfacer
text: "can be `github.com/golang/protobuf/proto.Message"
- path: pkg/api/networkservice/connection_helpers.go
linters:
- interfacer
text: "can be `github.com/golang/protobuf/proto.Message"
- path: pkg/api/networkservice/path_segment_helpers.go
linters:
- interfacer
text: "can be `github.com/golang/protobuf/proto.Message"
- path: pkg/api/networkservice/connectioncontext_helpers_test.go
linters:
- funlen
text: "Function 'TestParsePortRange' is too long"
- path: pkg/api/networkservice
linters:
- gosec
text: "G115"
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/networkservicemesh/api

go 1.20
go 1.23

require (
github.com/pkg/errors v0.9.1
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down
3 changes: 2 additions & 1 deletion pkg/api/networkservice/mechanisms/kernel/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ package kernel

import (
"bytes"
"errors"
"net"
"strconv"
"strings"
"text/template"

"github.com/pkg/errors"

"github.com/networkservicemesh/api/pkg/api/networkservice"
"github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/cls"
)
Expand Down

0 comments on commit df76555

Please sign in to comment.