← Back to team overview

canonical-ubuntu-qa team mailing list archive

[Merge] ~hyask/autopkgtest-cloud:skia/github_context_improved into autopkgtest-cloud:master

 

Skia has proposed merging ~hyask/autopkgtest-cloud:skia/github_context_improved into autopkgtest-cloud:master.

Requested reviews:
  Canonical's Ubuntu QA (canonical-ubuntu-qa)

For more details, see:
https://code.launchpad.net/~hyask/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/473208

Improve the answer to Github, for better integration, especially when `testname` is provided.

Example: https://github.com/Hyask/curtin/pull/1
-- 
Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~hyask/autopkgtest-cloud:skia/github_context_improved into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-web/webcontrol/request/app.py b/charms/focal/autopkgtest-web/webcontrol/request/app.py
index 1f33218..caa7e4c 100644
--- a/charms/focal/autopkgtest-web/webcontrol/request/app.py
+++ b/charms/focal/autopkgtest-web/webcontrol/request/app.py
@@ -1,4 +1,5 @@
 """Test Request Flask App"""
+
 import hmac
 import json
 import logging
@@ -246,10 +247,19 @@ def index_root():
         ) as f:
             f.write(json.dumps(params))
 
+        if "testname" in params:
+            context = "%s/%s %s" % (
+                params["release"],
+                params["arch"],
+                params["testname"],
+            )
+        else:
+            context = "%s/%s" % (params["release"], params["arch"])
+
         # tell GitHub that the test is pending
         status = {
             "state": "pending",
-            "context": "%s-%s" % (params["release"], params["arch"]),
+            "context": context,
             "description": "autopkgtest running",
             "target_url": os.path.join(
                 request.host_url, "running#pkg-" + params["package"]
diff --git a/charms/focal/autopkgtest-web/webcontrol/update-github-jobs b/charms/focal/autopkgtest-web/webcontrol/update-github-jobs
index 55d14a0..b3f50e0 100755
--- a/charms/focal/autopkgtest-web/webcontrol/update-github-jobs
+++ b/charms/focal/autopkgtest-web/webcontrol/update-github-jobs
@@ -84,9 +84,18 @@ def finish_job(jobfile: Path, params, code, log_url):
     else:
         state = "error"
 
+    if "testname" in params:
+        context = "%s/%s %s" % (
+            params["release"],
+            params["arch"],
+            params["testname"],
+        )
+    else:
+        context = "%s/%s" % (params["release"], params["arch"])
+
     data = {
         "state": state,
-        "context": "%s-%s" % (params["release"], params["arch"]),
+        "context": context,
         "description": "autopkgtest finished (%s)" % state,
         "target_url": log_url,
     }

Follow ups