Skip to content

Commit 3bed71b

Browse files
authored
Merge pull request #32 from c9s/c9s/add-workflows
CI: add workflows
2 parents b4820f4 + 057b568 commit 3bed71b

File tree

7 files changed

+165
-22
lines changed

7 files changed

+165
-22
lines changed

.github/workflows/go.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Go
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
pull_request:
8+
# types: [synchronize, opened, reopened, edited]
9+
# branches:
10+
# - "main"
11+
# - "v*"
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 15
17+
18+
strategy:
19+
matrix:
20+
redis-version:
21+
- "6.2"
22+
go-version:
23+
- "1.25"
24+
env:
25+
GITHUB_CI: true
26+
MYSQL_DATABASE: bbgo
27+
MYSQL_USER: "root"
28+
MYSQL_PASSWORD: "root" # pragma: allowlist secret
29+
30+
steps:
31+
32+
- uses: actions/checkout@v6
33+
with:
34+
# lfs: 'true'
35+
ssh-key: ${{ secrets.git_ssh_key }}
36+
37+
- uses: actions/cache@v4
38+
with:
39+
path: |
40+
~/.cache/go-build
41+
~/go/pkg/mod
42+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
43+
restore-keys: |
44+
${{ runner.os }}-go-
45+
46+
- name: Set up MySQL
47+
run: |
48+
sudo /etc/init.d/mysql start
49+
mysql -e 'CREATE DATABASE ${{ env.MYSQL_DATABASE }};' -u${{ env.MYSQL_USER }} -p${{ env.MYSQL_PASSWORD }}
50+
51+
- name: Set up redis
52+
uses: shogo82148/actions-setup-redis@v1
53+
with:
54+
redis-version: ${{ matrix.redis-version }}
55+
# auto-start: "false"
56+
57+
- name: Set up Go
58+
uses: actions/setup-go@v6
59+
with:
60+
go-version: ${{ matrix.go-version }}
61+
62+
- name: Test
63+
run: |
64+
go test -count 3 -race -coverprofile coverage.txt -covermode atomic ./...
65+
sed -i -e '/_requestgen.go/d' coverage.txt
66+
67+
- name: Revive Check
68+
uses: morphy2k/revive-action@v2.7.7 # https://github.com/mgechev/revive/issues/956
69+
with:
70+
reporter: github-pr-review
71+
fail_on_error: true
72+
73+
- name: Upload Coverage Report
74+
uses: codecov/codecov-action@v5
75+
with:
76+
files: ./coverage.txt,./coverage_dnum.txt
77+

.github/workflows/golang-lint.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: golang-lint
2+
on:
3+
push:
4+
branches: [ main ]
5+
pull_request:
6+
7+
permissions:
8+
contents: read
9+
pull-requests: read
10+
checks: write
11+
12+
jobs:
13+
golangci:
14+
name: lint
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v6
18+
- uses: actions/setup-go@v6
19+
with:
20+
go-version: '1.25'
21+
- name: golangci-lint
22+
uses: golangci/golangci-lint-action@v8
23+
with:
24+
version: 'v2.6'

.golangci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
version: "2"
2+
run:
3+
issues-exit-code: 0
4+
tests: true
5+
linters:
6+
default: none
7+
enable:
8+
- staticcheck
9+
- bodyclose
10+
- contextcheck
11+
- dupword
12+
- decorder
13+
- goconst
14+
- govet
15+
- gosec
16+
- misspell
17+
exclusions:
18+
generated: lax
19+
presets:
20+
- comments
21+
- common-false-positives
22+
- legacy
23+
- std-error-handling
24+
paths:
25+
- third_party$
26+
- builtin$
27+
- examples$
28+
formatters:
29+
enable:
30+
- gofmt
31+
exclusions:
32+
generated: lax
33+
paths:
34+
- third_party$
35+
- builtin$
36+
- examples$

client_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import (
99
)
1010

