-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
Enable parallel execution of independent hooks using Deno Workers to significantly speed up pre-commit/pre-push operations.
Motivation
Current implementation runs hooks sequentially:
- Slow for projects with multiple hooks
- Wastes time when hooks are independent
- Poor developer experience (waiting for each hook)
Example: fmt + lint + test could run in ~3 seconds instead of ~9 seconds.
Proposed Solution
hooks:
pre-commit:
- id: fmt
run: deno-fmt
parallel: true # Can run in parallel
- id: lint
run: deno-lint
parallel: true # Can run in parallel
- id: test
run: deno-test
parallel: false # Must run after fmt/lint
depends_on: [fmt, lint]Implementation Strategy
- Build dependency graph from
depends_onfields - Identify hooks that can run in parallel (no dependencies)
- Use Deno Workers to execute independent hooks concurrently
- Wait for dependencies before running dependent hooks
- Aggregate results and report
interface HookConfig {
id: string;
run: string;
parallel?: boolean; // Default: true
depends_on?: string[]; // IDs of hooks that must complete first
}
async function executeHooksInParallel(hooks: HookConfig[]): Promise<HookResult[]> {
const graph = buildDependencyGraph(hooks);
const results: HookResult[] = [];
for (const batch of graph.batches) {
// Execute batch in parallel
const batchResults = await Promise.all(
batch.map(hook => executeInWorker(hook))
);
results.push(...batchResults);
// Stop if any hook failed
if (batchResults.some(r => !r.success)) {
break;
}
}
return results;
}Benefits
- ✅ 3x faster pre-commit hooks in typical projects
- ✅ Better developer experience (less waiting)
- ✅ Leverages Deno's Web Workers - native parallelism
- ✅ Smart dependency handling
- ✅ Graceful degradation (falls back to sequential if needed)
Configuration Examples
Simple parallel:
hooks:
pre-commit:
- id: fmt
run: deno-fmt
- id: lint
run: deno-lint
# Both run in parallel by defaultWith dependencies:
hooks:
pre-commit:
- id: fmt
run: deno-fmt
- id: lint
run: deno-lint
- id: test
run: deno-test
depends_on: [fmt, lint] # Runs after fmt and lint complete
- id: build
run: deno task build
depends_on: [test] # Runs after test completesOpt-out of parallel:
hooks:
pre-commit:
- id: database-migration
run: ./migrate.ts
parallel: false # Always run sequentiallyFiles to Modify
src/run.ts- Orchestrate parallel executionsrc/executor.ts- Support Worker-based executionsrc/hook.ts- Addparallelanddepends_onto typessrc/config.ts- Parse new configuration options
Priority
MEDIUM - High impact on developer experience, moderate complexity
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request