Merge pull request #418 from weibocom/fix/codecov #554
This file contains 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: Test and coverage | |
on: | |
push: | |
branches: | |
- master | |
- dev | |
- dev_fix | |
pull_request: | |
branches: | |
- master | |
- dev | |
jobs: | |
testing: | |
strategy: | |
matrix: | |
go-version: [1.16.x,1.17.x,1.18.x,1.19.x,1.20.x,1.21.x] | |
platform: [ubuntu-latest] | |
runs-on: ${{ matrix.platform }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Go | |
if: success() | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- name: Gather dependencies | |
run: go mod tidy | |
- name: Run tests | |
run: go test -v -race $(go list ./... | grep -v main) | |
codecov: | |
name: codecov | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go version to stable | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 'stable' | |
- name: Gather dependencies | |
run: go mod tidy | |
- name: Generate coverage report | |
run: go test -v -race -coverprofile=coverage.txt -covermode=atomic $(go list ./... | grep -v main) | |
- name: Upload coverage report | |
uses: codecov/codecov-action@v5 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} |