#70 Support just any PR CI Pagure might throw at us
Merged 3 years ago by frantisekz. Opened 3 years ago by frantisekz.

file modified
+8 -11
@@ -424,23 +424,20 @@ 

  def get_pr_ci_result(package, pr_id):

      """

      Return CI result for package pull-request

-     Returns {"Zuul": "result", "simple-koji-ci": "result"} , "result" can be "failure", "success", "pending" or None

-     TODO: Add support for FedoraCI once pagure exposes it's result in the api

+     Returns {"ci-name": "result", "different-ci-name": "result",...} ,

+     "result" can be whatever a CI returns, there is no damned standard for it

+     "ci-name" can be anything, Zuul and simple-koji-ci will be the most common at the time of writing the code

      """

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

-     data = {"Zuul": None, "simple-koji-ci": None}

+     data = {}

      if not resp_pr_ci_result:

-         return data

+         return {}

      if "flags" not in resp_pr_ci_result:

-         return data

+         return {}

      for result in resp_pr_ci_result["flags"]:

-         if result["username"] == "Zuul" and not data["Zuul"]:

-             data["Zuul"] = result["status"]

-         if result["username"] == "simple-koji-ci" and not data["simple-koji-ci"]:

-             data["simple-koji-ci"] = result["status"]

          # We care only about the newest results

-         if data["simple-koji-ci"] and data["Zuul"]:

-             break

+         if result["username"] not in data.keys():

+             data[result["username"]] = result["status"]

      return data

  

  

rebased onto d7f5aab

3 years ago

rebased onto a255de9

3 years ago

rebased onto 9630df2

3 years ago

I know it's technically the same, but by the power of PEP20 Explicit is better than implicit. Please use data.keys()

rebased onto dbc7098

3 years ago

Pull-Request has been merged by frantisekz

3 years ago
Metadata