[auto-submit] Add raw_result

Add raw_result so changes triggered can be seen from builder page and
not just build pages in MILO. Unfortunately raw_results are not yet
included in expectation files.

Change-Id: Idfeda847a48193ccb23869339706f3ac59008c0a
Reviewed-on: https://fuchsia-review.googlesource.com/c/infra/recipes/+/445459
Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com>
Fuchsia-Auto-Submit: Rob Mohr <mohrr@google.com>
Reviewed-by: Nathan Mulcahey <nmulcahey@google.com>
diff --git a/recipes/gerrit_auto_submit.py b/recipes/gerrit_auto_submit.py
index fe2de27..093d00d 100644
--- a/recipes/gerrit_auto_submit.py
+++ b/recipes/gerrit_auto_submit.py
@@ -3,6 +3,8 @@
 # found in the LICENSE file.
 """Recipe for triggering CQ+2 on changes which meet submitability criteria and have opted in via Auto-Submit+1."""
 
+from PB.recipe_engine import result
+from PB.go.chromium.org.luci.buildbucket.proto import common
 from recipe_engine.recipe_api import Property
 
 DEPS = [
@@ -106,19 +108,38 @@
         presentation.links["change"] = _get_change_url(host, change)
 
 
+def raw_result(host, changes, dry_run):
+    if changes:
+        contents = [
+            "Submitted the following CLs{}:".format(" (dry run)" if dry_run else "")
+        ]
+        contents.extend(_get_change_url(host, change) for change in changes)
+    else:
+        contents = ["No CLs to submit."]
+
+    return result.RawResult(
+        summary_markdown="\n".join(contents), status=common.SUCCESS,
+    )
+
+
 def RunSteps(api, gerrit_host, dry_run, auto_submit_label):
     with api.step.nest("get eligible") as presentation:
         changes = get_eligible_changes(api, gerrit_host, auto_submit_label)
         if not changes:
             presentation.step_text = "\nno eligible changes."
-            return
-    with api.step.nest("set cq+2") as presentation:
-        if dry_run:
-            for change in [_get_change_url(gerrit_host, change) for change in changes]:
-                presentation.links[change] = change
-            return
-        for change in changes:
-            set_commit_queue(api, gerrit_host, change)
+
+    if changes:
+        with api.step.nest("set cq+2") as presentation:
+            if dry_run:
+                for change in [
+                    _get_change_url(gerrit_host, change) for change in changes
+                ]:
+                    presentation.links[change] = change
+            else:
+                for change in changes:
+                    set_commit_queue(api, gerrit_host, change)
+
+    return raw_result(gerrit_host, changes, dry_run)
 
 
 def GenTests(api):