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
5 changes: 5 additions & 0 deletions .github/workflows/reusable-dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ jobs:
STAGE="review"
fi
;;
labeled)
if [[ "${TRIGGERING_LABEL}" == "ready-for-review" ]]; then
STAGE="review"
fi
;;
closed)
STAGE="retro"
;;
Expand Down
16 changes: 16 additions & 0 deletions internal/harnessdispatch/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,22 @@ func TestIsAuthorized_LabelRemovedRequiresWriteRole(t *testing.T) {
assert.False(t, IsAuthorized(ev))
}

func TestIsAuthorized_BotOpenedPRFallsThrough(t *testing.T) {
// Bot-opened PR events have no special bypass in the pre-CEL gate.
// Trusted-bot handling lives in bash dispatch (is_trusted_bot) and
// CEL trigger expressions, not here.
ev := &normevent.Event{
Transition: normevent.Transition{Kind: normevent.TransitionOpened},
Source: normevent.Source{System: normevent.SystemGitHub},
Actor: normevent.Actor{
ID: "myapp-coder[bot]",
Kind: normevent.ActorBot,
Role: normevent.RoleNone,
},
}
assert.False(t, IsAuthorized(ev))
}

func TestIsAuthorized_OpenedRequiresWriteRole(t *testing.T) {
ev := &normevent.Event{
Transition: normevent.Transition{Kind: normevent.TransitionOpened},
Expand Down
35 changes: 35 additions & 0 deletions internal/harnessdispatch/input/ghaevent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,41 @@ func TestLoadGHAEvent_PROpened(t *testing.T) {
assert.NotNil(t, ev.State.ChangeProposal)
}

func TestLoadGHAEvent_PROpenedByBot(t *testing.T) {
raw := map[string]any{
"action": "opened",
"pull_request": map[string]any{
"number": float64(101),
"html_url": "https://github.com/o/r/pull/101",
"user": map[string]any{"login": "myapp-coder[bot]"},
"labels": []any{},
"head": map[string]any{
"ref": "agent/fix-thing",
"sha": "cccccccccccccccccccccccccccccccccccccccc",
"repo": map[string]any{"full_name": "o/r"},
},
"base": map[string]any{
"ref": "main",
"repo": map[string]any{"full_name": "o/r"},
},
},
"sender": map[string]any{"login": "myapp-coder[bot]", "type": "Bot"},
}
path := writeEventFile(t, raw)

client := forge.NewFakeClient()

ev, err := input.LoadGHAEvent(context.Background(), input.GHAEventOptions{
EventPath: path,
EventName: "pull_request_target",
Repository: "o/r",
Forge: client,
})
require.NoError(t, err)
assert.Equal(t, normevent.ActorBot, ev.Actor.Kind)
assert.Equal(t, normevent.RoleNone, ev.Actor.Role)
}

func TestLoadGHAEvent_PRLabeled(t *testing.T) {
raw := map[string]any{
"action": "labeled",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ jobs:
STAGE="review"
fi
;;
labeled)
if [[ "${TRIGGERING_LABEL}" == "ready-for-review" ]]; then
STAGE="review"
fi
;;
closed)
STAGE="retro"
;;
Expand Down
Loading