aboutsummaryrefslogtreecommitdiff
path: root/mod/mod-ci-github.cxx
diff options
context:
space:
mode:
authorFrancois Kritzinger <francois@codesynthesis.com>2024-11-14 10:47:14 +0200
committerFrancois Kritzinger <francois@codesynthesis.com>2024-11-14 13:18:45 +0200
commit7d05ad1895fffb936f182177facc9e5497e45f01 (patch)
tree8afef6ed40deb57b93e7cd2771f159752299440c /mod/mod-ci-github.cxx
parentc5c2f6dd99e575b1521bd158bc4cffad50279c72 (diff)
Use function gq_update_or_create_check_run()
Diffstat (limited to 'mod/mod-ci-github.cxx')
-rw-r--r--mod/mod-ci-github.cxx122
1 files changed, 46 insertions, 76 deletions
diff --git a/mod/mod-ci-github.cxx b/mod/mod-ci-github.cxx
index 95bfe99..0d0940a 100644
--- a/mod/mod-ci-github.cxx
+++ b/mod/mod-ci-github.cxx
@@ -1793,48 +1793,33 @@ namespace brep
//
if (iat != nullptr)
{
- // Update the check run if we have a node id, otherwise create a new
- // one.
+ // Update the check run if we have a node id, otherwise create a new one
+ // (as requested by handle_check_run_rerequest(); see above).
//
- if (cr->node_id)
- {
- if (gq_update_check_run (error,
- *cr,
- iat->token,
- sd.repository_node_id,
- *cr->node_id,
- details_url (b),
- build_state::building))
- {
- // Do nothing further if the state was already built on GitHub (note
- // that this is based on the above-mentioned special GitHub
- // semantics of preventing changes to the built status).
- //
- if (cr->state == build_state::built)
- {
- warn << "check run " << bid << ": already in built state on GitHub";
- return nullptr;
- }
-
- assert (cr->state == build_state::building);
- l3 ([&]{trace << "updated check_run { " << *cr << " }";});
- }
- }
- else
- {
- // Create a new check run as requested by build_building() (see above).
+ bool updated (cr->node_id.has_value ());
+
+ if (gq_update_or_create_check_run (error,
+ *cr,
+ iat->token,
+ sd.repository_node_id,
+ cr->node_id,
+ sd.report_sha,
+ details_url (b),
+ build_state::building))
+ {
+ // Do nothing further if the state was already built on GitHub (note
+ // that this is based on the above-mentioned special GitHub
+ // semantics of preventing changes to the built status).
//
- if (gq_create_check_run (error,
- *cr,
- iat->token,
- sd.repository_node_id,
- sd.report_sha,
- details_url (b),
- build_state::building))
+ if (updated && cr->state == build_state::built)
{
- assert (cr->state == build_state::building);
- l3 ([&]{trace << "created check_run { " << *cr << " }";});
+ warn << "check run " << bid << ": already in built state on GitHub";
+ return nullptr;
}
+
+ assert (cr->state == build_state::building);
+ l3 ([&]{trace << (updated ? "updated" : "created")
+ << " check_run { " << *cr << " }";});
}
}
@@ -2105,45 +2090,30 @@ namespace brep
circle (*b.status) + ' ' + ucase (to_string (*b.status)),
move (sm));
- if (cr.node_id)
- {
- // Update existing check run to built.
- //
- if (gq_update_check_run (error,
- cr,
- iat->token,
- sd.repository_node_id,
- *cr.node_id,
- details_url (b),
- build_state::built,
- move (br)))
- {
- assert (cr.state == build_state::built);
- l3 ([&]{trace << "updated check_run { " << cr << " }";});
- }
- }
- else
+ // Update existing or create new check run if cr.node_id is absent.
+ //
+ // Note that we don't have build hints so will be creating this check
+ // run with the full build id as name. In the unlikely event that an out
+ // of order build_queued() were to run before we've saved this check run
+ // to the service data it will create another check run with the
+ // shortened name which will never get to the built state.
+ //
+ bool updated (cr.node_id.has_value ());
+
+ if (gq_update_or_create_check_run (error,
+ cr,
+ iat->token,
+ sd.repository_node_id,
+ cr.node_id,
+ sd.report_sha,
+ details_url (b),
+ build_state::built,
+ move (br)))
{
- // Create new check run.
- //
- // Note that we don't have build hints so will be creating this check
- // run with the full build id as name. In the unlikely event that an
- // out of order build_queued() were to run before we've saved this
- // check run to the service data it will create another check run with
- // the shortened name which will never get to the built state.
- //
- if (gq_create_check_run (error,
- cr,
- iat->token,
- sd.repository_node_id,
- sd.report_sha,
- details_url (b),
- build_state::built,
- move (br)))
- {
- assert (cr.state == build_state::built);
- l3 ([&]{trace << "created check_run { " << cr << " }";});
- }
+ assert (cr.state == build_state::built);
+
+ l3 ([&]{trace << (updated ? "updated" : "created")
+ << " check_run { " << cr << " }";});
}
if (cr.state_synced)