fix(workflow): require triage's workflow when a code change is needed
This commit is contained in:
1 parent
7c7cb0cf62
commit
5b2c4f9077
2 files changed
+35
No files matched your search
@@ -30,6 +30,11 @@ steps:
|
||||
type: string
|
||||
description: The rationale, written for the human who filed the request.
|
||||
required: [needs_code_change, reasons]
|
||||
if:
|
||||
properties:
|
||||
needs_code_change: {const: true}
|
||||
then:
|
||||
required: [workflow]
|
||||
- type: forge.comment
|
||||
when: "!steps.classify.result.needs_code_change"
|
||||
settings:
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package workflow
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
)
|
||||
|
||||
// triageRegistry is the built-in step vocabulary the shipped definitions use.
|
||||
@@ -81,6 +84,33 @@ func TestTriageDoesNotRequireAWorkflowForANonCodeTask(t *testing.T) {
|
||||
if !slices.Contains(tool.RequiredFields, "needs_code_change") {
|
||||
t.Errorf("required = %v, want needs_code_change", tool.RequiredFields)
|
||||
}
|
||||
|
||||
// A code change with no workflow would hand off to nothing, so the schema
|
||||
// rejects it and the agent can correct the call.
|
||||
var schema jsonschema.Schema
|
||||
if err := json.Unmarshal(tool.Parameters, &schema); err != nil {
|
||||
t.Fatalf("decode the result schema: %v", err)
|
||||
}
|
||||
resolved, err := schema.Resolve(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("resolve the result schema: %v", err)
|
||||
}
|
||||
for _, tt := range []struct {
|
||||
result string
|
||||
valid bool
|
||||
}{
|
||||
{`{"needs_code_change": false, "reasons": "r"}`, true},
|
||||
{`{"needs_code_change": true, "workflow": "tdd", "reasons": "r"}`, true},
|
||||
{`{"needs_code_change": true, "reasons": "r"}`, false},
|
||||
} {
|
||||
var instance any
|
||||
if err := json.Unmarshal([]byte(tt.result), &instance); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := resolved.Validate(instance); (err == nil) != tt.valid {
|
||||
t.Errorf("%s: validate = %v, want valid=%v", tt.result, err, tt.valid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handoff reads steps.classify.result.workflow. On the non-code path that field
|
||||
|
||||
Reference in new issue
Block a user