Skip to content

chore: Add GitHub CI workflow and comprehensive test suite - #20

Merged
fengzai6 merged 14 commits into
mainfrom
chore-github-ci-vitest
Jun 24, 2026
Merged

chore: Add GitHub CI workflow and comprehensive test suite#20
fengzai6 merged 14 commits into
mainfrom
chore-github-ci-vitest

Conversation

@fengzai6

Copy link
Copy Markdown
Owner

概述

为项目添加 GitHub Actions CI 工作流和完整的测试基础设施,显著提升代码质量和可维护性。

主要改动

CI/CD

  • ✅ 新增 GitHub Actions CI 工作流配置
  • ✅ 集成 Vitest 作为测试运行器

测试覆盖

  • ✅ 完整的 E2E 测试套件(auth, cats, groups, permissions, roles, users)
  • ✅ 全面的单元测试覆盖
    • Common 层:guards, interceptors, filters, middleware, pipes
    • Modules 层:auth, cats, groups, permissions, roles, users, socket
    • Shared 层:caching, database, throttler, utils
  • ✅ 新增测试辅助工具(test-helper.ts

功能增强

  • ✅ Token 刷新管理器新增冷却机制,防止频繁刷新
  • ✅ HTTP 客户端文档和使用示例

代码质量

  • ✅ 更新 commitlint 配置
  • ✅ 优化 ESLint 配置
  • ✅ 修复已记录的逻辑问题
  • ✅ 调整项目结构(specs → tests 目录)

测试计划

  • CI 工作流在 GitHub Actions 上成功运行
  • 所有单元测试通过
  • 所有 E2E 测试通过
  • Token 刷新冷却机制正常工作

影响范围

  • Server: 测试基础设施、部分 bug 修复
  • Web: HTTP 工厂增强、token 管理优化
  • CI: 新增自动化测试流程

相关文件

  • .github/workflows/ci.yml - CI 配置
  • apps/server/vitest.config.ts - Vitest 配置
  • apps/server/tests/ - 测试文件目录
  • apps/web/src/services/api/http-factory/ - HTTP 客户端增强

fengzai6 added 12 commits June 3, 2026 09:45
- cache.service: add Redis store mock tests (rotateRefreshToken, invalidatePattern)
- socket.gateway: add JWT error handling, leaveRoom, sendToRoom tests
- snowflake: add new test file for constructor, nextId, singleton functions
- cache.constants: add tests for all CacheKeys factory functions
- decorators: add basic tests for Cookies and UserInfo

Coverage: 87% → 93% statements, 79% → 88% branches
- Add e2e tests for auth, cats, groups, users modules
- Fix Permission.code column type (add explicit varchar for TypeORM)
- Fix PermissionGuard to use request.user.id instead of useRequestUser()
  (guards execute before interceptors, so AsyncLocalStorage is not available)
- Fix USER_ALREADY_EXISTS status code: 400 → 409 (Conflict)
- Fix cookie-parser import style for vitest SSR compatibility
- Fix specialRoles null safety in user deletion
- Add fileParallelism: false to vitest config for e2e sequential execution
- Update TestHelper to use appUse() for proper middleware/interceptor setup
- Add permissions e2e tests (GET all, GET by id, PATCH)
- Add roles e2e tests (CRUD with SuperAdmin auth)
- Update eslint config to relax strict type rules for test files
@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
my-first-nest Ready Ready Preview, Comment Jun 24, 2026 7:53am

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@fengzai6, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 44 minutes and 52 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ebfdf0ad-4db4-4777-ac2b-14f2ba219e41

📥 Commits

Reviewing files that changed from the base of the PR and between a4c1e0e and fdffb91.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (83)
  • .github/workflows/ci.yml
  • apps/server/database/seeds/permissions.seed.ts
  • apps/server/database/seeds/roles.seed.ts
  • apps/server/eslint.config.mjs
  • apps/server/package.json
  • apps/server/src/common/exceptions/user.exception.ts
  • apps/server/src/common/guards/permission.guard.ts
  • apps/server/src/common/interceptors/timeout.interceptor.ts
  • apps/server/src/common/middleware/index.ts
  • apps/server/src/main.ts
  • apps/server/src/modules/cats/cats.controller.spec.ts
  • apps/server/src/modules/cats/cats.service.spec.ts
  • apps/server/src/modules/permissions/entities/permission.entity.ts
  • apps/server/src/modules/roles/dto/create-role.dto.ts
  • apps/server/src/modules/socket/interface/socket-event.types.ts
  • apps/server/src/modules/users/users.controller.spec.ts
  • apps/server/src/modules/users/users.service.spec.ts
  • apps/server/src/modules/users/users.service.ts
  • apps/server/test/app.e2e-spec.ts
  • apps/server/test/jest-e2e.json
  • apps/server/tests/e2e/auth.e2e-spec.ts
  • apps/server/tests/e2e/cats.e2e-spec.ts
  • apps/server/tests/e2e/groups.e2e-spec.ts
  • apps/server/tests/e2e/helpers/test-helper.ts
  • apps/server/tests/e2e/permissions.e2e-spec.ts
  • apps/server/tests/e2e/roles.e2e-spec.ts
  • apps/server/tests/e2e/users.e2e-spec.ts
  • apps/server/tests/unit/app.controller.spec.ts
  • apps/server/tests/unit/common/context/user-context.spec.ts
  • apps/server/tests/unit/common/decorators/cookies.decorator.spec.ts
  • apps/server/tests/unit/common/decorators/jwt-auth.decorator.spec.ts
  • apps/server/tests/unit/common/exceptions/error.exception.spec.ts
  • apps/server/tests/unit/common/filters/global-exception.filter.spec.ts
  • apps/server/tests/unit/common/filters/ws-exception.filter.spec.ts
  • apps/server/tests/unit/common/guards/disabled-endpoint.guard.spec.ts
  • apps/server/tests/unit/common/guards/jwt-auth.guard.spec.ts
  • apps/server/tests/unit/common/guards/permission.guard.spec.ts
  • apps/server/tests/unit/common/guards/special-roles.guard.spec.ts
  • apps/server/tests/unit/common/guards/ws-jwt.guard.spec.ts
  • apps/server/tests/unit/common/interceptors/post-response.interceptor.spec.ts
  • apps/server/tests/unit/common/interceptors/timeout.interceptor.spec.ts
  • apps/server/tests/unit/common/interceptors/user-context.interceptor.spec.ts
  • apps/server/tests/unit/common/middleware/logger.middleware.spec.ts
  • apps/server/tests/unit/common/pipes/validation.pipe.spec.ts
  • apps/server/tests/unit/common/response/base.response.spec.ts
  • apps/server/tests/unit/modules/auth/auth.controller.spec.ts
  • apps/server/tests/unit/modules/auth/auth.service.spec.ts
  • apps/server/tests/unit/modules/auth/jwt-auth.strategy.spec.ts
  • apps/server/tests/unit/modules/auth/refresh-token.service.spec.ts
  • apps/server/tests/unit/modules/cats/cats.service.spec.ts
  • apps/server/tests/unit/modules/groups/groups.service.spec.ts
  • apps/server/tests/unit/modules/permissions/permissions.service.spec.ts
  • apps/server/tests/unit/modules/roles/roles.service.spec.ts
  • apps/server/tests/unit/modules/socket/socket.gateway.spec.ts
  • apps/server/tests/unit/modules/socket/socket.service.spec.ts
  • apps/server/tests/unit/modules/users/user.entity.spec.ts
  • apps/server/tests/unit/modules/users/users.service.spec.ts
  • apps/server/tests/unit/shared/caching/cache.constants.spec.ts
  • apps/server/tests/unit/shared/caching/cache.service.spec.ts
  • apps/server/tests/unit/shared/caching/hash-cache.service.spec.ts
  • apps/server/tests/unit/shared/database/snake-naming.strategy.spec.ts
  • apps/server/tests/unit/shared/entity/base.entity.spec.ts
  • apps/server/tests/unit/shared/throttler/redis-throttler-storage.spec.ts
  • apps/server/tests/unit/shared/throttler/throttler.guard.spec.ts
  • apps/server/tests/unit/shared/utils/extract-token.spec.ts
  • apps/server/tests/unit/shared/utils/promise.spec.ts
  • apps/server/tests/unit/shared/utils/roles.spec.ts
  • apps/server/tests/unit/shared/utils/snowflake.spec.ts
  • apps/server/tsconfig.build.json
  • apps/server/vitest.config.ts
  • apps/web/eslint.config.js
  • apps/web/src/hooks/use-socket.ts
  • apps/web/src/services/api/http-factory/__tests__/http-client.cooldown.test.ts
  • apps/web/src/services/api/http-factory/__tests__/http-client.edge-cases.test.ts
  • apps/web/src/services/api/http-factory/__tests__/http-client.test.ts
  • apps/web/src/services/api/http-factory/__tests__/http-client.token-normalization.test.ts
  • apps/web/src/services/api/http-factory/index.ts
  • apps/web/src/services/api/http-factory/reference/README.md
  • apps/web/src/services/api/http-factory/reference/http-demo.ts
  • apps/web/src/services/api/http-factory/token-refresh-manager.ts
  • apps/web/src/services/api/http-factory/types.ts
  • apps/web/src/services/api/socket-event.types.ts
  • commitlint.config.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore-github-ci-vitest

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@fengzai6
fengzai6 merged commit f7863b1 into main Jun 24, 2026
4 checks passed
@fengzai6
fengzai6 deleted the chore-github-ci-vitest branch June 24, 2026 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant