mirror of
https://github.com/jefferyjob/go-easy-utils.git
synced 2025-12-24 13:18:09 +08:00
59 lines
1.4 KiB
YAML
59 lines
1.4 KiB
YAML
name: Go
|
|
|
|
on:
|
|
push:
|
|
branches: [ "main", "v1", "dev" ]
|
|
pull_request:
|
|
branches: [ "main", "v1", "dev" ]
|
|
|
|
jobs:
|
|
linux-build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: 1.18
|
|
|
|
- name: GO Env
|
|
run: |
|
|
go version
|
|
go env
|
|
|
|
- name: Build
|
|
run: go build -v ./...
|
|
|
|
# 运行go的单元测试
|
|
- name: Test
|
|
run: make test
|
|
|
|
# 生成 codecov 覆盖报告
|
|
- name: Test and create coverage file
|
|
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...
|
|
|
|
# 上传测试覆盖率报告到 codecov
|
|
- name: Upload coverage reports to Codecov
|
|
uses: codecov/codecov-action@v4
|
|
with:
|
|
token: ${{secrets.CODECOV_TOKEN}}
|
|
|
|
# 安装依赖项
|
|
- name: Install dependencies
|
|
run: |
|
|
go install github.com/jstemmer/go-junit-report@latest
|
|
go install gotest.tools/gotestsum@latest
|
|
|
|
# 运行测试并生成覆盖率报告
|
|
- name: Run tests and generate coverage report
|
|
run: gotestsum --junitfile junit.xml
|
|
|
|
# 上传测试结果到 Codecov
|
|
- name: Upload test results to Codecov
|
|
if: ${{ !cancelled() }}
|
|
uses: codecov/test-results-action@v1
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
|