1111
func TestClient(t *testing.T) {
12-
baseURL, err := url.Parse("https://api.binance.com")
12+
baseURL, err := url.Parse("https://api.binance.us")
1313
assert.NoError(t, err)
1414

1515
ctx := context.Background()
1616
apiClient := &BaseAPIClient{
17-
BaseURL: baseURL,
17+
BaseURL: baseURL,
1818
}
1919

20-
req, err := apiClient.NewRequest(ctx, "GET", "/api/v3/ping", nil , nil)
20+
req, err := apiClient.NewRequest(ctx, "GET", "/api/v3/ping", nil, nil)
2121
if assert.NoError(t, err) {
2222
assert.NotNil(t, req)
2323

go.mod

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module github.com/c9s/requestgen
22

3-
go 1.23.0
4-
5-
toolchain go1.23.6
3+
go 1.25.0
64

75
require (
86
github.com/fatih/camelcase v1.0.0
@@ -12,14 +10,14 @@ require (
1210
github.com/sirupsen/logrus v1.8.1
1311
github.com/stretchr/testify v1.4.0
1412
golang.org/x/time v0.6.0
15-
golang.org/x/tools v0.35.0
13+
golang.org/x/tools v0.39.0
1614
)
1715

1816
require (
1917
github.com/davecgh/go-spew v1.1.1 // indirect
2018
github.com/pmezard/go-difflib v1.0.0 // indirect
21-
golang.org/x/mod v0.26.0 // indirect
22-
golang.org/x/sync v0.16.0 // indirect
23-
golang.org/x/sys v0.34.0 // indirect
19+
golang.org/x/mod v0.30.0 // indirect
20+
golang.org/x/sync v0.18.0 // indirect
21+
golang.org/x/sys v0.38.0 // indirect
2422
gopkg.in/yaml.v2 v2.2.2 // indirect
2523
)

go.sum

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,23 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
1919
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
2020
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
2121
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
22-
golang.org/x/mod v0.26.0 h1:EGMPT//Ezu+ylkCijjPc+f4Aih7sZvaAr+O3EHBxvZg=
23-
golang.org/x/mod v0.26.0/go.mod h1:/j6NAhSk8iQ723BGAUyoAcn7SlD7s15Dp9Nd/SfeaFQ=
24-
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
25-
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
22+
golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk=
23+
golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc=
24+
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
25+
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
26+
golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I=
27+
golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
2628
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
27-
golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA=
28-
golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
29+
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
30+
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
31+
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
32+
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
2933
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
3034
golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
31-
golang.org/x/tools v0.35.0 h1:mBffYraMEf7aa0sB+NuKnuCy8qI/9Bughn8dC2Gu5r0=
32-
golang.org/x/tools v0.35.0/go.mod h1:NKdj5HkL/73byiZSJjqJgKn3ep7KjFkBOkR/Hps3VPw=
35+
golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ=
36+
golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs=
37+
golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ=
38+
golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ=
3339
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
3440
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
3541
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=

parseref_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ func TestParseTypeSelector(t *testing.T) {
77
main string
88
}
99
tests := []struct {
10-
name string
11-
args args
10+
name string
11+
args args
1212
wantErr bool
1313
wantSpec TypeSelector
1414
}{
@@ -41,7 +41,8 @@ func TestParseTypeSelector(t *testing.T) {
4141
},
4242
wantErr: false,
4343
wantSpec: TypeSelector{
44-
Package: "github.com/c9s/requestgen",
44+
// Package: "github.com/c9s/requestgen",
45+
Package: ".",
4546
Member: "APIClient",
4647
IsSlice: true,
4748
},
@@ -53,7 +54,8 @@ func TestParseTypeSelector(t *testing.T) {
5354
},
5455
wantErr: false,
5556
wantSpec: TypeSelector{
56-
Package: "github.com/c9s/requestgen",
57+
// Package: "github.com/c9s/requestgen",
58+
Package: ".",
5759
Member: "APIClient",
5860
},
5961
},

0 commit comments

Comments
 (0)