bbgo_origin/.github/workflows/go.yml

100 lines
2.5 KiB
YAML
Raw Normal View History

2021-12-04 16:37:46 +00:00
name: Go
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
2021-12-04 16:44:11 +00:00
strategy:
matrix:
redis-version:
- 6.2
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
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
uses: actions/setup-go@v2
with:
2022-05-12 11:07:11 +00:00
go-version: 1.18
2021-12-04 16:37:46 +00:00
2022-06-17 07:04:23 +00:00
- name: Run pre-commit
run: |
pip install pre-commit
go get -v -u github.com/go-critic/go-critic/cmd/gocritic
pre-commit install-hooks
pre-commit run markdownlint --files=README.md --verbose
pre-commit run go-fmt --all-files --verbose
pre-commit run go-critic --all-files --verbose
- 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
- 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
- name: Revive Check
uses: morphy2k/revive-action@v2
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