Skip to content

🏗️ Add dry-run support for trial command#13804

Merged
dsyme merged 3 commits intomainfrom
ft
Feb 4, 2026
Merged

🏗️ Add dry-run support for trial command#13804
dsyme merged 3 commits intomainfrom
ft

Conversation

@dsyme
Copy link
Contributor

@dsyme dsyme commented Feb 4, 2026

Summary

  • Introduced a new --dry-run flag for the trial command to preview actions without making changes
  • Updated ensureTrialRepository function to support dry-run mode
  • Added verbose logging for dry-run scenarios

Details

The changes enable users to run trial workflows in a preview mode, showing what actions would be taken without actually executing them. This is helpful for understanding the potential impact of a trial before committing to the full process.

Copilot AI review requested due to automatic review settings February 4, 2026 22:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds dry-run functionality to the trial command, allowing users to preview what actions would be taken without making actual changes to repositories. This is useful for understanding the impact of a trial workflow before execution.

Changes:

  • Added a --dry-run flag to the trial command that previews actions without executing them
  • Modified ensureTrialRepository function to support dry-run mode with appropriate logging
  • Implemented early exit logic in RunWorkflowTrials to stop execution after dry-run preview

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
pkg/cli/trial_command.go Added DryRun field to TrialOptions struct, registered --dry-run flag, and implemented early exit logic when dry-run mode is enabled
pkg/cli/trial_repository.go Updated ensureTrialRepository function signature to accept dryRun parameter and added conditional logic to preview instead of execute repository operations
pkg/cli/repo_error_messages_test.go Updated test call to ensureTrialRepository with additional dryRun parameter
Comments suppressed due to low confidence (1)

pkg/cli/trial_repository.go:56

  • When both verbose and dry-run modes are enabled with forceDeleteHostRepo, two similar messages are printed: one at line 52 saying "Force deleting existing host repository" and another at line 56 saying "[DRY RUN] Would delete repository". This is redundant and could confuse users. Consider consolidating these into a single message or skipping the verbose message when in dry-run mode.
			if verbose {
				fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Force deleting existing host repository: %s", repoSlug)))
			}

			if dryRun {
				fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("[DRY RUN] Would delete repository: %s", repoSlug)))

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if repoExists {
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("[DRY RUN] Repository %s exists", repoSlug)))
} else {
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("[DRY RUN] Repository %s does not exist (output: %s)", repoSlug, string(output))))
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dry-run output exposes the error message when checking if a repository doesn't exist. This could potentially leak sensitive information or contain confusing technical details. Consider removing the output parameter from the message or limiting it to verbose mode only. A cleaner approach would be to simply state "[DRY RUN] Repository {repoSlug} does not exist" without including the raw error output.

Suggested change
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("[DRY RUN] Repository %s does not exist (output: %s)", repoSlug, string(output))))
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("[DRY RUN] Repository %s does not exist", repoSlug)))

Copilot uses AI. Check for mistakes.
Comment on lines +76 to +80
prefix := ""
if dryRun {
prefix = "[DRY RUN] "
}
fmt.Fprintln(os.Stderr, console.FormatSuccessMessage(fmt.Sprintf("%sUsing existing host repository: https://github.com/%s", prefix, repoSlug)))
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When reusing an existing repository in dry-run mode, the verbose information message (lines 69-74) is only shown when verbose flag is set, but the success message (line 80) is always shown with the dry-run prefix. For consistency in dry-run mode, consider showing the informational context (whether contents will be force-pushed) regardless of the verbose flag, similar to how the creation messages work (line 86 where dry-run implies showing the message).

See below for a potential fix:

			prefix := ""
			if dryRun {
				prefix = "[DRY RUN] "
			}
			if verbose || dryRun {
				if cloneRepoSlug != "" {
					fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("%sReusing existing host repository: %s (contents will be force-pushed)", prefix, repoSlug)))
				} else {
					fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("%sReusing existing host repository: %s", prefix, repoSlug)))
				}
			}

Copilot uses AI. Check for mistakes.
Comment on lines +318 to +322
// In dry-run mode, stop here after showing what would be done
if opts.DryRun {
fmt.Fprintln(os.Stderr, console.FormatInfoMessage("[DRY RUN] Stopping here. No actual changes were made."))
return nil
}
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new dry-run functionality lacks test coverage. Given that the codebase has comprehensive test coverage for similar flag-based functionality (as seen in the test files), consider adding unit tests to verify:

  1. The dry-run flag is correctly parsed and stored in TrialOptions
  2. The ensureTrialRepository function behaves correctly in dry-run mode (doesn't make actual API calls that modify state)
  3. The early exit logic at line 319-322 is triggered correctly in dry-run mode
  4. Dry-run messages are formatted consistently

This would help ensure the feature works as expected and prevent regressions.

Copilot uses AI. Check for mistakes.
@dsyme dsyme merged commit 0d4539d into main Feb 4, 2026
49 of 50 checks passed
@dsyme dsyme deleted the ft branch February 4, 2026 23:08
github-actions bot added a commit that referenced this pull request Feb 5, 2026
Add documentation for the new --dry-run flag added to the trial command
in PR #13804. This flag allows users to preview trial operations without
executing workflows or creating repositories.

Changes:
- Updated CLI reference to include --dry-run flag and usage example
- Added "Dry-Run Mode" section to TrialOps guide
- Updated "Development Workflow" best practices to include dry-run step

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant