diff options
author | Francois Kritzinger <francois@codesynthesis.com> | 2024-11-07 13:35:53 +0200 |
---|---|---|
committer | Francois Kritzinger <francois@codesynthesis.com> | 2024-11-12 17:23:52 +0200 |
commit | a048473adae8fc9a803ccb3814d01199e626cbbf (patch) | |
tree | 326a95c0bdb75ad9d5bf50f30fa262633f6cf485 | |
parent | e46f4790386fa0b9b089ae5113aaf1546f560792 (diff) |
Verify check suite completeness in build_built() service data lambda
-rw-r--r-- | mod/mod-ci-github.cxx | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/mod/mod-ci-github.cxx b/mod/mod-ci-github.cxx index 7683a23..377db83 100644 --- a/mod/mod-ci-github.cxx +++ b/mod/mod-ci-github.cxx @@ -1917,6 +1917,8 @@ namespace brep // Only update the check_run state in service data if it matches the // state (specifically, status) on GitHub. // + // @@ TMP Shouldn't we update service data either way? + // if (cr.state_synced) { if (check_run* scr = sd.find_check_run (cr.build_id)) @@ -1937,19 +1939,38 @@ namespace brep } else sd.check_runs.push_back (cr); - } - if (completed) - { - // Note that this can be racy: while we calculated the completed value - // based on the snapshot of the service data, it could have been - // changed (e.g., by handle_check_run_request()). So we Re-calculate - // it based on the check run states and only update if matches. - // Otherwise, we log an error. - // - // @@@ TODO + if (completed) + { + // Note that this can be racy: while we calculated the completed + // value based on the snapshot of the service data, it could have + // been changed (e.g., by handle_check_run_rerequest()). So we + // Re-calculate it based on the check run states and only update if + // matches. Otherwise, we log an error. + // + bool u (true); // True if completeness should be updated. - sd.completed = true; + for (const check_run& scr: sd.check_runs) + { + // Note: the CR has already been saved to the service data as + // built. + // + if (scr.state != build_state::built) + { + string sid (sd.repository_node_id + ':' + sd.report_sha); + + error << "tenant_service id " << sid + << ": out of order built notification service data update; " + << "check suite is no longer complete"; + + u = false; + break; + } + } + + if (u) + sd.completed = true; + } } return sd.json (); |