Integrate ScriptExecutor into HooksRunner
Part of #7435 — Multi-Language Hook Support
User Story
As a template consumer, I want Python hooks defined in azure.yaml to execute automatically during azd up/azd deploy alongside existing shell hooks so the deployment lifecycle works end-to-end.
Solution Approach
Modify pkg/ext/hooks_runner.go:
-
Add import for pkg/tools/language.
-
Add GetScriptExecutor(hookConfig *HookConfig) (language.ScriptExecutor, error) method:
- Resolve executor via
language.GetExecutor(hookConfig.ScriptLanguage(), h.commandRunner, h.console, h.cwd).
-
Update execHook() — branch on hookConfig.IsLanguageHook():
if hookConfig.IsLanguageHook() {
executor, err := h.GetScriptExecutor(hookConfig)
// ...
if err := executor.Prepare(ctx, hookConfig.path); err != nil { ... }
res, err := executor.Execute(ctx, hookConfig.path, *options)
// ... shared post-execution logic ...
} else {
// existing shell hook path — unchanged
}
-
Extract shared post-execution logic (ContinueOnError, output previewer, cleanup) into helper to avoid duplication.
-
Thread environment variables via ExecOptions.Env or executor constructor.
Modify pkg/ext/hooks_runner_test.go:
- Python hook full pipeline (mock CommandRunner expects: version check → venv → pip → execute)
- Shell hook unchanged (
.sh does NOT trigger language path)
- ContinueOnError with failing Python hook
- Interactive mode flag passthrough
Follow existing test pattern: mocks.NewMockContext, mockenv.MockEnvManager, mockContext.CommandRunner.When(...).RespondFn(...).
Files: pkg/ext/hooks_runner.go (MODIFY), pkg/ext/hooks_runner_test.go (MODIFY)
Acceptance Criteria
References
Integrate ScriptExecutor into HooksRunner
Part of #7435 — Multi-Language Hook Support
User Story
As a template consumer, I want Python hooks defined in azure.yaml to execute automatically during
azd up/azd deployalongside existing shell hooks so the deployment lifecycle works end-to-end.Solution Approach
Modify
pkg/ext/hooks_runner.go:Add import for
pkg/tools/language.Add
GetScriptExecutor(hookConfig *HookConfig) (language.ScriptExecutor, error)method:language.GetExecutor(hookConfig.ScriptLanguage(), h.commandRunner, h.console, h.cwd).Update
execHook()— branch onhookConfig.IsLanguageHook():Extract shared post-execution logic (ContinueOnError, output previewer, cleanup) into helper to avoid duplication.
Thread environment variables via
ExecOptions.Envor executor constructor.Modify
pkg/ext/hooks_runner_test.go:.shdoes NOT trigger language path)Follow existing test pattern:
mocks.NewMockContext,mockenv.MockEnvManager,mockContext.CommandRunner.When(...).RespondFn(...).Files:
pkg/ext/hooks_runner.go(MODIFY),pkg/ext/hooks_runner_test.go(MODIFY)Acceptance Criteria
.pyhooks execute through ScriptExecutor path automatically.sh/.ps1hooks execute through existing Script path (no regression)ContinueOnErrorandInteractiveflags work for language hooksReferences