Skip to content

Commit 4bfe14c

Browse files
committed
feat: add ci/cd 相关脚本
1 parent e124d32 commit 4bfe14c

File tree

8 files changed

+318
-1
lines changed

8 files changed

+318
-1
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: '[BUG] '
5+
labels: 'bug'
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Environment (please complete the following information):**
24+
- OS: [e.g. Ubuntu 20.04, macOS 12.0]
25+
- Go Version: [e.g. 1.21.0]
26+
- Pulse Version: [e.g. v1.0.0]
27+
28+
**Additional context**
29+
Add any other context about the problem here.
30+
31+
**Code sample**
32+
If applicable, add code sample to help explain your problem.
33+
34+
```go
35+
// Your code here
36+
```
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: '[FEATURE] '
5+
labels: 'enhancement'
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/workflows/ci.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
jobs:
10+
test:
11+
strategy:
12+
matrix:
13+
go-version: [1.21, 1.22, 1.23]
14+
os: [ubuntu-latest, macos-latest]
15+
runs-on: ${{ matrix.os }}
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v5
22+
with:
23+
go-version: ${{ matrix.go-version }}
24+
25+
- name: Cache go modules
26+
uses: actions/cache@v4
27+
with:
28+
path: ~/go/pkg/mod
29+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
30+
restore-keys: |
31+
${{ runner.os }}-go-
32+
33+
- name: Download dependencies
34+
run: go mod download
35+
36+
- name: Run tests
37+
run: go test -race -coverprofile=coverage.out -covermode=atomic . ./core/...
38+
39+
- name: Upload coverage to Codecov
40+
if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.23'
41+
uses: codecov/codecov-action@v4
42+
with:
43+
file: ./coverage.out
44+
token: ${{ secrets.CODECOV_TOKEN }}
45+
fail_ci_if_error: false
46+
47+
lint:
48+
runs-on: ubuntu-latest
49+
steps:
50+
- uses: actions/checkout@v4
51+
52+
- name: Set up Go
53+
uses: actions/setup-go@v5
54+
with:
55+
go-version: '1.23'
56+
57+
- name: golangci-lint
58+
uses: golangci/golangci-lint-action@v6
59+
with:
60+
version: latest
61+
args: --timeout=5m --skip-dirs=example --skip-dirs=cpu
62+
63+
build:
64+
runs-on: ubuntu-latest
65+
steps:
66+
- uses: actions/checkout@v4
67+
68+
- name: Set up Go
69+
uses: actions/setup-go@v5
70+
with:
71+
go-version: '1.23'
72+
73+
- name: Build
74+
run: go build .

.golangci.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
run:
2+
timeout: 5m
3+
4+
linters:
5+
enable:
6+
- gofmt
7+
- golint
8+
- govet
9+
- errcheck
10+
- staticcheck
11+
- unused
12+
- gosimple
13+
- structcheck
14+
- varcheck
15+
- ineffassign
16+
- deadcode
17+
- typecheck
18+
- gosec
19+
- gocyclo
20+
- dupl
21+
- misspell
22+
- unparam
23+
- unconvert
24+
- goconst
25+
- gocognit
26+
- asciicheck
27+
- gofumpt
28+
- goimports
29+
- revive
30+
31+
linters-settings:
32+
gocyclo:
33+
min-complexity: 15
34+
goconst:
35+
min-len: 2
36+
min-occurrences: 2
37+
misspell:
38+
locale: US
39+
revive:
40+
min-confidence: 8
41+
42+
issues:
43+
exclude-use-default: false
44+
exclude:
45+
# for "revive" linter
46+
- "should have comment"
47+
- "comment on exported"

