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
17 changes: 13 additions & 4 deletions cmd/roborev/ghaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,19 @@ After generating the workflow, add repository secrets ` +
// List required secrets per agent
infos := ghaction.AgentSecrets(cfg.Agents)
for i, info := range infos {
fmt.Printf(
" %d. Add a repository secret "+
"named %q (%s API key)\n",
i+1, info.SecretName, info.Name)
if info.Name == "opencode" {
fmt.Printf(
" %d. Add a repository secret "+
"named %q (default for "+
"opencode; change if using "+
"a different provider)\n",
i+1, info.SecretName)
} else {
fmt.Printf(
" %d. Add a repository secret "+
"named %q (%s API key)\n",
i+1, info.SecretName, info.Name)
}
fmt.Printf(
" gh secret set %s\n",
info.SecretName)
Expand Down
8 changes: 8 additions & 0 deletions internal/ghaction/ghaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ func AgentEnvVar(agentName string) string {
switch agentName {
case "claude-code":
return "ANTHROPIC_API_KEY"
case "opencode":
return "ANTHROPIC_API_KEY"
case "gemini":
return "GOOGLE_API_KEY"
case "copilot":
Expand Down Expand Up @@ -253,8 +255,14 @@ var workflowTemplate = `# roborev CI Review
#
# Required setup:
{{- range .EnvEntries }}
{{- if eq .Name "opencode" }}
# - Add a repository secret named "{{ .SecretName }}" (default for opencode).
# If you use a different model provider, replace with the appropriate key
# (e.g., OPENAI_API_KEY, GOOGLE_API_KEY) and update the env block below.
{{- else }}
# - Add a repository secret named "{{ .SecretName }}" with your {{ .Name }} API key
{{- end }}
{{- end }}
#
# Review behavior (types, reasoning, severity) is configured in
# .roborev.toml under the [ci] section.
Expand Down
40 changes: 31 additions & 9 deletions internal/ghaction/ghaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,34 @@ func TestGenerate(t *testing.T) {
"@openai/codex@latest",
},
},
{
name: "opencode uses ANTHROPIC_API_KEY",
cfg: WorkflowConfig{
Agents: []string{"opencode"},
},
wantStrs: []string{
"opencode-ai/opencode@latest",
"ANTHROPIC_API_KEY",
"different model provider",
},
envChecks: func(t *testing.T, env map[string]string) {
if _, ok := env["ANTHROPIC_API_KEY"]; !ok {
t.Error("expected ANTHROPIC_API_KEY in env")
}
},
},
{
name: "dedupes env vars",
cfg: WorkflowConfig{
Agents: []string{"codex", "opencode"},
Agents: []string{"claude-code", "opencode"},
},
wantStrs: []string{
"@openai/codex@latest",
"@anthropic-ai/claude-code@latest",
"opencode-ai/opencode@latest",
},
envChecks: func(t *testing.T, env map[string]string) {
if _, ok := env["OPENAI_API_KEY"]; !ok {
t.Error("expected OPENAI_API_KEY in env")
if _, ok := env["ANTHROPIC_API_KEY"]; !ok {
t.Error("expected ANTHROPIC_API_KEY in env")
}
},
},
Expand Down Expand Up @@ -262,12 +278,12 @@ func TestGenerate(t *testing.T) {
lines := strings.Split(out, "\n")
envDefCount := 0
for _, line := range lines {
if strings.HasPrefix(strings.TrimSpace(line), "OPENAI_API_KEY:") {
if strings.HasPrefix(strings.TrimSpace(line), "ANTHROPIC_API_KEY:") {
envDefCount++
}
}
if envDefCount != 1 {
t.Errorf("expected 1 OPENAI_API_KEY: definition, got %d", envDefCount)
t.Errorf("expected 1 ANTHROPIC_API_KEY: definition, got %d", envDefCount)
}
}
}
Expand Down Expand Up @@ -453,7 +469,7 @@ func TestAgentEnvVar(t *testing.T) {
{"claude-code", "ANTHROPIC_API_KEY"},
{"gemini", "GOOGLE_API_KEY"},
{"copilot", "GITHUB_TOKEN"},
{"opencode", "OPENAI_API_KEY"},
{"opencode", "ANTHROPIC_API_KEY"},
{"droid", "OPENAI_API_KEY"},
}
for _, tt := range tests {
Expand Down Expand Up @@ -482,10 +498,16 @@ func TestAgentSecrets(t *testing.T) {
wantVars: []string{"OPENAI_API_KEY"},
},
{
name: "dedupes by env var",
name: "codex and opencode have separate keys",
agents: []string{"codex", "opencode"},
wantLen: 2,
wantVars: []string{"OPENAI_API_KEY", "ANTHROPIC_API_KEY"},
},
{
name: "dedupes by env var",
agents: []string{"claude-code", "opencode"},
wantLen: 1,
wantVars: []string{"OPENAI_API_KEY"},
wantVars: []string{"ANTHROPIC_API_KEY"},
},
{
name: "multi env var",
Expand Down
Loading