aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mod/mod-ci-github.cxx61
-rw-r--r--mod/mod-ci-github.hxx43
-rw-r--r--mod/mod-repository-root.cxx24
-rw-r--r--mod/mod-repository-root.hxx2
4 files changed, 128 insertions, 2 deletions
diff --git a/mod/mod-ci-github.cxx b/mod/mod-ci-github.cxx
new file mode 100644
index 0000000..b31c144
--- /dev/null
+++ b/mod/mod-ci-github.cxx
@@ -0,0 +1,61 @@
+// file : mod/mod-ci-github.cxx -*- C++ -*-
+// license : MIT; see accompanying LICENSE file
+
+#include <mod/mod-ci-github.hxx>
+
+//#include <libbutl/manifest-parser.hxx>
+#include <libbutl/manifest-serializer.hxx>
+
+#include <mod/module-options.hxx>
+
+using namespace std;
+using namespace butl;
+using namespace web;
+using namespace brep::cli;
+
+brep::ci_github::
+ci_github (const ci_github& r)
+ : handler (r)
+{
+}
+
+void brep::ci_github::
+init (scanner& s)
+{
+ options_ = make_shared<options::ci> (
+ s, unknown_mode::fail, unknown_mode::fail);
+}
+
+bool brep::ci_github::
+handle (request& /*rq*/, response& rs)
+{
+ using namespace bpkg;
+ using namespace xhtml;
+
+ // using parser = manifest_parser;
+ // using parsing = manifest_parsing;
+ using serializer = manifest_serializer;
+ // using serialization = manifest_serialization;
+
+ HANDLER_DIAG;
+
+ string request_id; // Will be set later.
+ auto respond_manifest = [&rs, &request_id] (status_code status,
+ const string& message) -> bool
+ {
+ serializer s (rs.content (status, "text/manifest;charset=utf-8"),
+ "response");
+
+ s.next ("", "1"); // Start of manifest.
+ s.next ("status", to_string (status));
+ s.next ("message", message);
+
+ if (!request_id.empty ())
+ s.next ("reference", request_id);
+
+ s.next ("", ""); // End of manifest.
+ return true;
+ };
+
+ return respond_manifest (404, "XXX CI request submission disabled");
+}
diff --git a/mod/mod-ci-github.hxx b/mod/mod-ci-github.hxx
new file mode 100644
index 0000000..a869878
--- /dev/null
+++ b/mod/mod-ci-github.hxx
@@ -0,0 +1,43 @@
+// file : mod/mod-ci-github.hxx -*- C++ -*-
+// license : MIT; see accompanying LICENSE file
+
+#ifndef MOD_MOD_CI_GITHUB_HXX
+#define MOD_MOD_CI_GITHUB_HXX
+
+#include <web/xhtml/fragment.hxx>
+
+#include <libbrep/types.hxx>
+#include <libbrep/utility.hxx>
+
+#include <mod/module.hxx>
+#include <mod/module-options.hxx>
+
+namespace brep
+{
+ class ci_github: public handler
+ {
+ public:
+ ci_github () = default;
+
+ // Create a shallow copy (handling instance) if initialized and a deep
+ // copy (context exemplar) otherwise.
+ //
+ explicit
+ ci_github (const ci_github&);
+
+ virtual bool
+ handle (request&, response&);
+
+ virtual const cli::options&
+ cli_options () const {return options::ci::description ();}
+
+ private:
+ virtual void
+ init (cli::scanner&);
+
+ private:
+ shared_ptr<options::ci> options_;
+ };
+}
+
+#endif // MOD_MOD_CI_GITHUB_HXX
diff --git a/mod/mod-repository-root.cxx b/mod/mod-repository-root.cxx
index bc861a8..950fd8a 100644
--- a/mod/mod-repository-root.cxx
+++ b/mod/mod-repository-root.cxx
@@ -15,6 +15,7 @@
#include <mod/module-options.hxx>
#include <mod/mod-ci.hxx>
+#include <mod/mod-ci-github.hxx>
#include <mod/mod-submit.hxx>
#include <mod/mod-upload.hxx>
#include <mod/mod-builds.hxx>
@@ -134,6 +135,7 @@ namespace brep
ci_ (make_shared<ci> ()),
#endif
ci_cancel_ (make_shared<ci_cancel> ()),
+ ci_github_ (make_shared<ci_github> ()),
upload_ (make_shared<upload> ())
{
}
@@ -206,6 +208,10 @@ namespace brep
r.initialized_
? r.ci_cancel_
: make_shared<ci_cancel> (*r.ci_cancel_)),
+ ci_github_ (
+ r.initialized_
+ ? r.ci_github_
+ : make_shared<ci_github> (*r.ci_github_)),
upload_ (
r.initialized_
? r.upload_
@@ -237,6 +243,7 @@ namespace brep
append (r, submit_->options ());
append (r, ci_->options ());
append (r, ci_cancel_->options ());
+ append (r, ci_github_->options ());
append (r, upload_->options ());
return r;
}
@@ -284,6 +291,7 @@ namespace brep
sub_init (*submit_, "submit");
sub_init (*ci_, "ci");
sub_init (*ci_cancel_, "ci-cancel");
+ sub_init (*ci_github_, "ci_github");
sub_init (*upload_, "upload");
// Parse own configuration options.
@@ -304,8 +312,13 @@ namespace brep
//
auto verify = [&fail] (const string& v, const char* what)
{
- cstrings vs ({
- "packages", "builds", "build-configs", "about", "submit", "ci"});
+ cstrings vs ({"packages",
+ "builds",
+ "build-configs",
+ "about",
+ "submit",
+ "ci",
+ "ci-github"});
if (find (vs.begin (), vs.end (), v) == vs.end ())
fail << what << " value '" << v << "' is invalid";
@@ -487,6 +500,13 @@ namespace brep
return handle ("ci-cancel", param);
}
+ else if (func == "ci-github")
+ {
+ if (handler_ == nullptr)
+ handler_.reset (new ci_github (*ci_github_));
+
+ return handle ("ci_github", param);
+ }
else if (func == "upload")
{
if (handler_ == nullptr)
diff --git a/mod/mod-repository-root.hxx b/mod/mod-repository-root.hxx
index 990587e..31fde9b 100644
--- a/mod/mod-repository-root.hxx
+++ b/mod/mod-repository-root.hxx
@@ -26,6 +26,7 @@ namespace brep
class submit;
class ci;
class ci_cancel;
+ class ci_github;
class upload;
class repository_root: public handler
@@ -76,6 +77,7 @@ namespace brep
shared_ptr<submit> submit_;
shared_ptr<ci> ci_;
shared_ptr<ci_cancel> ci_cancel_;
+ shared_ptr<ci_github> ci_github_;
shared_ptr<upload> upload_;
shared_ptr<options::repository_root> options_;