From a783f18cb524d32319830ff18134b90a90fdcf2a Mon Sep 17 00:00:00 2001 From: Robert He Date: Sun, 5 Oct 2025 19:09:05 +0800 Subject: [PATCH 01/68] feat: implement programme, update port 4594 --- .dockerignore | 42 ++++ .github/workflows/ci.yml | 106 ++++++++ .gitignore | 2 + .vscode/settings.json | 24 +- CONTRIBUTING.md | 152 +++++++++++ Dockerfile | 43 ++++ Makefile | 46 ++++ QUICKSTART.md | 195 +++++++++++++++ README.md | 401 +++++++++++++++++++++++++++++- cmd/feishu-github-tracker/main.go | 108 ++++++++ configs/server.yaml | 2 +- docker-compose.yml | 29 +++ go.mod | 8 + go.sum | 6 + internal/config/config.go | 112 +++++++++ internal/config/config_test.go | 100 ++++++++ internal/handler/handler.go | 320 ++++++++++++++++++++++++ internal/matcher/matcher.go | 133 ++++++++++ internal/matcher/matcher_test.go | 101 ++++++++ internal/notifier/notifier.go | 106 ++++++++ internal/template/template.go | 174 +++++++++++++ log/.gitkeep | 0 pkg/logger/logger.go | 90 +++++++ 23 files changed, 2296 insertions(+), 4 deletions(-) create mode 100644 .dockerignore create mode 100644 .github/workflows/ci.yml create mode 100644 CONTRIBUTING.md create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 QUICKSTART.md create mode 100644 cmd/feishu-github-tracker/main.go create mode 100644 docker-compose.yml create mode 100644 go.mod create mode 100644 go.sum create mode 100644 internal/config/config.go create mode 100644 internal/config/config_test.go create mode 100644 internal/handler/handler.go create mode 100644 internal/matcher/matcher.go create mode 100644 internal/matcher/matcher_test.go create mode 100644 internal/notifier/notifier.go create mode 100644 internal/template/template.go create mode 100644 log/.gitkeep create mode 100644 pkg/logger/logger.go diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2b21a08 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,42 @@ +# Git +.git +.gitignore +.gitattributes + +# Documentation +*.md +!README.md +DEPLOYMENT.md +CONFIGURATION.md + +# CI/CD +.github + +# IDE +.vscode +.idea +*.swp +*.swo +*~ + +# Build artifacts +dist/ +bin/ +dist/ +feishu-github-tracker +webhook +*.exe + +# Logs +log/ +*.log + +# Test files +*_test.go + +# OS +.DS_Store +Thumbs.db + +# Local config overrides +*.local.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b268c87 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,106 @@ +name: CI/CD + +on: + push: + branches: [main, develop] + pull_request: + branches: [main, develop] + release: + types: [published] + +jobs: + test: + name: Test + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.21" + + - name: Cache Go modules + uses: actions/cache@v4 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Download dependencies + run: go mod download + + - name: Run tests + run: go test -v ./... + + - name: Run go vet + run: go vet ./... + + build: + name: Build + runs-on: ubuntu-latest + needs: test + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.21" + + - name: Build + run: go build -v -o bin/feishu-github-tracker ./cmd/feishu-github-tracker + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: feishu-github-tracker-binary + path: bin/feishu-github-tracker + retention-days: 7 + + docker: + name: Build and Push Docker Image + runs-on: ubuntu-latest + needs: test + if: github.event_name == 'push' || github.event_name == 'release' + permissions: + contents: read + packages: write + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=ref,event=branch + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha + type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.gitignore b/.gitignore index 6f72f89..4308b6d 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,5 @@ go.work.sum # env file .env + +bin/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 613d7ad..507532d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,14 +1,36 @@ { "cSpell.words": [ + "Buildx", "color", + "delaycompress", "demilestoned", + "endscript", + "extldflags", "feishu", "forkee", + "GOARCH", + "gobwas", + "golangci", "gollum", + "GOOS", + "gopkg", + "healthcheck", "labeled", + "ldflags", "milestoned", + "myorg", + "myrepo", + "notifempty", + "postrotate", "prereleased", "rerequested", - "unlabeled" + "resp", + "sharedscripts", + "timezone", + "tmpl", + "tzdata", + "unlabeled", + "yourdomain", + "zoneinfo" ] } \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..ea61910 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,152 @@ +# Contributing to Feishu GitHub Tracker + +感谢您对本项目的关注!我们欢迎各种形式的贡献。 + +## 如何贡献 + +### 报告 Bug + +如果您发现了 bug,请创建一个 Issue 并包含: + +1. 清晰的标题和描述 +2. 复现步骤 +3. 预期行为和实际行为 +4. 环境信息(Go 版本、操作系统等) +5. 相关的日志输出 + +### 提出新功能 + +如果您有新功能的想法: + +1. 先创建一个 Issue 讨论该功能 +2. 说明功能的用途和价值 +3. 如果可能,提供实现思路 + +### 提交代码 + +1. **Fork 项目** + +2. **创建特性分支** + + ```bash + git checkout -b feature/amazing-feature + ``` + +3. **进行修改** + + - 遵循现有的代码风格 + - 添加必要的测试 + - 更新相关文档 + +4. **提交更改** + + ```bash + git add . + git commit -m "Add amazing feature" + ``` + +5. **推送到 Fork** + + ```bash + git push origin feature/amazing-feature + ``` + +6. **创建 Pull Request** + +## 开发指南 + +### 环境准备 + +```bash +# 克隆项目 +git clone https://github.com/hnrobert/feishu-github-tracker.git +cd feishu-github-tracker + +# 安装依赖 +go mod download + +# 运行测试 +go test ./... + +# 构建 +make build +``` + +### 代码规范 + +- 使用 `go fmt` 格式化代码 +- 使用 `go vet` 检查代码 +- 所有导出的函数和类型都需要注释 +- 遵循 Go 标准项目布局 + +### 测试 + +- 为新功能添加单元测试 +- 确保所有测试通过:`go test ./...` +- 测试覆盖率应保持或提高 + +### 提交信息规范 + +使用清晰的提交信息: + +```text +: + + + +