Skip to content

Commit fae7528

Browse files
committed
Add support for Github Action CI.
For now only the build (= GH run) and task (= GH job) data is maintained. The task_command (= GH step) data is not synchronised yet, and no logs are pulled down and analysed -- hopefully that can be added later. This is just enough to feed checkmarks to the Commitfest app. The Cirrus endpoint is disabled.
1 parent 539b952 commit fae7528

7 files changed

Lines changed: 894 additions & 33 deletions

cfbot_api.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import cfbot_cirrus
1+
import cfbot_github
22
import cfbot_config
33
import cfbot_util
44
import logging
@@ -28,25 +28,22 @@ def error_cleanup():
2828
app = Flask("cfbot_api")
2929

3030

31-
# This URL is registered with with cirrus so it calls us any time a build
32-
# begins or a status changes:
33-
#
34-
# https://cirrus-ci.org/api/#builds-and-tasks-webhooks
35-
#
36-
# We extract commit_id:task_id and create a work_queue entry for later
37-
# processing.
38-
#
39-
# XXX Should we process the status change immediately in this transaction?
40-
#
41-
@app.route("/api/cirrus-webhook", methods=["POST"])
42-
def cirrus_webhook():
31+
# This URL is registered with Github to receive workflow_job events,
32+
# from both postgresql-cfbot/postgres (for cf/* branches) and
33+
# postgres/postgres (for master, REL_* branches).
34+
@app.route("/api/github-webhook", methods=["POST"])
35+
def github_webhook():
4336
try:
44-
event_type = request.headers.get("X-Cirrus-Event")
37+
event_type = request.headers.get("X-Github-Event")
4538
event = request.json
46-
# logging.info("Cirrus webhook: type = %s, payload = %s", event_type, event)
47-
if event_type and "build" in event and "id" in event["build"]:
48-
cursor = conn.cursor()
49-
cfbot_cirrus.ingest_webhook(conn, event_type, event)
39+
logging.info("Github webhook: type = %s, payload = %s", event_type, event)
40+
if event_type == "workflow_job":
41+
cfbot_github.ingest_workflow_job(conn, event)
42+
conn.commit()
43+
return "OK"
44+
elif event_type == "workflow_run":
45+
# XXX Not used yet...
46+
cfbot_github.ingest_workflow_run(conn, event)
5047
conn.commit()
5148
return "OK"
5249
else:
@@ -142,3 +139,8 @@ def rerun_patch():
142139
conn.commit()
143140

144141
return jsonify({"status": "success"})
142+
143+
144+
# Easy way to run this locally for development.
145+
if __name__ == "__main__":
146+
app.run(debug=True)

cfbot_commitfest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
import logging
1313

1414

15+
# These tasks (jobs) are not interesting to cf app users.
16+
IGNORE_TASK_NAMES = ("Cancel previous runs", "Determine enabled OSes")
17+
18+
1519
def pull_submissions(conn, commitfest_id):
1620
"""Fetch the list of submissions and make sure we have a row for each one.
1721
Update the last email time according to the Commitfest main page,
@@ -198,6 +202,9 @@ def make_task_status_message(conn, task_id):
198202
def make_task_update_message(conn, task_id):
199203
task_status = make_task_status_message(conn, task_id)
200204

205+
if task_status["task_name"] in IGNORE_TASK_NAMES:
206+
return None
207+
201208
branch_status = make_branch_status_message(conn, build_id=task_status["build_id"])
202209
if not branch_status:
203210
logging.info(

0 commit comments

Comments
 (0)