diff --git a/.github/workflows/daily-team-status.lock.yml b/.github/workflows/daily-team-status.lock.yml index c5be529de0..794a8b0d0f 100644 --- a/.github/workflows/daily-team-status.lock.yml +++ b/.github/workflows/daily-team-status.lock.yml @@ -1858,6 +1858,7 @@ jobs: model: process.env.GH_AW_MODEL_AGENT_COPILOT || "", version: "", agent_version: "0.0.369", + cli_version: "e44a690", workflow_name: "Daily Team Status", experimental: false, supports_tools_allowlist: true, diff --git a/pkg/workflow/aw_info_versions_test.go b/pkg/workflow/aw_info_versions_test.go index 0902a4cec3..3365178f77 100644 --- a/pkg/workflow/aw_info_versions_test.go +++ b/pkg/workflow/aw_info_versions_test.go @@ -9,22 +9,53 @@ import ( func TestCLIVersionInAwInfo(t *testing.T) { tests := []struct { - name string - cliVersion string - engineID string - description string + name string + cliVersion string + engineID string + description string + shouldInclude bool }{ { - name: "CLI version is stored in aw_info.json", - cliVersion: "1.2.3", - engineID: "copilot", - description: "Should include cli_version field with correct value", + name: "Released CLI version is stored in aw_info.json", + cliVersion: "1.2.3", + engineID: "copilot", + description: "Should include cli_version field with correct value for released builds", + shouldInclude: true, }, { - name: "CLI version with semver prerelease", - cliVersion: "1.2.3-beta.1", - engineID: "claude", - description: "Should handle prerelease versions", + name: "CLI version with semver prerelease", + cliVersion: "1.2.3-beta.1", + engineID: "claude", + description: "Should handle prerelease versions", + shouldInclude: true, + }, + { + name: "Development CLI version is excluded", + cliVersion: "dev", + engineID: "copilot", + description: "Should NOT include cli_version field for development builds", + shouldInclude: false, + }, + { + name: "Dirty CLI version is excluded", + cliVersion: "1.2.3-dirty", + engineID: "copilot", + description: "Should NOT include cli_version field for dirty builds", + shouldInclude: false, + }, + { + name: "Test CLI version is excluded", + cliVersion: "1.0.0-test", + engineID: "claude", + description: "Should NOT include cli_version field for test builds", + shouldInclude: false, + }, + { + name: "Git hash with dirty suffix is excluded", + cliVersion: "708d3ee-dirty", + engineID: "copilot", + description: "Should NOT include cli_version field for git hash with dirty suffix", + shouldInclude: false, }, } @@ -46,9 +77,19 @@ func TestCLIVersionInAwInfo(t *testing.T) { output := yaml.String() expectedLine := `cli_version: "` + tt.cliVersion + `"` - if !strings.Contains(output, expectedLine) { - t.Errorf("%s: Expected output to contain '%s', got:\n%s", - tt.description, expectedLine, output) + containsVersion := strings.Contains(output, expectedLine) + + if tt.shouldInclude { + if !containsVersion { + t.Errorf("%s: Expected output to contain '%s', got:\n%s", + tt.description, expectedLine, output) + } + } else { + // For dev builds, cli_version should not appear at all + if strings.Contains(output, "cli_version:") { + t.Errorf("%s: Expected output to NOT contain 'cli_version:' field, got:\n%s", + tt.description, output) + } } }) } @@ -122,7 +163,7 @@ func TestAwfVersionInAwInfo(t *testing.T) { func TestBothVersionsInAwInfo(t *testing.T) { // Test that both CLI version and AWF version are present simultaneously - compiler := NewCompiler(false, "", "2.0.0-test") + compiler := NewCompiler(false, "", "2.0.0-beta.5") registry := GetGlobalEngineRegistry() engine, err := registry.GetEngine("copilot") if err != nil { @@ -144,7 +185,7 @@ func TestBothVersionsInAwInfo(t *testing.T) { output := yaml.String() // Check for cli_version - expectedCLILine := `cli_version: "2.0.0-test"` + expectedCLILine := `cli_version: "2.0.0-beta.5"` if !strings.Contains(output, expectedCLILine) { t.Errorf("Expected output to contain cli_version '%s', got:\n%s", expectedCLILine, output) } diff --git a/pkg/workflow/compiler_yaml.go b/pkg/workflow/compiler_yaml.go index 186cd00e55..6f425c54e1 100644 --- a/pkg/workflow/compiler_yaml.go +++ b/pkg/workflow/compiler_yaml.go @@ -338,6 +338,22 @@ func (c *Compiler) generatePostSteps(yaml *strings.Builder, data *WorkflowData) } } +// isReleasedVersion checks if a version string represents a released build. +// It excludes development builds (containing "dev", "dirty", or "test"). +func isReleasedVersion(version string) bool { + if version == "" { + return false + } + // Filter out development/test versions + excludePatterns := []string{"dev", "dirty", "test"} + for _, pattern := range excludePatterns { + if strings.Contains(version, pattern) { + return false + } + } + return true +} + func (c *Compiler) generateCreateAwInfo(yaml *strings.Builder, data *WorkflowData, engine CodingAgentEngine) { yaml.WriteString(" - name: Generate agentic run info\n") yaml.WriteString(" id: generate_aw_info\n") // Add ID for outputs @@ -398,6 +414,12 @@ func (c *Compiler) generateCreateAwInfo(yaml *strings.Builder, data *WorkflowDat agentVersion := getInstallationVersion(data, engine) fmt.Fprintf(yaml, " agent_version: \"%s\",\n", agentVersion) + // CLI version - only include for released builds + // Excludes development builds containing "dev", "dirty", or "test" + if isReleasedVersion(c.version) { + fmt.Fprintf(yaml, " cli_version: \"%s\",\n", c.version) + } + // Workflow information fmt.Fprintf(yaml, " workflow_name: \"%s\",\n", data.Name) fmt.Fprintf(yaml, " experimental: %t,\n", engine.IsExperimental())