Skip to content

Commit f4cdeaa

Browse files
committed
add workflows
1 parent f5840d8 commit f4cdeaa

3 files changed

Lines changed: 137 additions & 0 deletions

File tree

.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$

0 commit comments

Comments
 (0)