Skip to content
Closed
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
104 changes: 104 additions & 0 deletions .github/workflows/smoke-pydantic.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/workflow/behavior_defined_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,14 @@ func (e *BehaviorDefinedEngine) GetInstallationSteps(workflowData *WorkflowData)
// is declared for the engine's CLI itself.
if behavior.Installation == nil {
if behavior.HarnessScript == "" {
return nil
return buildAWFInstallationSteps(workflowData)
}
return BuildNpmEngineInstallStepsWithAWF([]GitHubActionStep{GenerateNodeJsSetupStep()}, workflowData)
}

install := behavior.Installation
if install.PackageManager != "npm" {
return nil
return buildAWFInstallationSteps(workflowData)
}
version := install.Version
if workflowData != nil && workflowData.EngineConfig != nil && workflowData.EngineConfig.Version != "" {
Expand Down
93 changes: 93 additions & 0 deletions pkg/workflow/behavior_defined_engine_harness_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ import (
"github.com/stretchr/testify/require"
)

func joinInstallSteps(steps []GitHubActionStep) string {
var b strings.Builder
for _, step := range steps {
b.WriteString(strings.Join(step, "\n"))
b.WriteString("\n")
}
return b.String()
}

// newHarnessEngineDefinition returns a minimal EngineDefinition with harness-script set.
func newHarnessEngineDefinition() *EngineDefinition {
return &EngineDefinition{
Expand Down Expand Up @@ -208,6 +217,90 @@ func TestBehaviorDefinedEngineNoHarnessScript(t *testing.T) {
assert.NotContains(t, execStepContent, "GHAW_HARNESS_SCRIPT_EOF", "no harness write step should be present")
}

func TestBehaviorDefinedEngineGetInstallationSteps_AWFInstallForNonNpmPaths(t *testing.T) {
firewallWorkflowData := &WorkflowData{
Name: "test",
NetworkPermissions: &NetworkPermissions{
Allowed: []string{"defaults"},
Firewall: &FirewallConfig{Enabled: true},
},
}

t.Run("non_npm_installation_includes_awf_install_step", func(t *testing.T) {
def := &EngineDefinition{
ID: "pipengine",
DisplayName: "Pip Engine",
Behaviors: &EngineBehaviorDefinition{
Installation: &EngineInstallationDefinition{
PackageManager: "pip",
PackageName: "example",
StepName: "Install example",
},
Execution: &EngineExecutionDefinition{
CommandName: "example",
StepName: "Execute example",
},
},
}
engine, err := NewBehaviorDefinedEngine(def)
require.NoError(t, err)

steps := engine.GetInstallationSteps(firewallWorkflowData)
require.NotEmpty(t, steps)
installStepsText := joinInstallSteps(steps)
assert.Contains(t, installStepsText, "Install AWF binary")
assert.Contains(t, installStepsText, "install_awf_binary.sh")
})

t.Run("no_installation_and_no_harness_includes_awf_install_step", func(t *testing.T) {
def := &EngineDefinition{
ID: "noinstall",
DisplayName: "No Install",
Behaviors: &EngineBehaviorDefinition{
Execution: &EngineExecutionDefinition{
CommandName: "noinstall",
StepName: "Execute noinstall",
},
},
}
engine, err := NewBehaviorDefinedEngine(def)
require.NoError(t, err)

steps := engine.GetInstallationSteps(firewallWorkflowData)
require.NotEmpty(t, steps)
installStepsText := joinInstallSteps(steps)
assert.Contains(t, installStepsText, "Install AWF binary")
assert.Contains(t, installStepsText, "install_awf_binary.sh")
})

t.Run("custom_command_still_skips_installation", func(t *testing.T) {
def := &EngineDefinition{
ID: "pipenginecustom",
DisplayName: "Pip Engine Custom",
Behaviors: &EngineBehaviorDefinition{
Installation: &EngineInstallationDefinition{
PackageManager: "pip",
PackageName: "example",
StepName: "Install example",
},
Execution: &EngineExecutionDefinition{
CommandName: "example",
StepName: "Execute example",
},
},
}
engine, err := NewBehaviorDefinedEngine(def)
require.NoError(t, err)

steps := engine.GetInstallationSteps(&WorkflowData{
Name: "test",
NetworkPermissions: firewallWorkflowData.NetworkPermissions,
EngineConfig: &EngineConfig{Command: "custom"},
})
assert.Nil(t, steps)
})
}

// TestBehaviorDefinedEngineRenderMCPConfig verifies that the MCP gateway startup command
// is always emitted, even for engines that declare no behaviors.mcp.config-path (e.g.
// engines with `mcp: false`). Skipping it would leave the gateway container unstarted
Expand Down
78 changes: 44 additions & 34 deletions pkg/workflow/nodejs.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,48 @@ func buildStandardNpmEngineInstallSteps(
)
}

func buildAWFInstallationSteps(workflowData *WorkflowData) []GitHubActionStep {
if !isFirewallEnabled(workflowData) {
return nil
}

var steps []GitHubActionStep

firewallConfig := getFirewallConfig(workflowData)
agentConfig := getAgentConfig(workflowData)
var awfVersion string
if firewallConfig != nil {
awfVersion = firewallConfig.Version
}

// gVisor must be installed and registered BEFORE AWF starts the agent container.
if isGVisorRuntime(workflowData) {
steps = append(steps, generateGVisorInstallStep())
}

// docker-sbx must be installed, authenticated, and smoke-tested BEFORE AWF
// starts so the microVM runtime is ready when AWF launches the agent.
if isDockerSbxRuntime(workflowData) {
steps = append(steps, generateDockerSbxKVMCheckStep())
steps = append(steps, generateDockerSbxSecretsCheckStep())
steps = append(steps, generateDockerSbxInstallStep())
steps = append(steps, generateDockerSbxAuthAndDaemonStep())
steps = append(steps, generateDockerSbxPreFlightStep())
}

awfInstall := generateAWFInstallationStep(awfVersion, agentConfig)
if len(awfInstall) > 0 {
steps = append(steps, awfInstall)
}

// Install Docker Compose plugin for ARC/DinD runners where it may not be pre-installed.
if isArcDindTopology(workflowData) {
steps = append(steps, generateDockerComposeInstallStep())
}

return steps
}

// BuildNpmEngineInstallStepsWithAWF injects an AWF installation step between the Node.js
// setup step and the CLI install steps when the firewall is enabled. This eliminates the
// duplicated AWF-injection pattern shared by Claude, Gemini, and Copilot engines.
Expand All @@ -134,40 +176,8 @@ func BuildNpmEngineInstallStepsWithAWF(npmSteps []GitHubActionStep, workflowData
steps = append(steps, npmSteps[0]) // Node.js setup step
}

// Inject AWF installation after Node.js setup but before the CLI install steps
if isFirewallEnabled(workflowData) {
firewallConfig := getFirewallConfig(workflowData)
agentConfig := getAgentConfig(workflowData)
var awfVersion string
if firewallConfig != nil {
awfVersion = firewallConfig.Version
}

// gVisor must be installed and registered BEFORE AWF starts the agent container.
if isGVisorRuntime(workflowData) {
steps = append(steps, generateGVisorInstallStep())
}

// docker-sbx must be installed, authenticated, and smoke-tested BEFORE AWF
// starts so the microVM runtime is ready when AWF launches the agent.
if isDockerSbxRuntime(workflowData) {
steps = append(steps, generateDockerSbxKVMCheckStep())
steps = append(steps, generateDockerSbxSecretsCheckStep())
steps = append(steps, generateDockerSbxInstallStep())
steps = append(steps, generateDockerSbxAuthAndDaemonStep())
steps = append(steps, generateDockerSbxPreFlightStep())
}

awfInstall := generateAWFInstallationStep(awfVersion, agentConfig)
if len(awfInstall) > 0 {
steps = append(steps, awfInstall)
}

// Install Docker Compose plugin for ARC/DinD runners where it may not be pre-installed.
if isArcDindTopology(workflowData) {
steps = append(steps, generateDockerComposeInstallStep())
}
}
// Inject AWF installation after Node.js setup but before the CLI install steps.
steps = append(steps, buildAWFInstallationSteps(workflowData)...)

if len(npmSteps) > 1 {
steps = append(steps, npmSteps[1:]...) // CLI installation and subsequent steps
Expand Down