aboutsummaryrefslogtreecommitdiff
path: root/mod/mod-ci-github.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'mod/mod-ci-github.hxx')
-rw-r--r--mod/mod-ci-github.hxx140
1 files changed, 36 insertions, 104 deletions
diff --git a/mod/mod-ci-github.hxx b/mod/mod-ci-github.hxx
index 9731881..07feca8 100644
--- a/mod/mod-ci-github.hxx
+++ b/mod/mod-ci-github.hxx
@@ -10,115 +10,28 @@
#include <mod/module.hxx>
#include <mod/module-options.hxx>
-namespace butl
-{
- namespace json
- {
- class parser;
- }
-}
+#include <mod/ci-common.hxx>
+#include <mod/tenant-service.hxx>
+
+#include <mod/mod-ci-github-gh.hxx>
namespace brep
{
- // GitHub request/response types.
- //
- // Note that having this types directly in brep causes clashes (e.g., for
- // the repository name).
- //
- namespace gh
- {
- namespace json = butl::json;
-
- // The "check_suite" object within a check_suite webhook event request.
- //
- struct check_suite
- {
- uint64_t id;
- string head_branch;
- string head_sha;
- string before;
- string after;
-
- explicit
- check_suite (json::parser&);
-
- check_suite () = default;
- };
-
- struct repository
- {
- string name;
- string full_name;
- string default_branch;
-
- explicit
- repository (json::parser&);
-
- repository () = default;
- };
-
- struct installation
- {
- uint64_t id;
-
- explicit
- installation (json::parser&);
-
- installation () = default;
- };
-
- // The check_suite webhook event request.
- //
- struct check_suite_event
- {
- string action;
- gh::check_suite check_suite;
- gh::repository repository;
- gh::installation installation;
-
- explicit
- check_suite_event (json::parser&);
-
- check_suite_event () = default;
- };
-
- struct installation_access_token
- {
- string token;
- timestamp expires_at;
-
- explicit
- installation_access_token (json::parser&);
-
- installation_access_token () = default;
- };
-
- ostream&
- operator<< (ostream&, const check_suite&);
-
- ostream&
- operator<< (ostream&, const repository&);
-
- ostream&
- operator<< (ostream&, const installation&);
-
- ostream&
- operator<< (ostream&, const check_suite_event&);
-
- ostream&
- operator<< (ostream&, const installation_access_token&);
- }
-
- class ci_github: public handler
+ class ci_github: public handler,
+ private ci_start,
+ public tenant_service_build_queued,
+ public tenant_service_build_building,
+ public tenant_service_build_built
{
public:
- ci_github () = default;
+ explicit
+ ci_github (tenant_service_map&);
// Create a shallow copy (handling instance) if initialized and a deep
// copy (context exemplar) otherwise.
//
explicit
- ci_github (const ci_github&);
+ ci_github (const ci_github&, tenant_service_map&);
virtual bool
handle (request&, response&);
@@ -126,6 +39,21 @@ namespace brep
virtual const cli::options&
cli_options () const {return options::ci_github::description ();}
+ virtual function<optional<string> (const tenant_service&)>
+ build_queued (const tenant_service&,
+ const vector<build>&,
+ optional<build_state> initial_state,
+ const build_queued_hints&,
+ const diag_epilogue& log_writer) const noexcept override;
+
+ virtual function<optional<string> (const tenant_service&)>
+ build_building (const tenant_service&, const build&,
+ const diag_epilogue& log_writer) const noexcept override;
+
+ virtual function<optional<string> (const tenant_service&)>
+ build_built (const tenant_service&, const build&,
+ const diag_epilogue& log_writer) const noexcept override;
+
private:
virtual void
init (cli::scanner&);
@@ -133,18 +61,22 @@ namespace brep
// Handle the check_suite event `requested` and `rerequested` actions.
//
bool
- handle_check_suite_request (gh::check_suite_event) const;
+ handle_check_suite_request (gh_check_suite_event);
- string
- generate_jwt () const;
+ optional<string>
+ generate_jwt (const basic_mark& trace, const basic_mark& error) const;
// Authenticate to GitHub as an app installation.
//
- gh::installation_access_token
- obtain_installation_access_token (uint64_t install_id, string jwt) const;
+ optional<gh_installation_access_token>
+ obtain_installation_access_token (uint64_t install_id,
+ string jwt,
+ const basic_mark& error) const;
private:
shared_ptr<options::ci_github> options_;
+
+ tenant_service_map& tenant_service_map_;
};
}