summary refs log tree commit diff
diff options
context:
space:
mode:
authorZach DeCook <zach.decook@bettercarpeople.com>2026-03-25 09:30:02 -0400
committerZach DeCook <zach.decook@bettercarpeople.com>2026-03-25 09:30:02 -0400
commit8bb67873e50931e347e58a95bfb822ea4e3572a6 (patch)
treed88646ecf1fe8101534edc6e8c07563bcf75f3ab
parent2e51849aeba91ea3ce29005dde28f1d163f31e90 (diff)
downloaddotfiles-bcp.tar.gz
jira-CR.php: Show failed tests and tickets without PR's bcp
-rwxr-xr-x.local/bin/jira-CR.php45
-rwxr-xr-x.local/bin/jira-codereview4
2 files changed, 42 insertions, 7 deletions
diff --git a/.local/bin/jira-CR.php b/.local/bin/jira-CR.php
index e87d265..a8955f7 100755
--- a/.local/bin/jira-CR.php
+++ b/.local/bin/jira-CR.php
@@ -1,11 +1,24 @@
 #!/usr/bin/env php
 <?php
+
+// shim before php 8.4
+if (!function_exists('array_any')) {
+    function array_any(array $array, callable $callback): bool {
+        foreach ($array as $key => $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 -R BetterCarPeople/OnBDC2 --json 'title,url,statusCheckRollup,reviews,author,reviewDecision,reviewRequests,headRefName'`, true);
+$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));
@@ -16,18 +29,31 @@ 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'], 38);
-        if (strlen($title) > 38) {
-            $title = substr($title,0,35)."...";
+        $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 = "";
 
@@ -37,6 +63,7 @@ foreach ($prs_json as $pr) {
                 $changeNames[] = $r['author']['login'];
             }
         }
+        $changeNames = array_unique($changeNames);
         $changes = $changeNames ? (str_repeat("โŒ", count($changeNames)) . ": " . implode(", ", $changeNames) . '. ') : '';
 
         $requestNames = [];
@@ -47,6 +74,7 @@ foreach ($prs_json as $pr) {
                 $requestNames[] = $rr['login'];
             }
         }
+        $requestNames = array_unique($requestNames);
         $reviewRequests = $requestNames ? (str_repeat("๐ŸŸก", count($requestNames)) . ": " . implode(", ", $requestNames) . '. ') : '';
 
         $approvers = [];
@@ -60,7 +88,7 @@ foreach ($prs_json as $pr) {
         $commentNames = [];
         foreach ($pr['reviews'] as $r) {
             $newName = $r['author']['login'];
-            if ($r['state'] === "COMMENTED" && !in_array($newName, $approvers) && !in_array($newName, $requestNames) && $newName != $author) {
+            if ($r['state'] === "COMMENTED" && $newName != $author && !array_any([...$approvers, ...$requestNames, ...$changeNames], fn($n)=>$n===$newName)) {
                 $commentNames[] = $newName;
             }
         }
@@ -71,9 +99,14 @@ foreach ($prs_json as $pr) {
         // Show review requested for
         // show other review statuses
         
-        echo "$pr[url]?T=$title($author)\t$review_status\n";
+        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);
 
 
diff --git a/.local/bin/jira-codereview b/.local/bin/jira-codereview
index 9fbdfc3..3b10c10 100755
--- a/.local/bin/jira-codereview
+++ b/.local/bin/jira-codereview
@@ -9,7 +9,9 @@ if test "$ticket"; then
     echo "Reviewing $ticket ..."
     # ugh
     #xdg-open https://proactivedealersolutions.atlassian.net/browse/$ticket
-    xdg-open "https://github.com/pulls?q=is%3Aopen+is%3Apr+user%3ABetterCarPeople+$ticket"
+    if ! test "$2" = "noopen"; then
+        xdg-open "https://github.com/pulls?q=is%3Aopen+is%3Apr+user%3ABetterCarPeople+$ticket"
+    fi
     #xdg-open "https://github.com/search?q=is%3Aopen+is%3Apr+org%3ABetterCarPeople+$ticket"
 else
     exit 1;