2021-12-04 16:37:46 +00:00
|
|
|
name: Go
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: [ main ]
|
|
|
|
pull_request:
|
|
|
|
branches: [ main ]
|
|
|
|
|
|
|
|
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:
|
2021-12-04 16:46:50 +00:00
|
|
|
redis-version:
|
|
|
|
- 6.2
|
2022-08-09 08:49:34 +00:00
|
|
|
go-version:
|
|
|
|
- 1.17
|
|
|
|
- 1.18
|
2022-05-03 08:23:10 +00:00
|
|
|
env:
|
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
|
2021-12-04 16:46:50 +00:00
|
|
|
uses: shogo82148/actions-setup-redis@v1
|
2021-12-04 16:44:11 +00:00
|
|
|
with:
|
|
|
|
redis-version: ${{ matrix.redis-version }}
|
2021-12-04 16:46:50 +00:00
|
|
|
# auto-start: "false"
|
2021-12-04 16:44:11 +00:00
|
|
|
|
2021-12-04 16:37:46 +00:00
|
|
|
- name: Set up Go
|
2022-06-17 07:23:12 +00:00
|
|
|
uses: actions/setup-go@v3
|
2021-12-04 16:37:46 +00:00
|
|
|
with:
|
2022-08-09 08:49:34 +00:00
|
|
|
go-version: ${{ matrix.go-version }}
|
2021-12-04 16:37:46 +00:00
|
|
|
|
2022-05-03 06:59:28 +00:00
|
|
|
- name: Install Migration Tool
|
|
|
|
run: go install github.com/c9s/rockhopper/cmd/rockhopper@v1.2.1
|
|
|
|
|
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: |
|
|
|
|
go test -race -coverprofile coverage.txt -covermode atomic ./pkg/...
|
|
|
|
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
|
2022-06-10 05:01:14 +00:00
|
|
|
|
2022-06-17 04:01:15 +00:00
|
|
|
- name: Revive Check
|
|
|
|
uses: morphy2k/revive-action@v2
|
|
|
|
with:
|
|
|
|
reporter: github-pr-review
|
|
|
|
fail_on_error: true
|
|
|
|
|
2022-06-10 05:01:14 +00:00
|
|
|
- name: Upload Coverage Report
|
2022-06-10 05:05:56 +00:00
|
|
|
uses: codecov/codecov-action@v3
|
2022-06-10 05:01:14 +00:00
|
|
|
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
|
|
|
|
|