Some checks failed
CI / lint-typecheck (pull_request) Failing after 4m51s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped
2.8 KiB
2.8 KiB
CI/CD & Dev Experience Optimization Plan
Current Situation
- Husky
pre-commit: Runsnpm test(Vitest) on every commit. This likely runs the entire test suite, which is slow and frustrating for developers. - Gitea Actions: Currently only has
contract-testing.yml. - Missing: No automated linting or type-checking in CI, no tiered testing strategy.
Proposed Strategy: The "Fast Feedback Loop"
We will implement a tiered approach to balance speed and safety.
1. Local Development (Husky + lint-staged)
Goal: Prevent obvious errors from entering the repo without slowing down the dev.
- Trigger:
pre-commit - Action: Only run on staged files.
- Tasks:
eslint --fixprettier --writevitest related(only run tests related to changed files)
2. Pull Request (Gitea Actions)
Goal: Ensure the branch is stable and doesn't break the build or other modules.
- Trigger: PR creation and updates.
- Tasks:
- Full
lint - Full
typecheck(crucial for monorepo integrity) - Full
unit tests integration testscontract tests
- Full
3. Merge to Main / Release (Gitea Actions)
Goal: Final verification before deployment.
- Trigger: Push to
mainordevelop. - Tasks:
- Everything from PR stage.
e2e tests(Playwright) - these are the slowest and most expensive.
Implementation Steps
Step 1: Install and Configure lint-staged
We need to add lint-staged to package.json and update the Husky hook.
Step 2: Optimize Husky Hook
Update .husky/pre-commit to run npx lint-staged instead of npm test.
Step 3: Create Comprehensive CI Workflow
Create .github/workflows/ci.yml (Gitea Actions compatible) to handle the heavy lifting.
Workflow Diagram
graph TD
A[Developer Commits] --> B{Husky pre-commit}
B -->|lint-staged| C[Lint/Format Changed Files]
C --> D[Run Related Tests]
D --> E[Commit Success]
E --> F[Push to PR]
F --> G{Gitea CI PR Job}
G --> H[Full Lint & Typecheck]
G --> I[Full Unit & Integration Tests]
G --> J[Contract Tests]
J --> K{Merge to Main}
K --> L{Gitea CI Main Job}
L --> M[All PR Checks]
L --> N[Full E2E Tests]
N --> O[Deploy/Release]
Proposed lint-staged Configuration
{
"*.{js,ts,tsx}": ["eslint --fix", "vitest related --run"],
"*.{json,md,yml}": ["prettier --write"]
}
Questions for the User
- Do you want to include
typecheckin thepre-commithook? (Note:tscdoesn't support linting only changed files easily, so it usually checks the whole project, which might be slow). - Should we run
integration testson every PR, or only on merge tomain? - Are there specific directories that should be excluded from this automated flow?