aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2024-11-18 09:07:56 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2024-11-18 09:07:56 +0200
commite142ce121abc666dfba0dab686f54850934443a1 (patch)
tree8e382779db362499cf9ff7ecd17e832c0dde2a06
parentb03540a7dc9d47c3c6e095a5dfae848770d5feff (diff)
Sketch new handle_check_run_rerequest() logicci-github-2
-rw-r--r--mod/mod-ci-github-gq.cxx17
-rw-r--r--mod/mod-ci-github-gq.hxx18
-rw-r--r--mod/mod-ci-github.cxx49
3 files changed, 49 insertions, 35 deletions
diff --git a/mod/mod-ci-github-gq.cxx b/mod/mod-ci-github-gq.cxx
index 4d1c583..0868987 100644
--- a/mod/mod-ci-github-gq.cxx
+++ b/mod/mod-ci-github-gq.cxx
@@ -573,23 +573,6 @@ namespace brep
return r;
}
- bool
- gq_update_or_create_check_run (const basic_mark& error,
- check_run& cr,
- const string& iat,
- const string& rid,
- const optional<string>& nid,
- const string& hs,
- const optional<string>& du,
- build_state st,
- optional<gq_built_result> br)
- {
- if (nid)
- return gq_update_check_run (error, cr, iat, rid, *nid, du, st, br);
- else
- return gq_create_check_run (error, cr, iat, rid, hs, du, st, br);
- }
-
// Serialize a GraphQL query that fetches a pull request from GitHub.
//
static string
diff --git a/mod/mod-ci-github-gq.hxx b/mod/mod-ci-github-gq.hxx
index 0353281..9022fe3 100644
--- a/mod/mod-ci-github-gq.hxx
+++ b/mod/mod-ci-github-gq.hxx
@@ -92,24 +92,6 @@ namespace brep
build_state,
optional<gq_built_result> = nullopt);
- // Update a check run on GitHub if node_id is present, otherwise create a
- // new check run associated with head_sha. In the latter case, the new
- // node_id is set in the passed check_run object.
- //
- // This is a wrapper of gq_update_check_run() and gq_create_check_run() for
- // convenience.
- //
- bool
- gq_update_or_create_check_run (const basic_mark& error,
- check_run& cr,
- const string& installation_access_token,
- const string& repository_id,
- const optional<string>& node_id,
- const string& head_sha,
- const optional<string>& details_url,
- build_state,
- optional<gq_built_result> = nullopt);
-
// Fetch pre-check information for a pull request from GitHub. This
// information is used to decide whether or not to CI the PR and is
// comprised of the PR's head commit SHA, whether its head branch is behind
diff --git a/mod/mod-ci-github.cxx b/mod/mod-ci-github.cxx
index 6dfaa5f..b5935d2 100644
--- a/mod/mod-ci-github.cxx
+++ b/mod/mod-ci-github.cxx
@@ -637,6 +637,54 @@ namespace brep
static optional<build_id>
parse_details_url (const string& details_url);
+
+ bool ci_github::
+ handle_check_run_rerequest (const gh_check_run_event& cr,
+ bool warning_success)
+ {
+ // The overall plan is as follows:
+ //
+ // 1. Load service data.
+ //
+ // 2. If the tenant is archived, then fail (re-create) conclusion with
+ // appropriate diagnostics.
+ //
+ // 3. If the check run is in the queued state, then do nothing.
+ //
+ // 4. Re-create the check run in the queued state.
+ //
+ // 5. Re-create the check run in the queued state and the conclusion in
+ // the building state. Note: do in a single request to make sure we
+ // either "win" or "loose" the potential race for both (important
+ // for #8).
+ //
+ // 6. Call the rebuild() function to attempt to schedule a rebuild. Pass
+ // the update function that does the following (if called):
+ //
+ // a. Save new node ids.
+ //
+ // b. Update the check run state (may also not exist).
+ //
+ // c. Clear the completed flag if true.
+ //
+ // d. "Return" the service data to be used after the call.
+ //
+ // 7. If the result of rebuild() indicates the tenant is archived, then
+ // fail (update) the conclusion check run with appropriate diagnostics.
+ //
+ // 8. If original state is queued (no rebuild was scheduled), then fail
+ // (update) both the check run and the conclusion.
+ //
+ // Note that while conceptually we are updating existing check runs, in
+ // practice we have to re-create as new check runs in order to replace the
+ // existing ones because GitHub does not allow transitioning out of the
+ // built state.
+ //
+ }
+
+ // @@ TMP
+ //
+#if 0
bool ci_github::
handle_check_run_rerequest (const gh_check_run_event& cr,
bool warning_success)
@@ -940,6 +988,7 @@ namespace brep
return true;
}
+#endif
// Miscellaneous pull request facts
//