aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
authorFrancois Kritzinger <francois@codesynthesis.com>2024-11-26 14:07:29 +0200
committerFrancois Kritzinger <francois@codesynthesis.com>2024-11-27 09:08:26 +0200
commitee6d96c115f4c18a1a8ab908db4e0981971337a0 (patch)
treee8d64927a114bad46a9bc7baed35410104ac842b /mod
parent9d853826320cd39a3b96c6ecdc4ae8a855784e99 (diff)
Remote PRs: cancel previous PR head commit CI
Diffstat (limited to 'mod')
-rw-r--r--mod/mod-ci-github.cxx30
1 files changed, 29 insertions, 1 deletions
diff --git a/mod/mod-ci-github.cxx b/mod/mod-ci-github.cxx
index be2dc10..7037dfb 100644
--- a/mod/mod-ci-github.cxx
+++ b/mod/mod-ci-github.cxx
@@ -1498,7 +1498,35 @@ namespace brep
//
if (kind == service_data::remote && pr.action == "synchronize")
{
- // @@ TODO: call cancel on old SHA with refcount=true.
+ if (pr.before)
+ {
+ // Service id that will uniquely identify the CI tenant.
+ //
+ string sid (pr.repository.node_id + ':' + *pr.before);
+
+ if (optional<tenant_service> ts = cancel (error, warn,
+ verb_ ? &trace : nullptr,
+ *build_db_, retry_,
+ "ci-github", sid,
+ true /* ref_count */))
+ {
+ l3 ([&]{trace << "pull request " << pr.pull_request.node_id
+ << ": canceled CI of previous head commit"
+ << " (ref_count: " << ts->ref_count << ')';});
+ }
+ else
+ {
+ error << "pull request " << pr.pull_request.node_id
+ << ": failed to cancel CI of previous head commit "
+ << "with tenant_service id " << sid;
+ }
+ }
+ else
+ {
+ error << "pull request " << pr.pull_request.node_id
+ << ": `before` member is missing"
+ << " so cannot cancel CI of previous head commit";
+ }
}
// Note: for remote PRs the check_sha will be set later, in