Skip to content

Commit 44a7f98

Browse files
authored
ci: updated the latest conf and use supported Go versions (#367)
1 parent b3ca76e commit 44a7f98

35 files changed

+303
-301
lines changed

.github/workflows/pr-check.yml

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,47 +6,60 @@ jobs:
66
compatibility-test:
77
strategy:
88
matrix:
9-
go: [ 1.15, 1.22 ]
10-
# - "ubuntu-latest" is for Linux with X64 CPU, hosted by GitHub,
11-
# fewer CPUs but high speed international network
12-
# - "ARM64" is for Linux with ARM64 CPU, hosted by bytedance,
13-
# more CPUs but inside CN internet which may download go cache slowly.
14-
# GitHub don't have free runner with ARM CPU.
15-
os: [ ubuntu-latest, ARM64 ]
9+
go: [ 1.18, 1.23 ]
10+
os: [ X64, ARM64 ]
1611
runs-on: ${{ matrix.os }}
1712
steps:
1813
- uses: actions/checkout@v4
1914
- name: Set up Go
2015
uses: actions/setup-go@v5
2116
with:
2217
go-version: ${{ matrix.go }}
18+
cache: false
2319
- name: Unit Test
24-
run: go test -timeout=2m -v -race -covermode=atomic -coverprofile=coverage.out ./...
20+
run: go test -timeout=2m -race ./...
2521
- name: Benchmark
26-
run: go test -bench=. -benchmem -run=none ./...
22+
run: go test -bench=. -benchmem -run=none ./... -benchtime=100ms
23+
2724
windows-test:
2825
runs-on: windows-latest
2926
steps:
3027
- uses: actions/checkout@v4
3128
- name: Set up Go
3229
uses: actions/setup-go@v5
3330
with:
34-
go-version: 1.22
31+
go-version: stable
3532
- name: Build Test
36-
run: go vet -v ./...
37-
style-test:
33+
run: go vet ./...
34+
35+
compliant:
3836
runs-on: ubuntu-latest
3937
steps:
4038
- uses: actions/checkout@v4
41-
- name: Set up Go
42-
uses: actions/setup-go@v5
43-
with:
44-
go-version: 1.16
39+
4540
- name: Check License Header
4641
uses: apache/skywalking-eyes/[email protected]
4742
env:
4843
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49-
- name: Lint
50-
run: |
51-
test -z "$(gofmt -s -l .)"
52-
go vet -stdmethods=false $(go list ./...)
44+
45+
- name: Check Spell
46+
uses: crate-ci/[email protected]
47+
48+
golangci-lint:
49+
runs-on: [ self-hosted, X64 ]
50+
steps:
51+
- uses: actions/checkout@v4
52+
- name: Set up Go
53+
uses: actions/setup-go@v5
54+
with:
55+
go-version: stable
56+
# for self-hosted, the cache path is shared across projects
57+
# and it works well without the cache of github actions
58+
# Enable it if we're going to use Github only
59+
cache: false
60+
61+
- name: Golangci Lint
62+
# https://golangci-lint.run/
63+
uses: golangci/golangci-lint-action@v6
64+
with:
65+
version: latest

.github/workflows/release-check.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.golangci.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
output:
2+
# Format: colored-line-number|line-number|json|tab|checkstyle|code-climate|junit-xml|github-actions
3+
format: colored-line-number
4+
# All available settings of specific linters.
5+
# Refer to https://golangci-lint.run/usage/linters
6+
linters-settings:
7+
gofumpt:
8+
# Choose whether to use the extra rules.
9+
# Default: false
10+
extra-rules: true
11+
goimports:
12+
# Put imports beginning with prefix after 3rd-party packages.
13+
# It's a comma-separated list of prefixes.
14+
local-prefixes: github.com/cloudwego/kitex
15+
govet:
16+
# Disable analyzers by name.
17+
# Run `go tool vet help` to see all analyzers.
18+
disable:
19+
- stdmethods
20+
linters:
21+
enable:
22+
- gofumpt
23+
- goimports
24+
- gofmt
25+
disable:
26+
- errcheck
27+
- typecheck
28+
- deadcode
29+
- varcheck
30+
- staticcheck
31+
issues:
32+
exclude-use-default: true

connection_errors.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const ErrnoMask = 0xFF
4444

4545
// wrap Errno, implement xerrors.Wrapper
4646
func Exception(err error, suffix string) error {
47-
var no, ok = err.(syscall.Errno)
47+
no, ok := err.(syscall.Errno)
4848
if !ok {
4949
if suffix == "" {
5050
return err
@@ -54,9 +54,7 @@ func Exception(err error, suffix string) error {
5454
return &exception{no: no, suffix: suffix}
5555
}
5656

57-
var (
58-
_ net.Error = (*exception)(nil)
59-
)
57+
var _ net.Error = (*exception)(nil)
6058

6159
type exception struct {
6260
no syscall.Errno
@@ -100,10 +98,7 @@ func (e *exception) Timeout() bool {
10098
case ErrDialTimeout, ErrReadTimeout, ErrWriteTimeout:
10199
return true
102100
}
103-
if e.no.Timeout() {
104-
return true
105-
}
106-
return false
101+
return e.no.Timeout()
107102
}
108103

109104
func (e *exception) Temporary() bool {

connection_impl.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,8 @@ func (c *connection) flush() error {
484484
return nil
485485
}
486486
// TODO: Let the upper layer pass in whether to use ZeroCopy.
487-
var bs = c.outputBuffer.GetBytes(c.outputBarrier.bs)
488-
var n, err = sendmsg(c.fd, bs, c.outputBarrier.ivs, false && c.supportZeroCopy)
487+
bs := c.outputBuffer.GetBytes(c.outputBarrier.bs)
488+
n, err := sendmsg(c.fd, bs, c.outputBarrier.ivs, false && c.supportZeroCopy)
489489
if err != nil && err != syscall.EAGAIN {
490490
return Exception(err, "when flush")
491491
}
@@ -510,10 +510,7 @@ func (c *connection) flush() error {
510510

511511
func (c *connection) waitFlush() (err error) {
512512
if c.writeTimeout == 0 {
513-
select {
514-
case err = <-c.writeTrigger:
515-
}
516-
return err
513+
return <-c.writeTrigger
517514
}
518515

519516
// set write timeout

connection_onevent.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func (c *connection) AddCloseCallback(callback CloseCallback) error {
9494
if callback == nil {
9595
return nil
9696
}
97-
var cb = &callbackNode{}
97+
cb := &callbackNode{}
9898
cb.fn = callback
9999
if pre := c.closeCallbacks.Load(); pre != nil {
100100
cb.pre = pre.(*callbackNode)
@@ -132,7 +132,7 @@ func (c *connection) onPrepare(opts *options) (err error) {
132132

133133
// onConnect is responsible for executing onRequest if there is new data coming after onConnect callback finished.
134134
func (c *connection) onConnect() {
135-
var onConnect, _ = c.onConnectCallback.Load().(OnConnect)
135+
onConnect, _ := c.onConnectCallback.Load().(OnConnect)
136136
if onConnect == nil {
137137
c.changeState(connStateNone, connStateConnected)
138138
return
@@ -141,17 +141,17 @@ func (c *connection) onConnect() {
141141
// it never happens because onDisconnect will not lock connecting if c.connected == 0
142142
return
143143
}
144-
var onRequest, _ = c.onRequestCallback.Load().(OnRequest)
144+
onRequest, _ := c.onRequestCallback.Load().(OnRequest)
145145
c.onProcess(onConnect, onRequest)
146146
}
147147

148148
// when onDisconnect called, c.IsActive() must return false
149149
func (c *connection) onDisconnect() {
150-
var onDisconnect, _ = c.onDisconnectCallback.Load().(OnDisconnect)
150+
onDisconnect, _ := c.onDisconnectCallback.Load().(OnDisconnect)
151151
if onDisconnect == nil {
152152
return
153153
}
154-
var onConnect, _ = c.onConnectCallback.Load().(OnConnect)
154+
onConnect, _ := c.onConnectCallback.Load().(OnConnect)
155155
if onConnect == nil {
156156
// no need lock if onConnect is nil
157157
// it's ok to force set state to disconnected since onConnect is nil
@@ -170,12 +170,11 @@ func (c *connection) onDisconnect() {
170170
return
171171
}
172172
// OnConnect is not finished yet, return and let onConnect helps to call onDisconnect
173-
return
174173
}
175174

176175
// onRequest is responsible for executing the closeCallbacks after the connection has been closed.
177176
func (c *connection) onRequest() (needTrigger bool) {
178-
var onRequest, ok = c.onRequestCallback.Load().(OnRequest)
177+
onRequest, ok := c.onRequestCallback.Load().(OnRequest)
179178
if !ok {
180179
return true
181180
}
@@ -270,8 +269,8 @@ func (c *connection) onProcess(onConnect OnConnect, onRequest OnRequest) (proces
270269
}
271270
// task exits
272271
panicked = false
273-
return
274-
}
272+
} // end of task closure func
273+
275274
// add new task
276275
runTask(c.ctx, task)
277276
return true
@@ -280,7 +279,7 @@ func (c *connection) onProcess(onConnect OnConnect, onRequest OnRequest) (proces
280279
// closeCallback .
281280
// It can be confirmed that closeCallback and onRequest will not be executed concurrently.
282281
// If onRequest is still running, it will trigger closeCallback on exit.
283-
func (c *connection) closeCallback(needLock bool, needDetach bool) (err error) {
282+
func (c *connection) closeCallback(needLock, needDetach bool) (err error) {
284283
if needLock && !c.lock(processing) {
285284
return nil
286285
}
@@ -290,7 +289,7 @@ func (c *connection) closeCallback(needLock bool, needDetach bool) (err error) {
290289
logger.Printf("NETPOLL: closeCallback[%v,%v] detach operator failed: %v", needLock, needDetach, err)
291290
}
292291
}
293-
var latest = c.closeCallbacks.Load()
292+
latest := c.closeCallbacks.Load()
294293
if latest == nil {
295294
return nil
296295
}

connection_reactor.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ func (c *connection) onHup(p Poll) error {
3737
// It depends on closing by user if OnConnect and OnRequest is nil, otherwise it needs to be released actively.
3838
// It can be confirmed that the OnRequest goroutine has been exited before closeCallback executing,
3939
// and it is safe to close the buffer at this time.
40-
var onConnect = c.onConnectCallback.Load()
41-
var onRequest = c.onRequestCallback.Load()
42-
var needCloseByUser = onConnect == nil && onRequest == nil
40+
onConnect := c.onConnectCallback.Load()
41+
onRequest := c.onRequestCallback.Load()
42+
needCloseByUser := onConnect == nil && onRequest == nil
4343
if !needCloseByUser {
4444
// already PollDetach when call OnHup
4545
c.closeCallback(true, false)
@@ -69,8 +69,8 @@ func (c *connection) onClose() error {
6969

7070
// closeBuffer recycle input & output LinkBuffer.
7171
func (c *connection) closeBuffer() {
72-
var onConnect, _ = c.onConnectCallback.Load().(OnConnect)
73-
var onRequest, _ = c.onRequestCallback.Load().(OnRequest)
72+
onConnect, _ := c.onConnectCallback.Load().(OnConnect)
73+
onRequest, _ := c.onRequestCallback.Load().(OnRequest)
7474
// if client close the connection, we cannot ensure that the poller is not process the buffer,
7575
// so we need to check the buffer length, and if it's an "unclean" close operation, let's give up to reuse the buffer
7676
if c.inputBuffer.Len() == 0 || onConnect != nil || onRequest != nil {
@@ -108,7 +108,7 @@ func (c *connection) inputAck(n int) (err error) {
108108
c.maxSize = mallocMax
109109
}
110110

111-
var needTrigger = true
111+
needTrigger := true
112112
if length == n { // first start onRequest
113113
needTrigger = c.onRequest()
114114
}

0 commit comments

Comments
 (0)