Skip to content

Commit f8ccfbb

Browse files
authored
Merge pull request #92 from marsevilspirit/refactor/ci
refactor(ci): big refactor for upgrade to go 1.25
2 parents 1054b17 + 155569d commit f8ccfbb

File tree

202 files changed

+2742
-490
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

202 files changed

+2742
-490
lines changed

.github/workflows/github-actions.yml

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,61 +7,61 @@ on:
77
branches: "*"
88

99
jobs:
10+
license:
11+
name: Check License Header
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Check License Header
17+
uses: apache/skywalking-eyes/header@main #NOSONAR
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
with:
21+
config: .licenserc.yaml
22+
mode: check
1023

11-
build:
12-
name: Build
24+
CI:
25+
name: CI
1326
runs-on: ${{ matrix.os }}
1427
strategy:
1528
# If you want to matrix build , you can append the following list.
1629
matrix:
1730
go_version:
18-
- '1.20'
31+
- '1.25'
1932
os:
2033
- ubuntu-latest
2134

2235
steps:
2336

2437
- name: Set up Go ${{ matrix.go_version }}
25-
uses: actions/setup-go@v2
38+
uses: actions/setup-go@v5
2639
with:
2740
go-version: ${{ matrix.go_version }}
28-
id: go
2941

3042
- name: Check out code into the Go module directory
31-
uses: actions/checkout@v2
43+
uses: actions/checkout@v4
3244

3345
- name: Cache Go Dependence
34-
uses: actions/cache@v2
46+
# ref: https://github.com/actions/cache/blob/main/examples.md#go---module
47+
uses: actions/cache@v4
3548
with:
36-
path: ~/go/pkg/mod
49+
# Cache, works only on Linux
50+
path: |
51+
~/.cache/go-build
52+
~/go/pkg/mod
3753
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
54+
# An ordered list of keys to use for restoring the cache if no cache hit occurred for key
3855
restore-keys: ${{ runner.os }}-go-
3956

40-
- name: Get dependencies
41-
run: |
42-
if [ -f Gopkg.toml ]; then
43-
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
44-
dep ensure
45-
else
46-
go get -v -t -d ./...
47-
fi
48-
49-
- name: License Check
50-
run: |
51-
sh before_validate_license.sh
52-
chmod u+x /tmp/tools/license/license-header-checker
53-
go fmt ./... && [[ -z `git status -s` ]]
54-
/tmp/tools/license/license-header-checker -v -a -r -i vendor /tmp/tools/license/license.txt . go && [[ -z `git status -s` ]]
57+
- name: Check Code Format
58+
run: make fmt && git status && [[ -z `git status -s` ]]
5559

56-
- name: Install go ci lint
57-
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.56.0
60+
- name: Unit Test
61+
run: make test
5862

59-
- name: Run Linter
60-
run: golangci-lint run --timeout=10m -v --disable-all --enable=govet --enable=staticcheck --enable=ineffassign --enable=misspell
61-
62-
- name: Test
63-
run: go mod vendor && go test $(go list ./... | grep -v vendor | grep -v demo) -coverprofile=coverage.txt -covermode=atomic
63+
- name: Lint
64+
run: make lint
6465

