#!/usr/bin/env php $value) { if ($callback($value, $key)) { return true; } } return false; } } $padlen = 50; print(str_pad("\rGetting tickets from jira...", $padlen)); $tickets = explode("\n", rtrim(`jira-cli issues list -q"project IS NOT EMPTY and project != AUTO and project != NET and project != MSP and project != SYST and project != LOYAL" --order-by="Sprint" -s"Code Review" --columns=KEY --plain | grep -v '^KEY$'`)); print(str_pad("\rGetting OnBDC2 PR's from github...", $padlen)); $prs_jsons[] = json_decode(`gh pr list -L 50 -R BetterCarPeople/OnBDC2 --json 'title,url,statusCheckRollup,reviews,author,reviewDecision,reviewRequests,headRefName'`, true); print(str_pad("\rGetting maple-ai PR's from github...", $padlen)); $prs_jsons[] = json_decode(`gh pr list -R BetterCarPeople/maple-ai --json 'title,url,statusCheckRollup,reviews,author,reviewDecision,reviewRequests,headRefName'`, true); print(str_pad("\rGetting maple-web PR's from github...", $padlen)); $prs_jsons[] = json_decode(`gh pr list -R BetterCarPeople/maple-web --json 'title,url,statusCheckRollup,reviews,author,reviewDecision,reviewRequests,headRefName'`, true); print(str_pad("\r", $padlen)); print("\r"); $prs_json = array_merge(...$prs_jsons); $output = ""; $has_pr = []; foreach ($prs_json as $pr) { $pr_ticket = null; $pr_ticket = in_array($pr['headRefName'], $tickets) ? $pr['headRefName'] : null; $pr_ticket ??= (preg_match("/^[^: ]*/", $pr['title'], $matches) && in_array($matches[0], $tickets)) ? $matches[0] : null; if ($pr_ticket) { $has_pr[$pr_ticket] = true; // These are github PR's that are in code review in Jira $title = str_pad($pr['title'], 40); if (strlen($title) > 40) { $title = substr($title,0,40-3)."..."; } $author = $pr['author']['login']; // Show pipeline status if failed $failedPipes = []; foreach ($pr['statusCheckRollup'] as $scr) { if ($scr['conclusion'] === 'FAILURE') { $failedPipes[] = $scr['name']; } } $failed = $failedPipes ? (str_repeat("๐Ÿงช๐Ÿ’”", count($failedPipes)) . ": " . implode(", ", $failedPipes) . '. ') : ''; $pipeline_status = $failed; // Show approvers $review_status = ""; $changeNames = []; foreach ($pr['reviews'] as $r) { if ($r['state'] === "CHANGES_REQUESTED") { $changeNames[] = $r['author']['login']; } } $changeNames = array_unique($changeNames); $changes = $changeNames ? (str_repeat("โŒ", count($changeNames)) . ": " . implode(", ", $changeNames) . '. ') : ''; $requestNames = []; foreach ($pr['reviewRequests'] as $rr) { if ($rr['__typename'] === "Team") { $requestNames[] = $rr['name']; } else { $requestNames[] = $rr['login']; } } $requestNames = array_unique($requestNames); $reviewRequests = $requestNames ? (str_repeat("๐ŸŸก", count($requestNames)) . ": " . implode(", ", $requestNames) . '. ') : ''; $approvers = []; foreach ($pr['reviews'] as $r) { if ($r['state'] === "APPROVED") { $approvers[] = $r['author']['login']; } } $approvals = $approvers ? (str_repeat("โœ…", count($approvers)) . ": " . implode(", ", $approvers) . '. ') : ''; $commentNames = []; foreach ($pr['reviews'] as $r) { $newName = $r['author']['login']; if ($r['state'] === "COMMENTED" && $newName != $author && !array_any([...$approvers, ...$requestNames, ...$changeNames], fn($n)=>$n===$newName)) { $commentNames[] = $newName; } } $commentNames = array_unique($commentNames); $comments = $commentNames ? (str_repeat("๐Ÿ’ฌ", count($commentNames)) . ": " . implode(", ", $commentNames) . '. ') : ''; $review_status = $changes . $reviewRequests . $approvals . $comments; // Show review requested for // show other review statuses echo "$pr[url]?T=$title($author)$pipeline_status$review_status\n"; } } $has_no_pr = array_diff($tickets, array_keys($has_pr)); foreach ($has_no_pr as $ticket) { echo "https://proactivedealersolutions.atlassian.net/browse/$ticket Has no PR\n"; } exit(1);