From e88b447711b4720a9689b46683c453cf7e415973 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Sep 2025 21:03:36 +0000 Subject: [PATCH 1/2] Initial plan From c65a66dac9eccbb1e6d1fff5c0eb4d159f5412cb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Sep 2025 21:14:54 +0000 Subject: [PATCH 2/2] Rename --workflow-dir flag to --workflows-dir Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- Makefile | 2 +- cmd/gh-aw/main.go | 6 +++--- pkg/cli/commands.go | 2 +- pkg/cli/workflow_dir_test.go | 22 +++++++++++----------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index a40efddd616..027333e0da1 100644 --- a/Makefile +++ b/Makefile @@ -152,7 +152,7 @@ install: build .PHONY: recompile recompile: build ./$(BINARY_NAME) compile --validate --instructions - ./$(BINARY_NAME) compile --workflow-dir pkg/cli/workflows --validate; + ./$(BINARY_NAME) compile --workflows-dir pkg/cli/workflows --validate; # Run development server .PHONY: dev diff --git a/cmd/gh-aw/main.go b/cmd/gh-aw/main.go index f46a5323d66..2a9f6a37072 100644 --- a/cmd/gh-aw/main.go +++ b/cmd/gh-aw/main.go @@ -206,13 +206,13 @@ Examples: ` + constants.CLIExtensionPrefix + ` compile weekly-research # Compile a specific workflow ` + constants.CLIExtensionPrefix + ` compile weekly-research daily-plan # Compile multiple workflows ` + constants.CLIExtensionPrefix + ` compile workflow.md # Compile by file path - ` + constants.CLIExtensionPrefix + ` compile --workflow-dir custom/workflows # Compile from custom directory + ` + constants.CLIExtensionPrefix + ` compile --workflows-dir custom/workflows # Compile from custom directory ` + constants.CLIExtensionPrefix + ` compile --watch weekly-research # Watch and auto-compile`, Run: func(cmd *cobra.Command, args []string) { engineOverride, _ := cmd.Flags().GetString("engine") validate, _ := cmd.Flags().GetBool("validate") watch, _ := cmd.Flags().GetBool("watch") - workflowDir, _ := cmd.Flags().GetString("workflow-dir") + workflowDir, _ := cmd.Flags().GetString("workflows-dir") instructions, _ := cmd.Flags().GetBool("instructions") noEmit, _ := cmd.Flags().GetBool("no-emit") purge, _ := cmd.Flags().GetBool("purge") @@ -349,7 +349,7 @@ func init() { compileCmd.Flags().StringP("engine", "a", "", "Override AI engine (claude, codex)") compileCmd.Flags().Bool("validate", true, "Enable GitHub Actions workflow schema validation (default: true)") compileCmd.Flags().BoolP("watch", "w", false, "Watch for changes to workflow files and recompile automatically") - compileCmd.Flags().String("workflow-dir", "", "Relative directory containing workflows (default: .github/workflows)") + compileCmd.Flags().String("workflows-dir", "", "Relative directory containing workflows (default: .github/workflows)") compileCmd.Flags().Bool("instructions", false, "Generate or update GitHub Copilot instructions file") compileCmd.Flags().Bool("no-emit", false, "Validate workflow without generating lock files") compileCmd.Flags().Bool("purge", false, "Delete .lock.yml files that were not regenerated during compilation (only when no specific files are specified)") diff --git a/pkg/cli/commands.go b/pkg/cli/commands.go index 4a4a9ba2337..54dec0e19cc 100644 --- a/pkg/cli/commands.go +++ b/pkg/cli/commands.go @@ -615,7 +615,7 @@ func CompileWorkflows(markdownFiles []string, verbose bool, engineOverride strin } else { // Ensure the path is relative if filepath.IsAbs(workflowDir) { - return fmt.Errorf("workflow-dir must be a relative path, got: %s", workflowDir) + return fmt.Errorf("workflows-dir must be a relative path, got: %s", workflowDir) } // Clean the path to avoid issues with ".." or other problematic elements workflowDir = filepath.Clean(workflowDir) diff --git a/pkg/cli/workflow_dir_test.go b/pkg/cli/workflow_dir_test.go index 2ab33d001b1..a6e7fd571e8 100644 --- a/pkg/cli/workflow_dir_test.go +++ b/pkg/cli/workflow_dir_test.go @@ -7,7 +7,7 @@ import ( "testing" ) -// TestCompileWorkflowsWithCustomWorkflowDir tests the --workflow-dir flag functionality +// TestCompileWorkflowsWithCustomWorkflowDir tests the --workflows-dir flag functionality func TestCompileWorkflowsWithCustomWorkflowDir(t *testing.T) { // Save current directory and defer restoration originalWd, err := os.Getwd() @@ -19,7 +19,7 @@ func TestCompileWorkflowsWithCustomWorkflowDir(t *testing.T) { }() // Create a temporary git repository with custom workflow directory - tmpDir, err := os.MkdirTemp("", "workflow-dir-test") + tmpDir, err := os.MkdirTemp("", "workflows-dir-test") if err != nil { t.Fatalf("Failed to create temp directory: %v", err) } @@ -60,7 +60,7 @@ This is a test workflow in a custom directory. // Test 1: Compile with custom workflow directory should work err = CompileWorkflows([]string{}, false, "", false, false, customDir, false, false, false) if err != nil { - t.Errorf("CompileWorkflows with custom workflow-dir should succeed, got error: %v", err) + t.Errorf("CompileWorkflows with custom workflows-dir should succeed, got error: %v", err) } // Verify the lock file was created @@ -72,13 +72,13 @@ This is a test workflow in a custom directory. // Test 2: Using absolute path should fail err = CompileWorkflows([]string{}, false, "", false, false, "/absolute/path", false, false, false) if err == nil { - t.Error("CompileWorkflows with absolute workflow-dir should fail") + t.Error("CompileWorkflows with absolute workflows-dir should fail") } - if err != nil && err.Error() != "workflow-dir must be a relative path, got: /absolute/path" { + if err != nil && err.Error() != "workflows-dir must be a relative path, got: /absolute/path" { t.Errorf("Expected specific error message for absolute path, got: %v", err) } - // Test 3: Empty workflow-dir should default to .github/workflows + // Test 3: Empty workflows-dir should default to .github/workflows // Create the default directory and a file defaultDir := ".github/workflows" if err := os.MkdirAll(defaultDir, 0755); err != nil { @@ -91,7 +91,7 @@ This is a test workflow in a custom directory. err = CompileWorkflows([]string{}, false, "", false, false, "", false, false, false) if err != nil { - t.Errorf("CompileWorkflows with default workflow-dir should succeed, got error: %v", err) + t.Errorf("CompileWorkflows with default workflows-dir should succeed, got error: %v", err) } // Verify the lock file was created in default location @@ -123,7 +123,7 @@ func TestCompileWorkflowsCustomDirValidation(t *testing.T) { name: "absolute path is invalid", workflowDir: "/absolute/path", expectError: true, - errorMsg: "workflow-dir must be a relative path, got: /absolute/path", + errorMsg: "workflows-dir must be a relative path, got: /absolute/path", }, { name: "path with .. is cleaned but valid", @@ -135,7 +135,7 @@ func TestCompileWorkflowsCustomDirValidation(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { // Create a temporary directory for each test - tmpDir, err := os.MkdirTemp("", "workflow-dir-validation-test") + tmpDir, err := os.MkdirTemp("", "workflows-dir-validation-test") if err != nil { t.Fatalf("Failed to create temp directory: %v", err) } @@ -187,13 +187,13 @@ on: push if tt.expectError { if err == nil { - t.Errorf("Expected error for workflow-dir '%s', but got none", tt.workflowDir) + t.Errorf("Expected error for workflows-dir '%s', but got none", tt.workflowDir) } else if err.Error() != tt.errorMsg { t.Errorf("Expected error message '%s', got '%s'", tt.errorMsg, err.Error()) } } else { if err != nil { - t.Errorf("Expected no error for workflow-dir '%s', but got: %v", tt.workflowDir, err) + t.Errorf("Expected no error for workflows-dir '%s', but got: %v", tt.workflowDir, err) } } })