#27 Add support for PR CI status
Merged 3 years ago by frantisekz. Opened 3 years ago by frantisekz.

file modified
+15 -1
@@ -267,6 +267,20 @@ 

  

      return data

  

+ def get_pr_ci_result(package, pr_id):

+     """

+     Return CI result for package pull-request

+     Returns "failure" or "success" or None

+     TODO: Add support for FedoraCI, add support for results other than "failure" and "success"

+     """

+     resp_pr_ci_result = get_json("https://src.fedoraproject.org/api/0/rpms/%s/pull-request/%s/flag" % (package, pr_id))

+     if not resp_pr_ci_result:

+         return None

+     # Pagure returns PR results sorted from newest to latest, so we can pick just the first result

+     if resp_pr_ci_result["flags"][0]["status"] not in ("failure", "success"):

+         return None

+     return resp_pr_ci_result["flags"][0]["status"]

+ 

  

  def get_package_prs(package):

      """
@@ -287,7 +301,7 @@ 

                  "comments": len(request["comments"]),

                  "date_created": str(datetime.datetime.fromtimestamp(int(request["date_created"]))),

                  "last_updated": str(datetime.datetime.fromtimestamp(int(request["last_updated"]))),

-                 "ci_status": None,  # Awaiting pagure api integration

+                 "ci_status": get_pr_ci_result(package, request["id"]),

                  "url": "https://src.fedoraproject.org/rpms/%s/pull-request/%s" % (package, request["id"])

              })

      return data

no initial comment

how about if resp_pr_ci_result["flags"][0]["status"] not in ("failure", "success"): ?

on top of that, maybe add a comment explaining what is the other kind of states we can encounter, and why are we ignoring them. THX

other than these nitpicks LGTM

rebased onto d2fa4b6

3 years ago

Pull-Request has been merged by frantisekz

3 years ago
Metadata