|
| 1 | +# Codecov Setup Guide |
| 2 | + |
| 3 | +This project uses [Codecov](https://codecov.io/) for test coverage reporting. |
| 4 | + |
| 5 | +## 📊 Coverage Status |
| 6 | + |
| 7 | +[](https://codecov.io/gh/simonguo/react-code-view) |
| 8 | + |
| 9 | +## 🚀 Setup Instructions |
| 10 | + |
| 11 | +### 1. Enable Codecov for Your Repository |
| 12 | + |
| 13 | +1. Go to [codecov.io](https://codecov.io/) |
| 14 | +2. Sign in with your GitHub account |
| 15 | +3. Add your repository `simonguo/react-code-view` |
| 16 | +4. Get your upload token from the repository settings |
| 17 | + |
| 18 | +### 2. Add Codecov Token to GitHub Secrets |
| 19 | + |
| 20 | +1. Go to your GitHub repository settings |
| 21 | +2. Navigate to **Settings** → **Secrets and variables** → **Actions** |
| 22 | +3. Click **New repository secret** |
| 23 | +4. Name: `CODECOV_TOKEN` |
| 24 | +5. Value: `8940f287-54c0-4594-ae35-d9379d71c3f0` |
| 25 | +6. Click **Add secret** |
| 26 | + |
| 27 | +> **Note**: The token is already configured for this repository. |
| 28 | +
|
| 29 | +### 3. Coverage Reports |
| 30 | + |
| 31 | +Coverage reports are automatically generated and uploaded on: |
| 32 | +- Every push to `main` branch |
| 33 | +- Every pull request to `main` branch |
| 34 | + |
| 35 | +## 📈 Local Coverage Generation |
| 36 | + |
| 37 | +Generate coverage reports locally: |
| 38 | + |
| 39 | +```bash |
| 40 | +# Generate coverage for all packages |
| 41 | +pnpm test:coverage |
| 42 | + |
| 43 | +# View HTML coverage reports |
| 44 | +open packages/core/coverage/index.html |
| 45 | +open packages/react/coverage/index.html |
| 46 | +open packages/unplugin/coverage/index.html |
| 47 | +``` |
| 48 | + |
| 49 | +## 📝 Coverage Configuration |
| 50 | + |
| 51 | +Coverage settings are configured in: |
| 52 | +- `codecov.yml` - Codecov-specific configuration |
| 53 | +- `packages/*/vitest.config.ts` - Test coverage settings per package |
| 54 | + |
| 55 | +### Current Coverage Targets |
| 56 | + |
| 57 | +- **Project coverage**: Auto (with 1% threshold) |
| 58 | +- **Patch coverage**: Auto (with 1% threshold) |
| 59 | +- **Precision**: 2 decimal places |
| 60 | +- **Range**: 70-100% |
| 61 | + |
| 62 | +## 🔍 What's Covered |
| 63 | + |
| 64 | +All packages have comprehensive test coverage: |
| 65 | + |
| 66 | +- **@react-code-view/core**: Core markdown transformation and syntax highlighting |
| 67 | +- **@react-code-view/react**: React components and hooks |
| 68 | +- **@react-code-view/unplugin**: Build tool plugins (Vite, Webpack, Rollup, etc.) |
| 69 | + |
| 70 | +## 🚫 Ignored Files |
| 71 | + |
| 72 | +The following files are excluded from coverage: |
| 73 | +- Test files (`**/*.test.ts`, `**/*.test.tsx`) |
| 74 | +- Type definitions (`**/*.d.ts`) |
| 75 | +- Configuration files (`**/*.config.*`) |
| 76 | +- Distribution files (`**/dist/**`) |
| 77 | +- Node modules (`**/node_modules/**`) |
| 78 | +- Index files (`**/index.ts`) |
| 79 | +- Icon files (`packages/react/src/icons/**`) |
| 80 | +- Examples (`examples/**`) |
| 81 | +- Documentation (`docs/**`) |
| 82 | + |
| 83 | +## 📊 Coverage Reports |
| 84 | + |
| 85 | +Coverage reports include: |
| 86 | +- **Text**: Console output during test runs |
| 87 | +- **JSON**: Machine-readable format |
| 88 | +- **HTML**: Interactive browser-based reports |
| 89 | +- **LCOV**: Standard format for Codecov upload |
| 90 | + |
| 91 | +## 🔗 Useful Links |
| 92 | + |
| 93 | +- [Codecov Dashboard](https://codecov.io/gh/simonguo/react-code-view) |
| 94 | +- [Codecov Documentation](https://docs.codecov.com/) |
| 95 | +- [GitHub Actions Workflow](.github/workflows/nodejs-ci.yml) |
0 commit comments