Skip to content

Commit

Permalink
ci: updated the latest conf and use supported Go versions
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaost committed Nov 11, 2024
1 parent b3ca76e commit 9bfa880
Show file tree
Hide file tree
Showing 34 changed files with 279 additions and 271 deletions.
47 changes: 30 additions & 17 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,60 @@ jobs:
compatibility-test:
strategy:
matrix:
go: [ 1.15, 1.22 ]
# - "ubuntu-latest" is for Linux with X64 CPU, hosted by GitHub,
# fewer CPUs but high speed international network
# - "ARM64" is for Linux with ARM64 CPU, hosted by bytedance,
# more CPUs but inside CN internet which may download go cache slowly.
# GitHub don't have free runner with ARM CPU.
os: [ ubuntu-latest, ARM64 ]
go: [ 1.18, 1.23 ]
os: [ X64, ARM64 ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
cache: false
- name: Unit Test
run: go test -timeout=2m -v -race -covermode=atomic -coverprofile=coverage.out ./...
- name: Benchmark
run: go test -bench=. -benchmem -run=none ./...

windows-test:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22
go-version: stable
- name: Build Test
run: go vet -v ./...
style-test:

compliant:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.16

- name: Check License Header
uses: apache/skywalking-eyes/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Lint
run: |
test -z "$(gofmt -s -l .)"
go vet -stdmethods=false $(go list ./...)

- name: Check Spell
uses: crate-ci/[email protected]

golangci-lint:
runs-on: [ self-hosted, X64 ]
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
# for self-hosted, the cache path is shared across projects
# and it works well without the cache of github actions
# Enable it if we're going to use Github only
cache: false

- name: Golangci Lint
# https://golangci-lint.run/
uses: golangci/golangci-lint-action@v6
with:
version: latest
25 changes: 0 additions & 25 deletions .github/workflows/release-check.yml

This file was deleted.

41 changes: 41 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Options for analysis running.
run:
# include `vendor` `third_party` `testdata` `examples` `Godeps` `builtin`
skip-dirs-use-default: true
skip-dirs:
- kitex_gen
skip-files:
- ".*\\.mock\\.go$"
# output configuration options
output:
# Format: colored-line-number|line-number|json|tab|checkstyle|code-climate|junit-xml|github-actions
format: colored-line-number
# All available settings of specific linters.
# Refer to https://golangci-lint.run/usage/linters
linters-settings:
gofumpt:
# Choose whether to use the extra rules.
# Default: false
extra-rules: true
goimports:
# Put imports beginning with prefix after 3rd-party packages.
# It's a comma-separated list of prefixes.
local-prefixes: github.com/cloudwego/kitex
govet:
# Disable analyzers by name.
# Run `go tool vet help` to see all analyzers.
disable:
- stdmethods
linters:
enable:
- gofumpt
- goimports
- gofmt
disable:
- errcheck
- typecheck
- deadcode
- varcheck
- staticcheck
issues:
exclude-use-default: true
11 changes: 3 additions & 8 deletions connection_errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const ErrnoMask = 0xFF

// wrap Errno, implement xerrors.Wrapper
func Exception(err error, suffix string) error {
var no, ok = err.(syscall.Errno)
no, ok := err.(syscall.Errno)
if !ok {
if suffix == "" {
return err
Expand All @@ -54,9 +54,7 @@ func Exception(err error, suffix string) error {
return &exception{no: no, suffix: suffix}
}

var (
_ net.Error = (*exception)(nil)
)
var _ net.Error = (*exception)(nil)

type exception struct {
no syscall.Errno
Expand Down Expand Up @@ -100,10 +98,7 @@ func (e *exception) Timeout() bool {
case ErrDialTimeout, ErrReadTimeout, ErrWriteTimeout:
return true
}
if e.no.Timeout() {
return true
}
return false
return e.no.Timeout()
}

func (e *exception) Temporary() bool {
Expand Down
9 changes: 3 additions & 6 deletions connection_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,8 @@ func (c *connection) flush() error {
return nil
}
// TODO: Let the upper layer pass in whether to use ZeroCopy.
var bs = c.outputBuffer.GetBytes(c.outputBarrier.bs)
var n, err = sendmsg(c.fd, bs, c.outputBarrier.ivs, false && c.supportZeroCopy)
bs := c.outputBuffer.GetBytes(c.outputBarrier.bs)
n, err := sendmsg(c.fd, bs, c.outputBarrier.ivs, false && c.supportZeroCopy)
if err != nil && err != syscall.EAGAIN {
return Exception(err, "when flush")
}
Expand All @@ -510,10 +510,7 @@ func (c *connection) flush() error {

func (c *connection) waitFlush() (err error) {
if c.writeTimeout == 0 {
select {
case err = <-c.writeTrigger:
}
return err
return <-c.writeTrigger
}

// set write timeout
Expand Down
17 changes: 9 additions & 8 deletions connection_onevent.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (c *connection) AddCloseCallback(callback CloseCallback) error {
if callback == nil {
return nil
}
var cb = &callbackNode{}
cb := &callbackNode{}
cb.fn = callback
if pre := c.closeCallbacks.Load(); pre != nil {
cb.pre = pre.(*callbackNode)
Expand Down Expand Up @@ -132,7 +132,7 @@ func (c *connection) onPrepare(opts *options) (err error) {

// onConnect is responsible for executing onRequest if there is new data coming after onConnect callback finished.
func (c *connection) onConnect() {
var onConnect, _ = c.onConnectCallback.Load().(OnConnect)
onConnect, _ := c.onConnectCallback.Load().(OnConnect)
if onConnect == nil {
c.changeState(connStateNone, connStateConnected)
return
Expand All @@ -141,17 +141,17 @@ func (c *connection) onConnect() {
// it never happens because onDisconnect will not lock connecting if c.connected == 0
return
}
var onRequest, _ = c.onRequestCallback.Load().(OnRequest)
onRequest, _ := c.onRequestCallback.Load().(OnRequest)
c.onProcess(onConnect, onRequest)
}

// when onDisconnect called, c.IsActive() must return false
func (c *connection) onDisconnect() {
var onDisconnect, _ = c.onDisconnectCallback.Load().(OnDisconnect)
onDisconnect, _ := c.onDisconnectCallback.Load().(OnDisconnect)
if onDisconnect == nil {
return
}
var onConnect, _ = c.onConnectCallback.Load().(OnConnect)
onConnect, _ := c.onConnectCallback.Load().(OnConnect)
if onConnect == nil {
// no need lock if onConnect is nil
// it's ok to force set state to disconnected since onConnect is nil
Expand All @@ -175,7 +175,7 @@ func (c *connection) onDisconnect() {

// onRequest is responsible for executing the closeCallbacks after the connection has been closed.
func (c *connection) onRequest() (needTrigger bool) {
var onRequest, ok = c.onRequestCallback.Load().(OnRequest)
onRequest, ok := c.onRequestCallback.Load().(OnRequest)
if !ok {
return true
}
Expand Down Expand Up @@ -272,6 +272,7 @@ func (c *connection) onProcess(onConnect OnConnect, onRequest OnRequest) (proces
panicked = false
return
}

// add new task
runTask(c.ctx, task)
return true
Expand All @@ -280,7 +281,7 @@ func (c *connection) onProcess(onConnect OnConnect, onRequest OnRequest) (proces
// closeCallback .
// It can be confirmed that closeCallback and onRequest will not be executed concurrently.
// If onRequest is still running, it will trigger closeCallback on exit.
func (c *connection) closeCallback(needLock bool, needDetach bool) (err error) {
func (c *connection) closeCallback(needLock, needDetach bool) (err error) {
if needLock && !c.lock(processing) {
return nil
}
Expand All @@ -290,7 +291,7 @@ func (c *connection) closeCallback(needLock bool, needDetach bool) (err error) {
logger.Printf("NETPOLL: closeCallback[%v,%v] detach operator failed: %v", needLock, needDetach, err)
}
}
var latest = c.closeCallbacks.Load()
latest := c.closeCallbacks.Load()
if latest == nil {
return nil
}
Expand Down
12 changes: 6 additions & 6 deletions connection_reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ func (c *connection) onHup(p Poll) error {
// It depends on closing by user if OnConnect and OnRequest is nil, otherwise it needs to be released actively.
// It can be confirmed that the OnRequest goroutine has been exited before closeCallback executing,
// and it is safe to close the buffer at this time.
var onConnect = c.onConnectCallback.Load()
var onRequest = c.onRequestCallback.Load()
var needCloseByUser = onConnect == nil && onRequest == nil
onConnect := c.onConnectCallback.Load()
onRequest := c.onRequestCallback.Load()
needCloseByUser := onConnect == nil && onRequest == nil
if !needCloseByUser {
// already PollDetach when call OnHup
c.closeCallback(true, false)
Expand Down Expand Up @@ -69,8 +69,8 @@ func (c *connection) onClose() error {

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

var needTrigger = true
needTrigger := true
if length == n { // first start onRequest
needTrigger = c.onRequest()
}
Expand Down
Loading

0 comments on commit 9bfa880

Please sign in to comment.