-
Notifications
You must be signed in to change notification settings - Fork 36
feat(review-agent): add outcome labels to post-review.sh #874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
internal/scaffold/fullsend-repo/scripts/post-review-test.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| #!/usr/bin/env bash | ||
| # post-review-test.sh — Test the outcome-label logic in post-review.sh. | ||
| # | ||
| # Extracts and tests the label-application logic in isolation using shell | ||
| # functions. This avoids needing a live GitHub API or fullsend CLI. | ||
| # | ||
| # Run from the repo root: | ||
| # bash internal/scaffold/fullsend-repo/scripts/post-review-test.sh | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| FAILURES=0 | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Test helper — reimplements the outcome-label logic from post-review.sh | ||
| # so we can test it without network access. | ||
| # | ||
| # Arguments: | ||
| # $1 — ACTION (the original action from agent-result.json) | ||
| # $2 — DOWNGRADED ("true" or "false") | ||
| # | ||
| # Prints the label that would be applied, or "none" if no label. | ||
| # --------------------------------------------------------------------------- | ||
| determine_outcome_label() { | ||
| local action="$1" | ||
| local downgraded="$2" | ||
|
|
||
| if [ "${action}" = "approve" ] && [ "${downgraded}" = "false" ]; then | ||
| echo "ready-for-merge" | ||
| elif [ "${action}" = "approve" ] && [ "${downgraded}" = "true" ]; then | ||
| echo "requires-manual-review" | ||
| elif [ "${action}" = "comment" ]; then | ||
| echo "requires-manual-review" | ||
| elif [ "${action}" = "request_changes" ]; then | ||
| echo "none" | ||
| elif [ "${action}" = "reject" ]; then | ||
| echo "rejected" | ||
| else | ||
| echo "none" | ||
| fi | ||
| } | ||
|
|
||
| run_test() { | ||
| local test_name="$1" | ||
| local action="$2" | ||
| local downgraded="$3" | ||
| local expected="$4" | ||
|
|
||
| local actual | ||
| actual="$(determine_outcome_label "${action}" "${downgraded}")" | ||
|
|
||
| if [ "${actual}" != "${expected}" ]; then | ||
| echo "FAIL: ${test_name}" | ||
| echo " action: '${action}'" | ||
| echo " downgraded: '${downgraded}'" | ||
| echo " expected: '${expected}'" | ||
| echo " actual: '${actual}'" | ||
| FAILURES=$((FAILURES + 1)) | ||
| return | ||
| fi | ||
|
|
||
| echo "PASS: ${test_name}" | ||
| } | ||
|
|
||
| # --- Test cases --- | ||
|
|
||
| # Approve without protected-path downgrade → ready-for-merge | ||
| run_test "approve-no-downgrade" \ | ||
| "approve" "false" "ready-for-merge" | ||
|
|
||
| # Approve with protected-path downgrade → requires-manual-review | ||
| run_test "approve-with-downgrade" \ | ||
| "approve" "true" "requires-manual-review" | ||
|
|
||
| # Comment (split/conflicting review) → requires-manual-review | ||
| run_test "comment-split-review" \ | ||
| "comment" "false" "requires-manual-review" | ||
|
|
||
| # request_changes → no outcome label | ||
| run_test "request-changes-no-label" \ | ||
| "request_changes" "false" "none" | ||
|
|
||
| # reject → rejected | ||
| run_test "reject-label" \ | ||
| "reject" "false" "rejected" | ||
|
|
||
| # Defensive: comment + downgraded=true can't occur in production (DOWNGRADED is | ||
| # only set inside the approve branch), but verify the label logic handles it. | ||
| run_test "comment-with-downgrade-flag" \ | ||
| "comment" "true" "requires-manual-review" | ||
|
|
||
| # Edge cases: ensure unknown/empty actions produce no label | ||
| run_test "empty-action-no-label" \ | ||
| "" "false" "none" | ||
|
|
||
| run_test "failure-action-no-label" \ | ||
| "failure" "false" "none" | ||
|
|
||
| run_test "unknown-action-no-label" \ | ||
| "banana" "false" "none" | ||
|
|
||
| # --- Summary --- | ||
|
|
||
| echo "" | ||
| if [ "${FAILURES}" -gt 0 ]; then | ||
| echo "${FAILURES} test(s) failed" | ||
| exit 1 | ||
| fi | ||
| echo "All tests passed" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.