2026-08-21 15:58:46 -07:00
|
|
|
package action
|
|
|
|
|
|
2026-08-21 18:07:12 -07:00
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"fmt"
|
|
|
|
|
"os/exec"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// RunIntegrationTestInput is input to RunIntegrationTestActivity.
|
|
|
|
|
type RunIntegrationTestInput struct {
|
|
|
|
|
WorktreePath string
|
|
|
|
|
TestCmd string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// RunIntegrationTestOutput is the output of RunIntegrationTestActivity.
|
|
|
|
|
type RunIntegrationTestOutput struct {
|
|
|
|
|
Passed bool
|
|
|
|
|
Logs string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// RunIntegrationTestActivity runs integration tests in the worktree.
|
|
|
|
|
func RunIntegrationTestActivity(ctx context.Context, in RunIntegrationTestInput) (RunIntegrationTestOutput, error) {
|
|
|
|
|
if in.TestCmd == "" {
|
|
|
|
|
// No test command, assume pass
|
|
|
|
|
return RunIntegrationTestOutput{Passed: true, Logs: "No test command provided"}, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Run test command
|
|
|
|
|
cmd := exec.CommandContext(ctx, "sh", "-c", in.TestCmd)
|
|
|
|
|
cmd.Dir = in.WorktreePath
|
|
|
|
|
|
|
|
|
|
output, err := cmd.CombinedOutput()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return RunIntegrationTestOutput{
|
|
|
|
|
Passed: false,
|
|
|
|
|
Logs: string(output) + "\nError: " + err.Error(),
|
|
|
|
|
}, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return RunIntegrationTestOutput{
|
|
|
|
|
Passed: true,
|
|
|
|
|
Logs: string(output),
|
|
|
|
|
}, nil
|
|
|
|
|
}
|