aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancois Kritzinger <francois@codesynthesis.com>2024-11-12 16:46:22 +0200
committerFrancois Kritzinger <francois@codesynthesis.com>2024-11-14 07:58:53 +0200
commit9f6b964110da6175ec47a5bdd0863c0c1ee598ff (patch)
tree39add6a87c2a2845bc568c7d8f2461846cfa45b4
parent4c1109b6d36fa63b5ee86475cde9c3fe31913ff5 (diff)
Update build_building() to support induced check run creation
-rw-r--r--mod/mod-ci-github.cxx60
1 files changed, 43 insertions, 17 deletions
diff --git a/mod/mod-ci-github.cxx b/mod/mod-ci-github.cxx
index d651e36..35c6d57 100644
--- a/mod/mod-ci-github.cxx
+++ b/mod/mod-ci-github.cxx
@@ -1731,7 +1731,11 @@ namespace brep
//
if (scr->state == build_state::queued)
{
- if (scr->node_id)
+ // An absent node id with a true state_synced flag is a signal from
+ // handle_check_run_rerequest() that we need to create a new check run
+ // here (see that function for details).
+ //
+ if (scr->node_id || scr->state_synced)
{
cr = move (*scr);
cr->state_synced = false;
@@ -1777,26 +1781,48 @@ namespace brep
//
if (iat != nullptr)
{
- if (gq_update_check_run (error,
- *cr,
- iat->token,
- sd.repository_node_id,
- *cr->node_id,
- details_url (b),
- build_state::building))
+ // Update the check run if we have a node id, otherwise create a new
+ // one.
+ //
+ if (cr->node_id)
{
- // 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_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).
//
- if (cr->state == build_state::built)
+ if (gq_create_check_run (error,
+ *cr,
+ iat->token,
+ sd.repository_node_id,
+ sd.report_sha,
+ details_url (b),
+ build_state::building))
{
- warn << "check run " << bid << ": already in built state on GitHub";
- return nullptr;
+ assert (cr->state == build_state::building);
+ l3 ([&]{trace << "created check_run { " << *cr << " }";});
}
-
- assert (cr->state == build_state::building);
- l3 ([&]{trace << "updated check_run { " << *cr << " }";});
}
}