Skip to content

Commit caf93c9

Browse files
committed
Better webhook handling, new URL generation.
1. Usually we have enough information in the webhook payload, so we can avoid a lot of API calls (which are counted and limited). In some cases we can't or they seem to arrive out of order (by a primitive status ordering rule), so we fall back to polling in that case. Time will tell how well this works in practice... The code for both cases is unified. 2. There are now also URL properties for builds and tasks, which will be pushed to the CF app so that it can create clickable links. They aren't directly taken from the Github API's html_url fields, because I wanted to include the run_attempt explicitly in the build URL. The links it makes for builds always take you to the latest run attempt, which might be confusing in some rare cases...
1 parent 26637e7 commit caf93c9

3 files changed

Lines changed: 178 additions & 211 deletions

File tree

cfbot_commitfest.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,22 +177,32 @@ def make_branch_status_message(conn, branch_id=None, build_id=None, commit_id=No
177177
def make_task_status_message(conn, task_id):
178178
cursor = conn.cursor()
179179
cursor.execute(
180-
"""SELECT build_id, build.commit_id, task.task_name, task.position, task.status, task.created, task.modified
180+
"""SELECT build_id, build.commit_id, task.task_name, task.position, task.status, task.html_url, build.html_url, task.created, task.modified
181181
FROM task
182182
JOIN build USING (build_id)
183183
WHERE task.task_id = %s""",
184184
(task_id,),
185185
)
186-
build_id, commit_id, task_name, position, status, created, modified = (
187-
cursor.fetchone()
188-
)
186+
(
187+
build_id,
188+
commit_id,
189+
task_name,
190+
position,
191+
status,
192+
task_url,
193+
build_url,
194+
created,
195+
modified,
196+
) = cursor.fetchone()
189197
message = {
190198
"build_id": build_id,
191199
"task_id": task_id,
192200
"commit_id": commit_id,
193201
"task_name": task_name,
194202
"position": position,
195203
"status": status,
204+
"task_url": task_url,
205+
"build_url": build_url,
196206
"created": created.isoformat(),
197207
"modified": modified.isoformat(),
198208
}

0 commit comments

Comments
 (0)