Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions cmd/gh-aw/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)")
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 11 additions & 11 deletions pkg/cli/workflow_dir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
}
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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",
Expand All @@ -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)
}
Expand Down Expand Up @@ -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)
}
}
})
Expand Down
Loading