CONTRIBUTING.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Contributing to Pulse
2+
3+
感谢您对Pulse项目的贡献!本文档将帮助您了解如何为项目做贡献。
4+
5+
## 开发流程
6+
7+
### 1. Fork和Clone
8+
9+
```bash
10+
# Fork项目到您的GitHub账户
11+
# 然后Clone到本地
12+
git clone https://github.com/YOUR_USERNAME/pulse.git
13+
cd pulse
14+
```
15+
16+
### 2. 创建分支
17+
18+
```bash
19+
git checkout -b feature/your-feature-name
20+
```
21+
22+
### 3. 开发和测试
23+
24+
在开发过程中,请确保:
25+
26+
- 编写清晰的代码和注释
27+
- 添加必要的测试用例
28+
- 运行测试确保通过
29+
30+
```bash
31+
# 运行测试
32+
make test
33+
34+
# 运行测试并生成覆盖率报告
35+
make test-coverage
36+
37+
# 运行代码检查
38+
make lint
39+
```
40+
41+
### 4. 提交代码
42+
43+
```bash
44+
git add .
45+
git commit -m "feat: add your feature description"
46+
git push origin feature/your-feature-name
47+
```
48+
49+
### 5. 创建Pull Request
50+
51+
- 创建PR并填写详细的描述
52+
- 确保所有CI检查通过
53+
- 等待代码审查
54+
55+
## CI/CD 流程
56+
57+
项目使用GitHub Actions进行持续集成,包括:
58+
59+
- **测试**:在多个Go版本(1.21, 1.22, 1.23)和操作系统(Ubuntu, macOS)上运行测试
60+
- **代码检查**:使用golangci-lint进行代码质量检查
61+
- **覆盖率**:生成测试覆盖率报告并上传到Codecov
62+
- **构建**:验证代码可以正常构建
63+
64+
## 代码规范
65+
66+
- 遵循Go官方代码规范
67+
- 使用`gofmt`格式化代码
68+
- 通过`golangci-lint`检查
69+
- 为新功能添加测试用例
70+
- 保持测试覆盖率
71+
72+
## 报告问题
73+
74+
如果您发现bug或有功能建议:
75+
76+
1. 搜索现有的issues,避免重复
77+
2. 使用适当的issue模板
78+
3. 提供详细的描述和复现步骤
79+
80+
## 许可证
81+
82+
通过贡献代码,您同意您的贡献将在Apache 2.0许可证下发布。

Makefile

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
11
# Makefile for building pulse examples for macOS, Linux and Windows
2-
.PHONY: all clean mac linux windows examples mac-race linux-race windows-race
2+
.PHONY: all clean mac linux windows examples mac-race linux-race windows-race test test-coverage ci-test lint
33

44
# Default target
55
all: examples
66

7+
# Test and CI targets
8+
test:
9+
@echo "Running tests..."
10+
go test -v -race ./...
11+
12+
test-coverage:
13+
@echo "Running tests with coverage..."
14+
go test -race -coverprofile=coverage.out -covermode=atomic . ./core/...
15+
go tool cover -html=coverage.out -o coverage.html
16+
@echo "Coverage report generated: coverage.html"
17+
18+
ci-test:
19+
@echo "Running CI tests..."
20+
go test -race -coverprofile=coverage.out -covermode=atomic . ./core/...
21+
22+
lint:
23+
@echo "Running linter..."
24+
golangci-lint run --timeout=5m --skip-dirs=example --skip-dirs=cpu
25+
726
# Directories
827
EXAMPLE_DIR = example
928
BIN_DIR = bin

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
# pulse
2+
3+
[![CI](https://github.com/antlabs/pulse/actions/workflows/ci.yml/badge.svg)](https://github.com/antlabs/pulse/actions/workflows/ci.yml)
4+
[![codecov](https://codecov.io/gh/antlabs/pulse/branch/master/graph/badge.svg)](https://codecov.io/gh/antlabs/pulse)
5+
[![Go Report Card](https://goreportcard.com/badge/github.com/antlabs/pulse)](https://goreportcard.com/report/github.com/antlabs/pulse)
6+
[![Go Reference](https://pkg.go.dev/badge/github.com/antlabs/pulse.svg)](https://pkg.go.dev/github.com/antlabs/pulse)
7+
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
8+
29
极简异步io库,速度很快,非常简单
310

411
## 特性

codecov.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
codecov:
2+
require_ci_to_pass: yes
3+
4+
coverage:
5+
precision: 2
6+
round: down
7+
range: "70...100"
8+
9+
status:
10+
project:
11+
default:
12+
target: auto
13+
threshold: 1%
14+
informational: false
15+
patch:
16+
default:
17+
target: auto
18+
threshold: 1%
19+
informational: false
20+
21+
parsers:
22+
gcov:
23+
branch_detection:
24+
conditional: yes
25+
loop: yes
26+
method: no
27+
macro: no
28+
29+
comment:
30+
layout: "reach,diff,flags,tree"
31+
behavior: default
32+
require_changes: no

0 commit comments

Comments
 (0)