Skip to content

Commit

Permalink
Merge branch 'c9s:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
chendagan authored Oct 28, 2022
2 parents 1fc0c11 + 7dd951e commit 9be9c08
Show file tree
Hide file tree
Showing 1,012 changed files with 77,228 additions and 24,473 deletions.
56 changes: 50 additions & 6 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,23 @@ on:
branches: [ main ]

jobs:

build:
runs-on: ubuntu-latest

strategy:
matrix:
redis-version:
- 6.2
go-version:
- 1.17
- 1.18
env:
MYSQL_DATABASE: bbgo
MYSQL_USER: "root"
MYSQL_PASSWORD: "root" # pragma: allowlist secret

steps:

- uses: actions/checkout@v2

- uses: actions/cache@v2
Expand All @@ -28,22 +35,59 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: Setup redis
- name: Set up MySQL
run: |
sudo /etc/init.d/mysql start
mysql -e 'CREATE DATABASE ${{ env.MYSQL_DATABASE }};' -u${{ env.MYSQL_USER }} -p${{ env.MYSQL_PASSWORD }}
- name: Set up redis
uses: shogo82148/actions-setup-redis@v1
with:
redis-version: ${{ matrix.redis-version }}
# auto-start: "false"

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version: ${{ matrix.go-version }}

- name: Install Migration Tool
run: go install github.com/c9s/rockhopper/cmd/rockhopper@v1.2.1

- name: Test Migration SQL Files For MySQL
run: |
rockhopper --config rockhopper_mysql.yaml up
- name: Test Migration SQL Files For SQLite
run: |
rockhopper --config rockhopper_sqlite.yaml up
- name: Build
run: go build -v ./cmd/bbgo

- name: Test
run: go test -v ./pkg/...
run: |
go test -race -coverprofile coverage.txt -covermode atomic ./pkg/...
sed -i -e '/_requestgen.go/d' coverage.txt
- name: TestDnum
run: go test -tags dnum -v ./pkg/...
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
with:
reporter: github-pr-review
fail_on_error: true

- name: Upload Coverage Report
uses: codecov/codecov-action@v3
with:
files: ./coverage.txt,./coverage_dnum.txt

- name: Create dotenv file
run: |
echo "DB_DRIVER=mysql" >> .env.local
echo "DB_DSN=root:root@/bbgo" >> .env.local
22 changes: 22 additions & 0 deletions .github/workflows/golang-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: golang-lint
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.18
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.46.2
40 changes: 40 additions & 0 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Node.js CI

on:
push:
branches: [ main ]
paths:
- apps/backtest-report
- frontend
pull_request:
branches: [ main ]
paths:
- apps/backtest-report
- frontend

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [ 16.x ]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm install -g yarn
- name: Install
run: yarn install
working-directory: "apps/backtest-report"
- name: Build
run: yarn run next build
working-directory: "apps/backtest-report"
- name: Export
run: yarn run next export
working-directory: "apps/backtest-report"
- run: yarn export
working-directory: "frontend"
57 changes: 31 additions & 26 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ name: Python
on:
push:
branches: [ main ]
paths:
- python

pull_request:
branches: [ main ]
paths:
- python

jobs:

Expand All @@ -13,31 +18,31 @@ jobs:

strategy:
matrix:
python-version: [3.8]
python-version: [ 3.8 ]

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install poetry
run: pip install poetry==1.1.13

- name: Install package
run: |
cd python
poetry install
- name: Test
run: |
cd python
poetry run pytest -v -s tests
- name: Lint
run: |
cd python
poetry run flake8 .
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install poetry
run: pip install poetry==1.1.13

- name: Install package
run: |
cd python
poetry install
- name: Test
run: |
cd python
poetry run pytest -v -s tests
- name: Lint
run: |
cd python
poetry run flake8 .
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.17.5
go-version: 1.18
- name: Install Node
uses: actions/setup-node@v2
with:
Expand Down
24 changes: 23 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,35 @@

/config/bbgo.yaml

/localconfig

/pkg/server/assets.go

bbgo.sqlite3
*.sqlite3
node_modules
output

otp*png

/.deploy

testoutput

*.swp
/pkg/backtest/assets.go

coverage.txt
coverage_dum.txt

*.cpuprofile

.systemd.*

/coverage.txt

/otp.png

/profile*.png

*_local.yaml
/.chglog/
9 changes: 9 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
run:
issues-exit-code: 0
tests: true
timeout: 5m
linters:
disable-all: true
enable:
- gofmt
- gosimple
5 changes: 5 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
default: true
extends: null
MD033: false
MD010: false
MD013: false
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
repos:
# Secret Detection
- repo: https://github.com/Yelp/detect-secrets
rev: v1.2.0
hooks:
- id: detect-secrets
args: ['--exclude-secrets', '3899a918953e01bfe218116cdfeccbed579e26275c4a89abcbc70d2cb9e9bbb8']
exclude: pacakge.lock.json
# Markdown
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.31.1
hooks:
- id: markdownlint
9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ If you find an issue to work on, you are welcome to open a PR with a fix.

### Making Changes

Install pre-commit to check your changes before you commit:

pip install pre-commit
pre-commit install
pre-commit run markdownlint --files=README.md --verbose
pre-commit run detect-secrets --all-files --verbose

See <https://pre-commit.com/> for more details.

For new large features, such as integrating binance futures contracts, please propose a discussion first before you start working on it.

For new small features, you could open a pull request directly.
Expand Down
14 changes: 8 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# First stage container
FROM golang:1.17.6-alpine3.15 AS builder
FROM golang:1.17.11-alpine3.16 AS builder
RUN apk add --no-cache git ca-certificates gcc libc-dev pkgconfig
# gcc is for github.com/mattn/go-sqlite3
# ADD . $GOPATH/src/github.com/c9s/bbgo
Expand All @@ -11,19 +11,21 @@ ENV GOPATH_ORIG=$GOPATH
ENV GOPATH=${GO_MOD_CACHE:+$WORKDIR/$GO_MOD_CACHE}
ENV GOPATH=${GOPATH:-$GOPATH_ORIG}
ENV CGO_ENABLED=1
RUN go get github.com/mattn/go-sqlite3
RUN cd $WORKDIR && go get github.com/mattn/go-sqlite3
ADD . .
RUN go build -o $GOPATH_ORIG/bin/bbgo ./cmd/bbgo

# Second stage container
FROM alpine:3.15
FROM alpine:3.16

# RUN apk add --no-cache ca-certificates
RUN mkdir /app
# Create the default user 'bbgo' and assign to env 'USER'
ENV USER=bbgo
RUN adduser -D -G wheel "$USER"
USER ${USER}

WORKDIR /app
COPY --from=builder /go/bin/bbgo /usr/local/bin

WORKDIR /home/${USER}
ENTRYPOINT ["/usr/local/bin/bbgo"]
CMD ["run", "--config", "/config/bbgo.yaml", "--no-compile"]
# vim:filetype=dockerfile:
Loading

0 comments on commit 9be9c08

Please sign in to comment.