CI: add workflows #3
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Go | |
| on: | |
| push: | |
| branches: | |
| - "main" | |
| pull_request: | |
| # types: [synchronize, opened, reopened, edited] | |
| # branches: | |
| # - "main" | |
| # - "v*" | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| strategy: | |
| matrix: | |
| redis-version: | |
| - "6.2" | |
| go-version: | |
| - "1.25" | |
| env: | |
| GITHUB_CI: true | |
| MYSQL_DATABASE: bbgo | |
| MYSQL_USER: "root" | |
| MYSQL_PASSWORD: "root" # pragma: allowlist secret | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| # lfs: 'true' | |
| ssh-key: ${{ secrets.git_ssh_key }} | |
| - uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/go-build | |
| ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go- | |
| - 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@v6 | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| - name: Test | |
| run: | | |
| go test -count 3 -race -coverprofile coverage.txt -covermode atomic ./... | |
| sed -i -e '/_requestgen.go/d' coverage.txt | |
| - name: Revive Check | |
| uses: morphy2k/revive-action@v2.7.7 # https://github.com/mgechev/revive/issues/956 | |
| with: | |
| reporter: github-pr-review | |
| fail_on_error: true | |
| - name: Upload Coverage Report | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| files: ./coverage.txt,./coverage_dnum.txt | |