6566
- name: Coverage
6667
run: bash <(curl -s https://codecov.io/bash)
67-

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ classes
2020
*.swp
2121

2222
vendor/
23+
24+
coverage.txt

.licenserc.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
header:
2+
license:
3+
spdx-id: Apache-2.0
4+
content: |
5+
Licensed to the Apache Software Foundation (ASF) under one or more
6+
contributor license agreements. See the NOTICE file distributed with
7+
this work for additional information regarding copyright ownership.
8+
The ASF licenses this file to You under the Apache License, Version 2.0
9+
(the "License"); you may not use this file except in compliance with
10+
the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing, software
15+
distributed under the License is distributed on an "AS IS" BASIS,
16+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
See the License for the specific language governing permissions and
18+
limitations under the License.
19+
20+
paths-ignore:
21+
- '**/*.md'
22+
- '**/*.json'
23+
- '**/*.properties'
24+
- '**/*.proto'
25+
- '**/*.tpl'
26+
- '**/*.crt'
27+
- '**/*.key'
28+
- '**/*.js'
29+
- '**/*.css'
30+
- '**/go.mod'
31+
- '**/go.sum'
32+
- '.git/'
33+
- '.github/**'
34+
- '.gitignore'
35+
- '.gitmodules'
36+
- 'LICENSE'
37+
- 'NOTICE'
38+
- '**/*.hessian2.go'
39+
- '**/*.triple.openapi.yaml'
40+
- 'protocol/triple/triple_protocol'
41+
- 'protocol/triple/reflection/serverreflection.go'
42+
43+
comment: on-failure
44+
45+
# If you don't want to check dependencies' license compatibility, remove the following part
46+
dependency:
47+
files:
48+
- go.mod

.travis.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
116
language: go
217

318
os:

Makefile

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
SHELL := bash
17+
.DELETE_ON_ERROR:
18+
.DEFAULT_GOAL := help
19+
.SHELLFLAGS := -eu -o pipefail -c
20+
MAKEFLAGS += --warn-undefined-variables
21+
MAKEFLAGS += --no-builtin-rules
22+
MAKEFLAGS += --no-print-directory
23+
24+
.PHONY: help test fmt clean lint
25+
26+
help:
27+
@echo "Available commands:"
28+
@echo " test - Run unit tests"
29+
@echo " clean - Clean test generate files"
30+
@echo " fmt - Format code"
31+
@echo " lint - Run golangci-lint"
32+
33+
# Run unit tests
34+
test: clean
35+
# For go 1.25.0
36+
go env -w GOTOOLCHAIN=go1.25.0+auto
37+
go test ./... -coverprofile=coverage.txt -covermode=atomic
38+
39+
fmt: install-imports-formatter
40+
go fmt ./... && GOROOT=$(shell go env GOROOT) imports-formatter
41+
42+
# Clean test generate files
43+
clean:
44+
rm -rf coverage.txt
45+
46+
# Run golangci-lint
47+
lint: install-golangci-lint
48+
go vet ./...
49+
golangci-lint run ./... --timeout=10m
50+
51+
install-golangci-lint:
52+
go install github.com/golangci/golangci-lint/v2/cmd/[email protected]
53+
54+
install-imports-formatter:
55+
go install github.com/dubbogo/tools/cmd/imports-formatter@latest

before_validate_license.sh

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

examples/build_all.sh

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
#!/usr/bin/env bash
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
217
# ******************************************************
318
# DESC :
419
# AUTHOR : Alex Stocks
@@ -22,9 +37,9 @@ cd echo/ws-echo/server && sh assembly/mac/dev.sh && rm -rf target && cd -
2237
cd echo/wss-echo/client && sh assembly/mac/dev.sh && rm -rf target && cd -
2338
cd echo/wss-echo/server && sh assembly/mac/dev.sh && rm -rf target && cd -
2439

25-
cd rpc/client && sh assembly/mac/dev.sh && rm -rf target && cd -
26-
cd rpc/server && sh assembly/mac/dev.sh && rm -rf target && cd -
40+
# cd rpc/client && sh assembly/mac/dev.sh && rm -rf target && cd -
41+
# cd rpc/server && sh assembly/mac/dev.sh && rm -rf target && cd -
2742

28-
cd micro/client && sh assembly/mac/dev.sh && rm -rf target && cd -
29-
cd micro/server && sh assembly/mac/dev.sh && rm -rf target && cd -
43+
# cd micro/client && sh assembly/mac/dev.sh && rm -rf target && cd -
44+
# cd micro/server && sh assembly/mac/dev.sh && rm -rf target && cd -
3045

examples/echo/tcp-echo/client/app/client.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,16 @@ import (
2626

2727
import (
2828
"github.com/AlexStocks/getty/transport"
29-
)
30-
31-
import (
3229
log "github.com/AlexStocks/getty/util"
3330
)
3431

3532
var (
3633
reqID uint32
37-
src = rand.NewSource(time.Now().UnixNano())
34+
r *rand.Rand
3835
)
3936

4037
func init() {
41-
rand.Seed(time.Now().UnixNano())
38+
r = rand.New(rand.NewSource(time.Now().UnixNano()))
4239
}
4340

4441
////////////////////////////////////////////////////////////////////
@@ -52,11 +49,7 @@ type EchoClient struct {
5249
}
5350

5451
func (c *EchoClient) isAvailable() bool {
55-
if c.selectSession() == nil {
56-
return false
57-
}
58-
59-
return true
52+
return c.selectSession() != nil
6053
}
6154

6255
func (c *EchoClient) close() {
@@ -84,7 +77,7 @@ func (c *EchoClient) selectSession() getty.Session {
8477
return nil
8578
}
8679

87-
return c.sessions[rand.Int31n(int32(count))].session
80+
return c.sessions[r.Int31n(int32(count))].session
8881
}
8982

9083
func (c *EchoClient) addSession(session getty.Session) {
@@ -159,7 +152,7 @@ func (c *EchoClient) getClientEchoSession(session getty.Session) (clientEchoSess
159152
func (c *EchoClient) heartbeat(session getty.Session) {
160153
var pkg EchoPackage
161154
pkg.H.Magic = echoPkgMagic
162-
pkg.H.LogID = (uint32)(src.Int63())
155+
pkg.H.LogID = (uint32)(r.Int63())
163156
pkg.H.Sequence = atomic.AddUint32(&reqID, 1)
164157
// pkg.H.ServiceID = 0
165158
pkg.H.Command = heartbeatCmd

0 commit comments

Comments
 (0)