Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 37 additions & 18 deletions pkg/cli/trial_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,21 +310,6 @@ func RunWorkflowTrials(workflowSpecs []string, logicalRepoSpec string, cloneRepo
if err := cloneRepoContentsIntoHost(cloneRepoSlug, cloneRepoVersion, hostRepoSlug, verbose); err != nil {
return fmt.Errorf("failed to clone repository contents: %w", err)
}

// After cloning, disable all workflows except the ones being trialled
// Build list of workflow names to keep enabled
var workflowsToKeep []string
for _, spec := range parsedSpecs {
workflowsToKeep = append(workflowsToKeep, spec.WorkflowName)
}

if verbose {
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Disabling workflows in cloned repository (keeping: %s)", strings.Join(workflowsToKeep, ", "))))
}
if err := DisableAllWorkflowsExcept(hostRepoSlug, workflowsToKeep, verbose); err != nil {
// Log warning but don't fail the trial - workflow disabling is not critical
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to disable workflows: %v", err)))
}
}

// Function to run all trials once
Expand Down Expand Up @@ -353,6 +338,43 @@ func RunWorkflowTrials(workflowSpecs []string, logicalRepoSpec string, cloneRepo
}
}()

// Step 3.5: Disable all workflows except the ones being trialled (only in clone-repo mode)
if cloneRepoSlug != "" {
// Build list of workflow names to keep enabled
var workflowsToKeep []string
for _, spec := range parsedSpecs {
workflowsToKeep = append(workflowsToKeep, spec.WorkflowName)
}

if verbose {
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Disabling workflows in cloned repository (keeping: %s)", strings.Join(workflowsToKeep, ", "))))
}

// Change to temp directory to access local .github/workflows
originalDir, err := os.Getwd()
if err != nil {
return fmt.Errorf("failed to get current directory: %w", err)
}

if err := os.Chdir(tempDir); err != nil {
return fmt.Errorf("failed to change to temp directory: %w", err)
}

// Disable workflows (pass empty string for repoSlug since we're working locally)
disableErr := DisableAllWorkflowsExcept("", workflowsToKeep, verbose)

// Change back to original directory
if err := os.Chdir(originalDir); err != nil {
return fmt.Errorf("failed to change back to original directory: %w", err)
}

// Check for disable errors after changing back
if disableErr != nil {
// Log warning but don't fail the trial - workflow disabling is not critical
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to disable workflows: %v", disableErr)))
}
}

// Step 4: Create trials directory
if err := os.MkdirAll("trials", 0755); err != nil {
return fmt.Errorf("failed to create trials directory: %w", err)
Expand Down Expand Up @@ -1122,9 +1144,6 @@ func determineAndAddEngineSecret(engineConfig *workflow.EngineConfig, hostRepoSl
fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Determining required engine secret for workflow"))
}

// Debug: Always show what engine override we received
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("DEBUG: engineOverride parameter = '%s'", engineOverride)))

// Use engine override if provided
if engineOverride != "" {
engineType = engineOverride
Expand Down
Loading