From a4c1f60c813783722d889a30d0d98aff177633bf Mon Sep 17 00:00:00 2001 From: Francois Kritzinger Date: Tue, 22 Oct 2024 07:05:57 +0200 Subject: Get building again --- mod/ci-common.cxx | 6 +++--- mod/mod-ci-github.cxx | 60 ++++++++++++++++++++++++++++----------------------- mod/mod-ci-github.hxx | 6 ++++-- 3 files changed, 40 insertions(+), 32 deletions(-) diff --git a/mod/ci-common.cxx b/mod/ci-common.cxx index caf9f40..b3fc432 100644 --- a/mod/ci-common.cxx +++ b/mod/ci-common.cxx @@ -534,7 +534,7 @@ namespace brep s.next ("", ""); // End of manifest. } - optional ci_start:: + pair, ci_start::duplicate_tenant_result> ci_start:: create (const basic_mark& error, const basic_mark&, const basic_mark* trace, @@ -557,7 +557,7 @@ namespace brep catch (const system_error& e) { error << "unable to generate request id: " << e; - return nullopt; + return {nullopt, duplicate_tenant_result::ignored}; // @@ TODO HACKED AROUND } // Use the generated request id if the tenant service id is not specified. @@ -605,7 +605,7 @@ namespace brep *trace << "unloaded CI request " << t.id << " for service " << t.service->id << ' ' << t.service->type << " is created"; - return move (t.id); + return {move (t.id), duplicate_tenant_result::created}; // @@ TODO HACKED AROUND } optional ci_start:: diff --git a/mod/mod-ci-github.cxx b/mod/mod-ci-github.cxx index 56f6d89..b9dc80f 100644 --- a/mod/mod-ci-github.cxx +++ b/mod/mod-ci-github.cxx @@ -825,8 +825,32 @@ namespace brep } function (const tenant_service&)> ci_github:: - build_unloaded_pre_check (service_data&& sd, - const diag_epilogue& log_writer) const noexcept + build_unloaded (tenant_service&& ts, + const diag_epilogue& log_writer) const noexcept + { + NOTIFICATION_DIAG (log_writer); + + service_data sd; + try + { + sd = service_data (*ts.data); + } + catch (const invalid_argument& e) + { + error << "failed to parse service data: " << e; + return nullptr; + } + + return sd.pre_check + ? build_unloaded_pre_check (move (ts), move (sd), log_writer) + : build_unloaded_load (move (ts), move (sd), log_writer); + } + + function (const tenant_service&)> ci_github:: + build_unloaded_pre_check ( + tenant_service&&, + service_data&& sd, + const diag_epilogue& log_writer) const noexcept { NOTIFICATION_DIAG (log_writer); @@ -842,9 +866,13 @@ namespace brep } function (const tenant_service&)> ci_github:: - build_unloaded_load (service_data&& sd, - const diag_epilogue& log_writer) const noexcept + build_unloaded_load ( + tenant_service&& ts, + service_data&& sd, + const diag_epilogue& log_writer) const noexcept { + NOTIFICATION_DIAG (log_writer); + // @@@ TODO: load the tenant: should be the same for both branch push and // PR. // @@ -1204,28 +1232,6 @@ namespace brep }; } - function (const tenant_service&)> ci_github:: - build_unloaded (tenant_service&& ts, - const diag_epilogue& log_writer) const noexcept - { - NOTIFICATION_DIAG (log_writer); - - service_data sd; - try - { - sd = service_data (*ts.data); - } - catch (const invalid_argument& e) - { - error << "failed to parse service data: " << e; - return nullptr; - } - - return sd.pre_check - ? build_unloaded_pre_check (move (sd), log_writer) - : build_unloaded_load (move (sd), log_writer) - } - // Build state change notifications (see tenant-services.hxx for // background). Mapping our state transitions to GitHub pose multiple // problems: @@ -2017,7 +2023,7 @@ namespace brep *build_db_, move (ts), chrono::seconds (30) /* interval */, chrono::seconds (0) /* delay */) - .has_value (); + .first.has_value (); // @@ TODO HACKED AROUND } string ci_github:: diff --git a/mod/mod-ci-github.hxx b/mod/mod-ci-github.hxx index c24e0a5..e919065 100644 --- a/mod/mod-ci-github.hxx +++ b/mod/mod-ci-github.hxx @@ -47,11 +47,13 @@ namespace brep const diag_epilogue& log_writer) const noexcept override; function (const tenant_service&)> - build_unloaded_pre_check (service_data&&, + build_unloaded_pre_check (tenant_service&&, + service_data&&, const diag_epilogue&) const noexcept; function (const tenant_service&)> - build_unloaded_load (service_data&&, + build_unloaded_load (tenant_service&&, + service_data&&, const diag_epilogue&) const noexcept; virtual function (const tenant_service&)> -- cgit v1.1