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
67 changes: 66 additions & 1 deletion .github/workflows/opencode-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,66 @@ jobs:
run: |
set -euo pipefail

current_peer_checks_still_running() {
local owner="${GH_REPOSITORY%%/*}"
local name="${GH_REPOSITORY#*/}"

# Exclude this OpenCode check run; otherwise the evidence step would
# wait on itself until the bounded retry budget is exhausted.
# shellcheck disable=SC2016
gh api graphql \
-f owner="$owner" \
-f name="$name" \
-F number="$PR_NUMBER" \
-f query='
query($owner:String!,$name:String!,$number:Int!) {
repository(owner:$owner,name:$name) {
pullRequest(number:$number) {
statusCheckRollup {
contexts(first: 100) {
nodes {
__typename
... on CheckRun {
name
status
checkSuite {
workflowRun {
workflow {
name
}
}
}
}
... on StatusContext {
context
state
}
}
}
}
}
}
}
' \
--jq '
[
(.data.repository.pullRequest.statusCheckRollup.contexts.nodes // [])
| .[]
| if .__typename == "CheckRun" then
select((.name // "") != "opencode-review")
| select((.checkSuite.workflowRun.workflow.name // "") != "OpenCode PR Review")
| select((.status // "") != "COMPLETED")
elif .__typename == "StatusContext" then
select((.context // "") != "opencode-review")
| select((.state // "" | ascii_upcase) as $s | ["PENDING","EXPECTED"] | index($s))
else
empty
end
]
| length > 0
'
}

collect_failed_check_evidence_with_wait() {
local evidence_file="$1"
local attempts="${FAILED_CHECK_EVIDENCE_ATTEMPTS:-19}"
Expand All @@ -100,7 +160,12 @@ jobs:

while [ "$attempt" -le "$attempts" ]; do
if scripts/ci/collect_failed_check_evidence.sh "$evidence_file"; then
return 0
if ! grep -Fq "No completed failed GitHub Checks were present" "$evidence_file"; then
return 0
fi
if [ "$(current_peer_checks_still_running 2>/dev/null || printf 'false')" != "true" ]; then
return 0
fi
fi

if [ "$attempt" -lt "$attempts" ]; then
Expand Down
13 changes: 11 additions & 2 deletions services/analysis-engine/tests/test_supply_chain_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4894,7 +4894,7 @@ def test_supply_chain_check_accepts_repo_workspace_exec_policy(


def test_opencode_review_gate_ignores_review_agent_status_contexts() -> None:
"""Ensure OpenCode approval does not wait on other review-agent statuses."""
"""Ensure OpenCode ignores review agents while waiting on regular peer checks."""
repo_root = Path(__file__).resolve().parents[3]
workflow = (repo_root / ".github" / "workflows" / "opencode-review.yml").read_text(
encoding="utf-8"
Expand All @@ -4903,7 +4903,16 @@ def test_opencode_review_gate_ignores_review_agent_status_contexts() -> None:
assert "def opencode_review_agent_status:" in workflow
assert '$context == "coderabbit"' in workflow
assert '$context == "copilot pull request reviewer"' in workflow
assert "current_peer_checks_still_running" not in workflow
assert "current_peer_checks_still_running" in workflow
assert 'select((.name // "") != "opencode-review")' in workflow
assert (
'select((.checkSuite.workflowRun.workflow.name // "") != "OpenCode PR Review")' in workflow
)
assert (
'select((.state // "" | ascii_upcase) as $s | ["PENDING","EXPECTED"] | index($s))'
in workflow
)
assert "No completed failed GitHub Checks were present" in workflow
assert workflow.count("select(opencode_review_agent_status | not)") >= 2


Expand Down
Loading