MCPcopy Create free account
hub / github.com/github/gh-aw / generatePlaywrightCLIInstallSteps

Function generatePlaywrightCLIInstallSteps

pkg/workflow/playwright_cli.go:53–107  ·  view source on GitHub ↗

generatePlaywrightCLIInstallSteps returns npm install steps for @playwright/cli when playwright is configured in CLI mode. Returns nil if playwright is in MCP mode. Node.js setup is intentionally omitted here because all supported engines (copilot, claude, codex, gemini) include a Node.js setup ste

(workflowData *WorkflowData)

Source from the content-addressed store, hash-verified

51// (copilot, claude, codex, gemini) include a Node.js setup step in their own
52// installation steps, which run before this function is called.
53func generatePlaywrightCLIInstallSteps(workflowData *WorkflowData) []GitHubActionStep {
54 if !isPlaywrightCLIMode(workflowData.Tools) {
55 return nil
56 }
57
58 playwrightCLILog.Print("Generating @playwright/cli install steps (CLI mode)")
59
60 version := string(constants.DefaultPlaywrightCLIVersion)
61 // Use version override from playwright config if provided
62 if playwrightTool, ok := workflowData.Tools["playwright"]; ok {
63 config := parsePlaywrightTool(playwrightTool)
64 if config != nil && config.Version != "" {
65 version = config.Version
66 playwrightCLILog.Printf("Using playwright CLI version from config: %s", version)
67 }
68 }
69
70 // Install @playwright/cli globally.
71 // Node.js setup is needed only when a custom engine.command is specified because
72 // in that case the engine's own install steps (which normally set up Node) are skipped.
73 // When EngineConfig is nil or Command is empty (standard engine configuration), Node.js
74 // is already set up by the engine install steps that run before this function is called.
75 needsNodeSetup := workflowData.EngineConfig != nil && workflowData.EngineConfig.Command != ""
76 steps := GenerateNpmInstallStepsWithScope(
77 "@playwright/cli",
78 version,
79 "Install Playwright CLI",
80 "playwright-cli",
81 needsNodeSetup, // true only when engine.command skips standard engine install steps
82 true, // Global install so playwright-cli is on PATH
83 true, // Allow install scripts for browser setup
84 resolveRuntimeCooldown(workflowData, "node"),
85 )
86 for i := range steps {
87 if len(steps[i]) > 0 && steps[i][0] == " - name: Install Playwright CLI" {
88 steps[i] = append(steps[i], " timeout-minutes: 10")
89 break
90 }
91 }
92
93 // Install playwright-cli skills so the coding agent can discover available commands.
94 // PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD keeps this step focused on skills installation;
95 // browser binaries can still be installed lazily when the agent runs browser commands.
96 installSkillsStep := GitHubActionStep{
97 " - name: Install Playwright CLI skills",
98 " run: playwright-cli install --skills",
99 " env:",
100 " PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'",
101 " timeout-minutes: 10",
102 }
103 steps = append(steps, installSkillsStep)
104
105 playwrightCLILog.Printf("Generated %d Playwright CLI install steps", len(steps))
106 return steps
107}

Calls 6

isPlaywrightCLIModeFunction · 0.85
parsePlaywrightToolFunction · 0.85
resolveRuntimeCooldownFunction · 0.85
PrintMethod · 0.80
PrintfMethod · 0.45