Skip to content

Commit b9e66e5

Browse files
committed
fix codecov
1 parent 1e80ea5 commit b9e66e5

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

.github/workflows/test.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Go Test & Coverage
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v5
14+
15+
- name: Set up Go
16+
uses: actions/setup-go@v5
17+
with:
18+
go-version-file: go.mod # 用 go.mod 里声明的 Go 版本(1.19),与题解代码年代匹配
19+
20+
- name: Run tests with coverage # 复用仓库原有的 gotest.sh,生成 coverage.txt
21+
run: bash ./gotest.sh
22+
23+
- name: Upload coverage to Codecov
24+
uses: codecov/codecov-action@v4
25+
with:
26+
token: ${{ secrets.CODECOV_TOKEN }} # 需在仓库 Settings → Secrets and variables → Actions 里添加(从 codecov.io 获取)
27+
files: ./coverage.txt
28+
fail_ci_if_error: false # codecov 上传出问题时不让整个 CI 变红,构建徽章只反映测试本身

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<a href="https://github.com/halfrost/leetcode-go/releases/" rel="nofollow"><img alt="GitHub All Releases" src="https://img.shields.io/github/downloads/halfrost/LeetCode-Go/total?label=PDF%20downloads"></a>
1414
<img src="https://img.shields.io/badge/Total%20Word%20Count-738884-success">
1515
<a href="https://github.com/halfrost/LeetCode-Go/actions/workflows/deploy.yml" rel="nofollow"><img src="https://github.com/halfrost/LeetCode-Go/actions/workflows/deploy.yml/badge.svg?branch=master" alt="Deploy Status"></a>
16-
<a href="https://travis-ci.org/github/halfrost/LeetCode-Go" rel="nofollow"><img src="https://travis-ci.org/halfrost/LeetCode-Go.svg?branch=master"></a>
16+
<a href="https://github.com/halfrost/LeetCode-Go/actions/workflows/test.yml" rel="nofollow"><img src="https://github.com/halfrost/LeetCode-Go/actions/workflows/test.yml/badge.svg?branch=master" alt="Go Test Status"></a>
1717
<a href="https://goreportcard.com/report/github.com/halfrost/LeetCode-Go" rel="nofollow"><img src="https://goreportcard.com/badge/github.com/halfrost/LeetCode-Go"></a>
1818
<img src="https://img.shields.io/badge/runtime%20beats-100%25-success">
1919
<a href="https://codecov.io/gh/halfrost/LeetCode-Go"><img src="https://codecov.io/gh/halfrost/LeetCode-Go/branch/master/graph/badge.svg" /></a>

0 commit comments

Comments
 (0)