bbgo_origin/.github/workflows/go.yml

106 lines
2.6 KiB
YAML
Raw Normal View History

2021-12-04 16:37:46 +00:00
name: Go
on:
push:
branches: [ main ]
pull_request:
2023-07-22 03:47:03 +00:00
branches:
- "main"
- "v*"
2021-12-04 16:37:46 +00:00
jobs:
build:
runs-on: ubuntu-latest
2022-12-03 04:42:48 +00:00
timeout-minutes: 15
2021-12-04 16:44:11 +00:00
strategy:
matrix:
redis-version:
2023-12-07 07:14:12 +00:00
- "6.2"
go-version:
2024-04-01 07:54:49 +00:00
- "1.21"
2022-05-03 08:23:10 +00:00
env:
GITHUB_CI: true
2022-05-03 08:26:33 +00:00
MYSQL_DATABASE: bbgo
MYSQL_USER: "root"
2022-06-17 07:04:23 +00:00
MYSQL_PASSWORD: "root" # pragma: allowlist secret
2021-12-04 16:44:11 +00:00
2021-12-04 16:37:46 +00:00
steps:
2022-05-03 08:23:10 +00:00
2021-12-04 16:37:46 +00:00
- uses: actions/checkout@v2
2022-12-05 18:39:59 +00:00
with:
2022-12-09 09:34:24 +00:00
# lfs: 'true'
2022-12-05 18:39:59 +00:00
ssh-key: ${{ secrets.git_ssh_key }}
2021-12-04 16:37:46 +00:00
2021-12-04 16:49:29 +00:00
- uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
2022-05-03 08:23:10 +00:00
- name: Set up MySQL
run: |
sudo /etc/init.d/mysql start
2022-05-03 08:26:33 +00:00
mysql -e 'CREATE DATABASE ${{ env.MYSQL_DATABASE }};' -u${{ env.MYSQL_USER }} -p${{ env.MYSQL_PASSWORD }}
2022-05-03 08:23:10 +00:00
- name: Set up redis
uses: shogo82148/actions-setup-redis@v1
2021-12-04 16:44:11 +00:00
with:
redis-version: ${{ matrix.redis-version }}
# auto-start: "false"
2021-12-04 16:44:11 +00:00
2021-12-04 16:37:46 +00:00
- name: Set up Go
2023-12-11 14:06:48 +00:00
uses: actions/setup-go@v4
2021-12-04 16:37:46 +00:00
with:
go-version: ${{ matrix.go-version }}
2021-12-04 16:37:46 +00:00
- name: Install Migration Tool
2024-04-08 10:59:52 +00:00
run: go install github.com/c9s/rockhopper/v2/cmd/rockhopper@latest
2022-05-03 08:26:33 +00:00
- name: Test Migration SQL Files For MySQL
run: |
rockhopper --config rockhopper_mysql.yaml up
2022-05-03 08:48:55 +00:00
- name: Test Migration SQL Files For SQLite
run: |
rockhopper --config rockhopper_sqlite.yaml up
2021-12-04 16:37:46 +00:00
- name: Build
run: go build -v ./cmd/bbgo
2022-12-05 18:49:48 +00:00
- name: Link Market Data
run: |
mkdir -p ~/.bbgo/cache
ln -s $PWD/data/binance-markets.json ~/.bbgo/cache/binance-markets.json
touch data/binance-markets.json
2021-12-04 16:37:46 +00:00
- name: Test
2022-06-14 05:19:55 +00:00
run: |
2024-01-24 07:31:48 +00:00
go test -count 3 -race -coverprofile coverage.txt -covermode atomic ./pkg/...
2022-06-14 05:19:55 +00:00
sed -i -e '/_requestgen.go/d' coverage.txt
2022-02-15 02:56:09 +00:00
- name: TestDnum
2022-06-14 05:19:55 +00:00
run: |
go test -race -coverprofile coverage_dnum.txt -covermode atomic -tags dnum ./pkg/...
sed -i -e '/_requestgen.go/d' coverage_dnum.txt
- name: Revive Check
uses: morphy2k/revive-action@v2.5.9 # https://github.com/mgechev/revive/issues/956
with:
reporter: github-pr-review
fail_on_error: true
- name: Upload Coverage Report
2022-06-10 05:05:56 +00:00
uses: codecov/codecov-action@v3
with:
files: ./coverage.txt,./coverage_dnum.txt
2022-05-20 08:48:23 +00:00
- name: Create dotenv file
run: |
echo "DB_DRIVER=mysql" >> .env.local
echo "DB_DSN=root:root@/bbgo" >> .env.local