django-ci-test-optimization
Optimize Django and pytest-django test execution in CI with cache configuration, slow-test splitting, database reuse strategy, parallel workers, pytest-xdist, CircleCI/GitHub Actions/Jenkins/Travis patterns, and full-coverage safeguards. Use when CI test jobs are slow, flaky under parallelism, missing slow-test coverage, or need a local-vs-CI test command design.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 1.6k
- Forks
- 491
01 前言 Front Matter
- name
- django-ci-test-optimization
- license
- MIT
- metadata
- { "tags": "django,testing,ci,pytest,github-actions", "version": "0.1.0", "category": "Django", "displayName": "Django CI Test Optimization" }
- description
- Optimize Django and pytest-django test execution in CI with cache configuration, slow-test splitting, database reuse strategy, parallel workers, pytest-xdist, CircleCI/GitHub Actions/Jenkins/Travis patterns, and full-coverage safeguards. Use when CI test jobs are slow, flaky under parallelism, missing slow-test coverage, or need a local-vs-CI test command design.
- compatibility
- Codex, Claude Code, and other Agent Skills-compatible clients.
02 资源文件 1
- 参考文档references/ci-patterns.md1.7 KB
03 SKILL.md 正文
Django CI Test Optimization
CI optimization should reduce feedback time without reducing confidence. Keep fast local commands and full CI coverage distinct, then make the CI path faster with caching, parallelism, and sensible split points.
CI Workflow
-
Capture current CI timing.
- Separate dependency install, test database setup, test execution, and artifact upload.
- Compare CI time with local wall-clock time to spot environment-only overhead.
-
Cache dependencies first.
- Use CI-native cache primitives for pip or package-manager caches.
- Cache the package download cache, not an unsafe mutable virtualenv unless the project already supports that pattern.
-
Keep local shortcuts honest.
- Local runs may skip slow tests or reuse databases.
- CI should run slow tests and at least one migration-realistic database setup path.
-
Split tests deliberately.
- Split slow vs normal tests when slow markers are meaningful.
- Use parallel workers after the suite is safe under
django-test-parallelization. - Avoid duplicating expensive setup across too many shards.
-
Scale hardware only after obvious waste is removed.
- Faster runners can be the pragmatic answer, but they hide inefficient setup when used too early.
Read ci-patterns.md for command and configuration patterns.
Decision Rules
- Cache dependency downloads before rewriting test code for CI-only speed.
- Register pytest marks strictly so
slowtypos do not silently change coverage. - If local commands exclude slow tests, add a CI job that includes them.
- If using no-migration local shortcuts, add a CI path that runs real migrations.
- Split by tags when test categories are intentionally different; split by workers when the suite is homogeneous enough.
- Use timing data to choose shard boundaries.
Common Mistakes
- Caching the wrong path and seeing no improvement.
- Letting slow tests disappear from CI after adding local skip defaults.
- Running too many shards and paying database/setup cost repeatedly.
- Using SQLite in CI for a PostgreSQL/MySQL production app.
- Enabling parallel CI workers before fixing shared resources.
- Treating larger runners as a substitute for profiling.
Verification
Before finishing:
- CI still runs all required test categories.
- Cache keys change when dependencies change.
- Test split commands are documented and reproducible locally where possible.
- Slow-test or worker split reduces wall-clock time in actual CI logs.
- A debugging fallback command exists for serial reproduction.
04 同仓库更多 Skills
worktable-review-with-annotations
Create, inspect, reply to, update, or resolve situated Worktable annotations. Use when feedback belongs to a Doc section, block, text range, or HTML Doc, or when the user asks to address existing review feedback and coordinate a requested artifact edit.
worktable-find-and-synthesize-context
Find, assess, and synthesize context from Worktable Docs and Records. Use when the user asks what a workspace contains, wants workspace-backed research, needs current facts reconciled across artifacts, or requests a cited synthesis without changing workspace state.
worktable-create-or-update-docs
Create, edit, rename, or maintain narrative Worktable Docs. Use for plans, decisions, briefs, notes, research syntheses, and other durable prose when the user requests a new artifact or a safe update to an existing one.
worktable-create-or-manage-records
Organize repeated structured information as durable Worktable Records. Use for research datasets, inventories, directories, pipelines, trackers, and other collections whose items need identity, fields, filtering, links, validation, or individual updates.
worktable-create-or-manage-interactive-html
Create or improve durable visual and interactive artifacts in Worktable. Use for dashboards, trackers, calculators, mini apps, slide presentations, and other requests that benefit from a polished HTML Doc.
worktable-collaborate-threads
Read, answer, and hand off messages through durable Worktable threads with users or other authenticated participants. Use when the user asks to check addressed messages, reply to a participant, continue a thread, request another agent's help, wait briefly for a response, or watch for comments and messages sent to the agent.