CI
Continuous integration for Vant.
┌─────────────────────────────────────────────────┐
│ CI Pipeline │
│ │
│ push ──▶ lint ──▶ test ──▶ build ──▶ deploy │
│ ↓ ↓ ↓ ↓ │
│ [fail] [fail] [fail] [main] │
└─────────────────────────────────────────────────┘
GitHub Actions
Vant uses GitHub Actions for CI.
Workflows
| Workflow | Trigger | What | Status |
|---|---|---|---|
| test.yml | push | Run tests | Required |
| lint.yml | push | Lint code | Required |
| deploy.yml | push to main | Deploy | Auto |
Test Workflow
# .github/workflows/test.yml
name: Test
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install deps
run: npm ci
- name: Run tests
run: npm test
- name: Upload coverage
uses: codecov/codecov-action@v3
Lint Workflow
# .github/workflows/lint.yml
name: Lint
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install deps
run: npm ci
- name: Lint
run: npm run lint
Run Locally
Install Dependencies
npm install
Run Tests
# All tests
npm test
# Watch mode
npm run test:watch
# Coverage
npm run test:coverage
Lint
# Full lint
npm run lint
# Fix auto-fixable
npm run lint:fix
Build
# Build
npm run build
# Watch mode
npm run build:watch
Code Coverage
Required: 80%+
# Generate coverage report
npm run test:coverage
# View locally
open coverage/lcov-report/index.html
Pre-Commit Checks
Run before committing:
# Single command - runs all checks
npm run pre-commit
# This runs:
# 1. lint
# 2. test
# 3. build
Troubleshooting
Tests Fail
# Run with verbose output
npm test -- --verbose
# Run single test
npm test -- --grep "specific test"
Lint Errors
# See detailed errors
npm run lint 2>&1
# Check specific file
npx eslint path/to/file.js