Skip to content

Merge pull request #12 from light-speak/staging #34

Merge pull request #12 from light-speak/staging

Merge pull request #12 from light-speak/staging #34

Workflow file for this run

name: Testing and Code Quality
on:
push:
branches:
- main
- dev
tags:
- 'v*'
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
# 确保同一时间只运行一个工作流
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write # 需要写权限来更新 PR 状态
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # 完整克隆,确保能获取所有提交历史
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
cache: true
- name: Install dependencies
run: go mod download
- name: Run Tests with Coverage
run: |
go test -race -coverprofile=coverage.txt -covermode=atomic ./...
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }} # 如果是私有仓库需要设置
file: ./coverage.txt
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
verbose: true
- name: Comment PR with Coverage
uses: codecov/codecov-action@v3
if: github.event_name == 'pull_request'
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.txt
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
verbose: true
override_commit: ${{ github.event.pull_request.head.sha }}
override_branch: ${{ github.event.pull_request.head.ref }}
override_pr: ${{ github.event.pull_request.number }}