From 95b2442db8aa986673716cf8df138e8f0c95ddfb Mon Sep 17 00:00:00 2001 From: Malcolm Date: Mon, 10 Feb 2025 10:00:30 +0100 Subject: [PATCH 1/2] #150 REFACTOR VCS Provider matrix --- code/pds.conf | 117 +++++++++++++++++- code/src/terrat/terrat_ep_github_events3.mli | 9 -- code/src/terrat/terrat_ep_installations.ml | 4 +- code/src/terrat/terrat_ep_user.ml | 16 ++- code/src/terrat/terrat_server.ml | 20 +-- code/src/terrat/terrat_server.mli | 13 +- .../terrat_code_idx.ml | 0 .../terrat_code_idx.mli | 0 code/src/terrat_ee/terrat_ee.ml | 2 +- .../terrat_evaluator3.ml | 0 .../terrat_evaluator3.mli | 0 .../terrat_metrics.ml | 0 .../terrat_metrics.mli | 0 code/src/terrat_oss/terrat_oss.ml | 2 +- .../terrat_session.ml | 0 .../terrat_session.mli | 0 .../terrat_storage.ml | 0 .../terrat_storage.mli | 0 .../{terrat => terrat_task}/terrat_task.ml | 0 .../{terrat => terrat_task}/terrat_task.mli | 0 .../terrat_telemetry.ml | 0 .../terrat_telemetry.mli | 0 .../{terrat => terrat_user}/terrat_user.ml | 0 .../{terrat => terrat_user}/terrat_user.mli | 0 .../terrat_vcs_github.ml} | 17 ++- .../terrat_vcs_github.mli} | 0 .../terrat_vcs_github_commit_check.ml} | 0 .../terrat_vcs_github_commit_check.mli} | 0 .../terrat_vcs_github_ep_callback.ml} | 0 .../terrat_vcs_github_ep_callback.mli} | 0 .../terrat_vcs_github_ep_client_id.ml} | 0 .../terrat_vcs_github_ep_client_id.mli} | 0 .../terrat_vcs_github_ep_events3.ml} | 54 ++++---- .../terrat_vcs_github_ep_events3.mli | 10 ++ .../terrat_vcs_github_ep_work_manifest.ml} | 12 +- .../terrat_vcs_github_ep_work_manifest.mli} | 13 +- .../terrat_vcs_github_installation.ml} | 0 .../terrat_vcs_github_installation.mli} | 0 .../terrat_vcs_github_user.ml} | 0 .../terrat_vcs_github_user.mli} | 0 .../terrat_vcs_provider.ml | 4 + .../terrat_vcs_provider.mli | 4 + 42 files changed, 220 insertions(+), 77 deletions(-) delete mode 100644 code/src/terrat/terrat_ep_github_events3.mli rename code/src/{terrat => terrat_code_idx}/terrat_code_idx.ml (100%) rename code/src/{terrat => terrat_code_idx}/terrat_code_idx.mli (100%) rename code/src/{terrat => terrat_evaluator3}/terrat_evaluator3.ml (100%) rename code/src/{terrat => terrat_evaluator3}/terrat_evaluator3.mli (100%) rename code/src/{terrat => terrat_metrics}/terrat_metrics.ml (100%) rename code/src/{terrat => terrat_metrics}/terrat_metrics.mli (100%) rename code/src/{terrat => terrat_session}/terrat_session.ml (100%) rename code/src/{terrat => terrat_session}/terrat_session.mli (100%) rename code/src/{terrat => terrat_storage}/terrat_storage.ml (100%) rename code/src/{terrat => terrat_storage}/terrat_storage.mli (100%) rename code/src/{terrat => terrat_task}/terrat_task.ml (100%) rename code/src/{terrat => terrat_task}/terrat_task.mli (100%) rename code/src/{terrat => terrat_telemetry}/terrat_telemetry.ml (100%) rename code/src/{terrat => terrat_telemetry}/terrat_telemetry.mli (100%) rename code/src/{terrat => terrat_user}/terrat_user.ml (100%) rename code/src/{terrat => terrat_user}/terrat_user.mli (100%) rename code/src/{terrat/terrat_github_evaluator3.ml => terrat_vcs_github/terrat_vcs_github.ml} (99%) rename code/src/{terrat/terrat_github_evaluator3.mli => terrat_vcs_github/terrat_vcs_github.mli} (100%) rename code/src/{terrat/terrat_github_commit_check.ml => terrat_vcs_github/terrat_vcs_github_commit_check.ml} (100%) rename code/src/{terrat/terrat_github_commit_check.mli => terrat_vcs_github/terrat_vcs_github_commit_check.mli} (100%) rename code/src/{terrat/terrat_ep_github_callback.ml => terrat_vcs_github/terrat_vcs_github_ep_callback.ml} (100%) rename code/src/{terrat/terrat_ep_github_callback.mli => terrat_vcs_github/terrat_vcs_github_ep_callback.mli} (100%) rename code/src/{terrat/terrat_ep_github_client_id.ml => terrat_vcs_github/terrat_vcs_github_ep_client_id.ml} (100%) rename code/src/{terrat/terrat_ep_github_client_id.mli => terrat_vcs_github/terrat_vcs_github_ep_client_id.mli} (100%) rename code/src/{terrat/terrat_ep_github_events3.ml => terrat_vcs_github/terrat_vcs_github_ep_events3.ml} (93%) create mode 100644 code/src/terrat_vcs_github/terrat_vcs_github_ep_events3.mli rename code/src/{terrat/terrat_ep_github_work_manifest3.ml => terrat_vcs_github/terrat_vcs_github_ep_work_manifest.ml} (96%) rename code/src/{terrat/terrat_ep_github_work_manifest3.mli => terrat_vcs_github/terrat_vcs_github_ep_work_manifest.mli} (65%) rename code/src/{terrat/terrat_github_installation.ml => terrat_vcs_github/terrat_vcs_github_installation.ml} (100%) rename code/src/{terrat/terrat_github_installation.mli => terrat_vcs_github/terrat_vcs_github_installation.mli} (100%) rename code/src/{terrat/terrat_github_user.ml => terrat_vcs_github/terrat_vcs_github_user.ml} (100%) rename code/src/{terrat/terrat_github_user.mli => terrat_vcs_github/terrat_vcs_github_user.mli} (100%) diff --git a/code/pds.conf b/code/pds.conf index 2a9a6de12..a17438e12 100644 --- a/code/pds.conf +++ b/code/pds.conf @@ -708,23 +708,31 @@ deps = [ "terrat_base_repo_config_v1", "terrat_change", "terrat_change_match3", + "terrat_code_idx", "terrat_comment", "terrat_commit_check", "terrat_config", "terrat_data", "terrat_dirspace", + "terrat_evaluator3", "terrat_files", "terrat_github", "terrat_github_webhooks", + "terrat_metrics", "terrat_plan_diff", "terrat_pull_request", "terrat_repo_config", + "terrat_session", "terrat_sql_of_tag_query", + "terrat_storage", "terrat_tag_query", "terrat_tag_query_ast", "terrat_tag_query_lexer", "terrat_tag_query_parser", "terrat_tag_set", + "terrat_telemetry", + "terrat_user", + "terrat_vcs_github", "terrat_vcs_provider", "terrat_work_manifest3", "terratc_intf", @@ -773,6 +781,12 @@ deps = [ "yojson", ] +[src.terrat_code_idx] +install = false +deps = [ + "terrat_api", +] + [src.terrat_code_indexer] install = false type = "exec" @@ -806,9 +820,21 @@ type = "exec" install = false deps = [ "terrat", + "terrat_vcs_github", "terratc_ee", ] +[src.terrat_evaluator3] +install = false +deps = [ + "abb", + "abb_flow", + "abbs", + "containers", + "terrat_storage", + "terrat_vcs_provider", +] + [src.terrat_files] install = false extra_makefile_lines = ["include $(SRC_DIR)/files.mk"] @@ -822,11 +848,18 @@ install = false deps = ["cohttp", "containers", "json_schema", "mirage-crypto", "ppx_deriving.eq", "ppx_deriving.make", "ppx_deriving.show", "ppx_deriving_yojson", "yojson"] extra_makefile_lines = ["DOC_FILES:=$(wildcard $(SRC_DIR)/*.ml)"] +[src.terrat_metrics] +install = false +deps = [ + "prmths", +] + [src.terrat_oss] type = "exec" install = false deps = [ "terrat", + "terrat_vcs_github", "terratc_oss", ] @@ -858,6 +891,14 @@ deps = [ "yojson", ] +[src.terrat_storage] +install = false +deps = [ + "pgsql_pool", + "prmths", + "terrat_config", +] + [src.terrat_tag_query] install = false deps = ["containers", "path_glob", "ppx_deriving", "ppx_deriving.eq", "ppx_deriving.show", "terrat_dirspace", "terrat_tag_query_ast", "terrat_tag_set"] @@ -883,6 +924,28 @@ deps = [] install = false deps = ["containers", "ppx_deriving", "ppx_deriving.show"] +[src.terrat_task] +install = false +deps = [ + "abb", + "abbs", + "pgsql_io", + "terrat_storage", + "uuidm", +] + +[src.terrat_telemetry] +install = false +deps = [ + "abb", + "abb_curl_easy", + "abbs", + "logs", + "terrat_config", + "terrat_work_manifest3", + "uri", +] + [src.terrat_ui] type = "exec" install = false @@ -943,9 +1006,60 @@ extra_makefile_lines = ["OCAMLC_LINK_OPTS=", "OCAMLOPT_LINK_OPTS=", "all: terrat [src.terrat_ui_sw.profile] extra_makefile_lines = ["OCAMLC_LINK_OPTS=", "OCAMLOPT_LINK_OPTS=", "all: terrat_ui_sw.js", "terrat_ui_sw.js: $(BYTE_TARGET)", "\tjs_of_ocaml --pretty --source-map-inline $(shell env OCAMLPATH=$(OCAMLPATH) ocamlfind query -r -format '%+(jsoo_runtime)' -separator ' ' $(PACKAGES)) terrat_ui_sw.byte"] +[src.terrat_user] +install = false +deps = [ + "abb", + "brtl", + "containers", + "pgsql_io", + "pgsql_pool", + "terrat_storage", + "uuidm", +] + +[src.terrat_session] +install = false +deps = [ + "terrat_storage", + "brtl", + "terrat_user", + "brtl_mw_session", +] + +[src.terrat_vcs_github] +install = false +deps = [ + "abb", + "abbs", + "brtl", + "brtl_permissions", + "containers", + "githubc2", + "pgsql_io", + "terrat_api", + "terrat_base_repo_config_v1", + "terrat_change", + "terrat_code_idx", + "terrat_config", + "terrat_evaluator3", + "terrat_github", + "terrat_github_webhooks", + "terrat_metrics", + "terrat_pull_request", + "terrat_session", + "terrat_storage", + "terrat_task", + "terrat_telemetry", + "terrat_user", + "terrat_vcs_provider", + "terrat_work_manifest3", +] + [src.terrat_vcs_provider] install = false deps = [ + "brtl", "containers", "pgsql_io", "terrat_access_control", @@ -956,8 +1070,9 @@ deps = [ "terrat_comment", "terrat_commit_check", "terrat_config", + "terrat_files", + "terrat_plan_diff", "terrat_pull_request", - "terrat_work_manifest3", "terratc_intf", ] diff --git a/code/src/terrat/terrat_ep_github_events3.mli b/code/src/terrat/terrat_ep_github_events3.mli deleted file mode 100644 index 0e42f3be2..000000000 --- a/code/src/terrat/terrat_ep_github_events3.mli +++ /dev/null @@ -1,9 +0,0 @@ -module Make - (Terratc : Terratc_intf.S - with type Github.Client.t = Terrat_github_evaluator3.S.Client.t - and type Github.Account.t = Terrat_github_evaluator3.S.Account.t - and type Github.Repo.t = Terrat_github_evaluator3.S.Repo.t - and type Github.Remote_repo.t = Terrat_github_evaluator3.S.Remote_repo.t - and type Github.Ref.t = Terrat_github_evaluator3.S.Ref.t) : sig - val post : Terrat_config.t -> Terrat_storage.t -> Brtl_rtng.Handler.t -end diff --git a/code/src/terrat/terrat_ep_installations.ml b/code/src/terrat/terrat_ep_installations.ml index 54d339287..677e3f707 100644 --- a/code/src/terrat/terrat_ep_installations.ml +++ b/code/src/terrat/terrat_ep_installations.ml @@ -1280,11 +1280,11 @@ module Repos = struct Terrat_user.enforce_installation_access storage user installation_id ctx >>= fun () -> let open Abb.Future.Infix_monad in - Terrat_github_installation.refresh_repos' + Terrat_vcs_github_installation.refresh_repos' ~request_id:(Brtl_ctx.token ctx) ~config ~storage - (Terrat_github_installation.Id.make installation_id) + (Terrat_vcs_github_installation.Id.make installation_id) >>= function | Ok task -> let id = Uuidm.to_string (Terrat_task.id task) in diff --git a/code/src/terrat/terrat_ep_user.ml b/code/src/terrat/terrat_ep_user.ml index 7752350c1..1cb15c16c 100644 --- a/code/src/terrat/terrat_ep_user.ml +++ b/code/src/terrat/terrat_ep_user.ml @@ -27,7 +27,7 @@ module Installations = struct let get' config storage user = let open Abbs_future_combinators.Infix_result_monad in - Terrat_github_user.get_token config storage user + Terrat_vcs_github_user.get_token config storage user >>= fun token -> Terrat_github.with_client config (`Bearer token) Terrat_github.get_user_installations >>= fun installations -> @@ -65,7 +65,11 @@ module Installations = struct Abb.Future.return (Ok (Brtl_ctx.set_response (Brtl_rspnc.create ~status:`OK body) ctx)) | Error (`Refresh_err _ as err) -> Logs.err (fun m -> - m "%s : GET : INSTALLATIONS : %a" (Brtl_ctx.token ctx) Terrat_github_user.pp_err err); + m + "%s : GET : INSTALLATIONS : %a" + (Brtl_ctx.token ctx) + Terrat_vcs_github_user.pp_err + err); Abb.Future.return (Ok (Brtl_ctx.set_response (Brtl_rspnc.create ~status:`Forbidden "") ctx)) | Error `Bad_refresh_token -> @@ -92,9 +96,13 @@ module Installations = struct err); Abb.Future.return (Ok (Brtl_ctx.set_response (Brtl_rspnc.create ~status:`Internal_server_error "") ctx)) - | Error (#Terrat_github_user.err as err) -> + | Error (#Terrat_vcs_github_user.err as err) -> Logs.err (fun m -> - m "%s : GET : INSTALLATIONS : %a" (Brtl_ctx.token ctx) Terrat_github_user.pp_err err); + m + "%s : GET : INSTALLATIONS : %a" + (Brtl_ctx.token ctx) + Terrat_vcs_github_user.pp_err + err); Abb.Future.return (Ok (Brtl_ctx.set_response (Brtl_rspnc.create ~status:`Internal_server_error "") ctx))) end diff --git a/code/src/terrat/terrat_server.ml b/code/src/terrat/terrat_server.ml index 493ebfbfc..b193e67bf 100644 --- a/code/src/terrat/terrat_server.ml +++ b/code/src/terrat/terrat_server.ml @@ -1,15 +1,15 @@ module Make (Terratc : Terratc_intf.S - with type Github.Client.t = Terrat_github_evaluator3.S.Client.t - and type Github.Account.t = Terrat_github_evaluator3.S.Account.t - and type Github.Repo.t = Terrat_github_evaluator3.S.Repo.t - and type Github.Remote_repo.t = Terrat_github_evaluator3.S.Remote_repo.t - and type Github.Ref.t = Terrat_github_evaluator3.S.Ref.t) = + with type Github.Client.t = Terrat_vcs_github.S.Client.t + and type Github.Account.t = Terrat_vcs_github.S.Account.t + and type Github.Repo.t = Terrat_vcs_github.S.Repo.t + and type Github.Remote_repo.t = Terrat_vcs_github.S.Remote_repo.t + and type Github.Ref.t = Terrat_vcs_github.S.Ref.t) = struct - module Github_evaluator = Terrat_github_evaluator3.Make (Terratc) - module Github_events = Terrat_ep_github_events3.Make (Terratc) - module Github_work_manifest = Terrat_ep_github_work_manifest3.Make (Terratc) + module Github_evaluator = Terrat_vcs_github.Make (Terratc) + module Github_events = Terrat_vcs_github_ep_events3.Make (Terratc) + module Github_work_manifest = Terrat_vcs_github_ep_work_manifest.Make (Terratc) module Rt = struct let api () = Brtl_rtng.Route.(rel / "api") @@ -196,8 +196,8 @@ struct --> Github_work_manifest.Access_token.post config storage ); (* Github *) (`POST, Rt.github_events () --> Github_events.post config storage); - (`GET, Rt.github_callback () --> Terrat_ep_github_callback.get config storage); - (`GET, Rt.github_client_id () --> Terrat_ep_github_client_id.get config storage); + (`GET, Rt.github_callback () --> Terrat_vcs_github_ep_callback.get config storage); + (`GET, Rt.github_client_id () --> Terrat_vcs_github_ep_client_id.get config storage); (* User *) (`GET, Rt.whoami () --> Terrat_ep_whoami.get config storage); (`GET, Rt.user_installations_rt () --> Terrat_ep_user.Installations.get config storage); diff --git a/code/src/terrat/terrat_server.mli b/code/src/terrat/terrat_server.mli index 2b8791d7c..f937be76e 100644 --- a/code/src/terrat/terrat_server.mli +++ b/code/src/terrat/terrat_server.mli @@ -1,9 +1,10 @@ module Make - (Terratc : Terratc_intf.S - with type Github.Client.t = Terrat_github_evaluator3.S.Client.t - and type Github.Account.t = Terrat_github_evaluator3.S.Account.t - and type Github.Repo.t = Terrat_github_evaluator3.S.Repo.t - and type Github.Remote_repo.t = Terrat_github_evaluator3.S.Remote_repo.t - and type Github.Ref.t = Terrat_github_evaluator3.S.Ref.t) : sig + (Terratc : + Terratc_intf.S + with type Github.Client.t = Terrat_vcs_github.S.Client.t + and type Github.Account.t = Terrat_vcs_github.S.Account.t + and type Github.Repo.t = Terrat_vcs_github.S.Repo.t + and type Github.Remote_repo.t = Terrat_vcs_github.S.Remote_repo.t + and type Github.Ref.t = Terrat_vcs_github.S.Ref.t) : sig val run : Terrat_config.t -> Terrat_storage.t -> unit Abb.Future.t end diff --git a/code/src/terrat/terrat_code_idx.ml b/code/src/terrat_code_idx/terrat_code_idx.ml similarity index 100% rename from code/src/terrat/terrat_code_idx.ml rename to code/src/terrat_code_idx/terrat_code_idx.ml diff --git a/code/src/terrat/terrat_code_idx.mli b/code/src/terrat_code_idx/terrat_code_idx.mli similarity index 100% rename from code/src/terrat/terrat_code_idx.mli rename to code/src/terrat_code_idx/terrat_code_idx.mli diff --git a/code/src/terrat_ee/terrat_ee.ml b/code/src/terrat_ee/terrat_ee.ml index a862b3b66..a8079d232 100644 --- a/code/src/terrat_ee/terrat_ee.ml +++ b/code/src/terrat_ee/terrat_ee.ml @@ -1,5 +1,5 @@ module Terratc = Terratc_ee.Make (struct - module Github = Terrat_github_evaluator3.S + module Github = Terrat_vcs_github.S end) module Server = Terrat_server.Make (Terratc) diff --git a/code/src/terrat/terrat_evaluator3.ml b/code/src/terrat_evaluator3/terrat_evaluator3.ml similarity index 100% rename from code/src/terrat/terrat_evaluator3.ml rename to code/src/terrat_evaluator3/terrat_evaluator3.ml diff --git a/code/src/terrat/terrat_evaluator3.mli b/code/src/terrat_evaluator3/terrat_evaluator3.mli similarity index 100% rename from code/src/terrat/terrat_evaluator3.mli rename to code/src/terrat_evaluator3/terrat_evaluator3.mli diff --git a/code/src/terrat/terrat_metrics.ml b/code/src/terrat_metrics/terrat_metrics.ml similarity index 100% rename from code/src/terrat/terrat_metrics.ml rename to code/src/terrat_metrics/terrat_metrics.ml diff --git a/code/src/terrat/terrat_metrics.mli b/code/src/terrat_metrics/terrat_metrics.mli similarity index 100% rename from code/src/terrat/terrat_metrics.mli rename to code/src/terrat_metrics/terrat_metrics.mli diff --git a/code/src/terrat_oss/terrat_oss.ml b/code/src/terrat_oss/terrat_oss.ml index 210f5c5c0..4b46ca1ae 100644 --- a/code/src/terrat_oss/terrat_oss.ml +++ b/code/src/terrat_oss/terrat_oss.ml @@ -1,5 +1,5 @@ module Terratc = Terratc_oss.Make (struct - module Github = Terrat_github_evaluator3.S + module Github = Terrat_vcs_github.S end) module Server = Terrat_server.Make (Terratc) diff --git a/code/src/terrat/terrat_session.ml b/code/src/terrat_session/terrat_session.ml similarity index 100% rename from code/src/terrat/terrat_session.ml rename to code/src/terrat_session/terrat_session.ml diff --git a/code/src/terrat/terrat_session.mli b/code/src/terrat_session/terrat_session.mli similarity index 100% rename from code/src/terrat/terrat_session.mli rename to code/src/terrat_session/terrat_session.mli diff --git a/code/src/terrat/terrat_storage.ml b/code/src/terrat_storage/terrat_storage.ml similarity index 100% rename from code/src/terrat/terrat_storage.ml rename to code/src/terrat_storage/terrat_storage.ml diff --git a/code/src/terrat/terrat_storage.mli b/code/src/terrat_storage/terrat_storage.mli similarity index 100% rename from code/src/terrat/terrat_storage.mli rename to code/src/terrat_storage/terrat_storage.mli diff --git a/code/src/terrat/terrat_task.ml b/code/src/terrat_task/terrat_task.ml similarity index 100% rename from code/src/terrat/terrat_task.ml rename to code/src/terrat_task/terrat_task.ml diff --git a/code/src/terrat/terrat_task.mli b/code/src/terrat_task/terrat_task.mli similarity index 100% rename from code/src/terrat/terrat_task.mli rename to code/src/terrat_task/terrat_task.mli diff --git a/code/src/terrat/terrat_telemetry.ml b/code/src/terrat_telemetry/terrat_telemetry.ml similarity index 100% rename from code/src/terrat/terrat_telemetry.ml rename to code/src/terrat_telemetry/terrat_telemetry.ml diff --git a/code/src/terrat/terrat_telemetry.mli b/code/src/terrat_telemetry/terrat_telemetry.mli similarity index 100% rename from code/src/terrat/terrat_telemetry.mli rename to code/src/terrat_telemetry/terrat_telemetry.mli diff --git a/code/src/terrat/terrat_user.ml b/code/src/terrat_user/terrat_user.ml similarity index 100% rename from code/src/terrat/terrat_user.ml rename to code/src/terrat_user/terrat_user.ml diff --git a/code/src/terrat/terrat_user.mli b/code/src/terrat_user/terrat_user.mli similarity index 100% rename from code/src/terrat/terrat_user.mli rename to code/src/terrat_user/terrat_user.mli diff --git a/code/src/terrat/terrat_github_evaluator3.ml b/code/src/terrat_vcs_github/terrat_vcs_github.ml similarity index 99% rename from code/src/terrat/terrat_github_evaluator3.ml rename to code/src/terrat_vcs_github/terrat_vcs_github.ml index bac83f5bb..3dc9fd6f2 100644 --- a/code/src/terrat/terrat_github_evaluator3.ml +++ b/code/src/terrat_vcs_github/terrat_vcs_github.ml @@ -1235,6 +1235,10 @@ struct include S module Db = Pgsql_io + module Routes = struct + let get = [] + end + module Drift = struct type t end @@ -4321,7 +4325,7 @@ struct "GITHUB_EVALUATOR : %s : CREATE_COMMIT_CHECKS : num=%d" request_id (CCList.length checks)); - Terrat_github_commit_check.create + Terrat_vcs_github_commit_check.create ~owner:(Repo.owner repo) ~repo:(Repo.name repo) ~ref_ @@ -4343,16 +4347,21 @@ struct (fun time -> Logs.info (fun m -> m "GITHUB_EVALUATOR : %s : LIST_COMMIT_CHECKS : %f" request_id time)) (fun () -> - Terrat_github_commit_check.list ~log_id:request_id ~owner ~repo ~ref_ client.Client.client) + Terrat_vcs_github_commit_check.list + ~log_id:request_id + ~owner + ~repo + ~ref_ + client.Client.client) >>= function | Ok _ as res -> Abb.Future.return res - | Error (#Terrat_github_commit_check.list_err as err) -> + | Error (#Terrat_vcs_github_commit_check.list_err as err) -> Prmths.Counter.inc_one Metrics.github_errors_total; Logs.err (fun m -> m "GITHUB_EVALUATOR : %s : FETCH_COMMIT_CHECKS : %a" request_id - Terrat_github_commit_check.pp_list_err + Terrat_vcs_github_commit_check.pp_list_err err); Abb.Future.return (Error `Error) diff --git a/code/src/terrat/terrat_github_evaluator3.mli b/code/src/terrat_vcs_github/terrat_vcs_github.mli similarity index 100% rename from code/src/terrat/terrat_github_evaluator3.mli rename to code/src/terrat_vcs_github/terrat_vcs_github.mli diff --git a/code/src/terrat/terrat_github_commit_check.ml b/code/src/terrat_vcs_github/terrat_vcs_github_commit_check.ml similarity index 100% rename from code/src/terrat/terrat_github_commit_check.ml rename to code/src/terrat_vcs_github/terrat_vcs_github_commit_check.ml diff --git a/code/src/terrat/terrat_github_commit_check.mli b/code/src/terrat_vcs_github/terrat_vcs_github_commit_check.mli similarity index 100% rename from code/src/terrat/terrat_github_commit_check.mli rename to code/src/terrat_vcs_github/terrat_vcs_github_commit_check.mli diff --git a/code/src/terrat/terrat_ep_github_callback.ml b/code/src/terrat_vcs_github/terrat_vcs_github_ep_callback.ml similarity index 100% rename from code/src/terrat/terrat_ep_github_callback.ml rename to code/src/terrat_vcs_github/terrat_vcs_github_ep_callback.ml diff --git a/code/src/terrat/terrat_ep_github_callback.mli b/code/src/terrat_vcs_github/terrat_vcs_github_ep_callback.mli similarity index 100% rename from code/src/terrat/terrat_ep_github_callback.mli rename to code/src/terrat_vcs_github/terrat_vcs_github_ep_callback.mli diff --git a/code/src/terrat/terrat_ep_github_client_id.ml b/code/src/terrat_vcs_github/terrat_vcs_github_ep_client_id.ml similarity index 100% rename from code/src/terrat/terrat_ep_github_client_id.ml rename to code/src/terrat_vcs_github/terrat_vcs_github_ep_client_id.ml diff --git a/code/src/terrat/terrat_ep_github_client_id.mli b/code/src/terrat_vcs_github/terrat_vcs_github_ep_client_id.mli similarity index 100% rename from code/src/terrat/terrat_ep_github_client_id.mli rename to code/src/terrat_vcs_github/terrat_vcs_github_ep_client_id.mli diff --git a/code/src/terrat/terrat_ep_github_events3.ml b/code/src/terrat_vcs_github/terrat_vcs_github_ep_events3.ml similarity index 93% rename from code/src/terrat/terrat_ep_github_events3.ml rename to code/src/terrat_vcs_github/terrat_vcs_github_ep_events3.ml index 0295a627f..d966b2547 100644 --- a/code/src/terrat/terrat_ep_github_events3.ml +++ b/code/src/terrat_vcs_github/terrat_vcs_github_ep_events3.ml @@ -40,13 +40,13 @@ end module Make (Terratc : Terratc_intf.S - with type Github.Client.t = Terrat_github_evaluator3.S.Client.t - and type Github.Account.t = Terrat_github_evaluator3.S.Account.t - and type Github.Repo.t = Terrat_github_evaluator3.S.Repo.t - and type Github.Remote_repo.t = Terrat_github_evaluator3.S.Remote_repo.t - and type Github.Ref.t = Terrat_github_evaluator3.S.Ref.t) = + with type Github.Client.t = Terrat_vcs_github.S.Client.t + and type Github.Account.t = Terrat_vcs_github.S.Account.t + and type Github.Repo.t = Terrat_vcs_github.S.Repo.t + and type Github.Remote_repo.t = Terrat_vcs_github.S.Remote_repo.t + and type Github.Ref.t = Terrat_vcs_github.S.Ref.t) = struct - module Github_evaluator = Terrat_github_evaluator3.Make (Terratc) + module Github_evaluator = Terrat_vcs_github.Make (Terratc) module Gw = Terrat_github_webhooks module Sql = struct @@ -244,10 +244,10 @@ struct repository.Gw.Repository.owner.Gw.User.login repository.Gw.Repository.name sender.Gw.User.login); - let account = Terrat_github_evaluator3.S.Account.make ~installation_id () in - let user = Terrat_github_evaluator3.S.User.make sender.Gw.User.login in + let account = Terrat_vcs_github.S.Account.make ~installation_id () in + let user = Terrat_vcs_github.S.User.make sender.Gw.User.login in let repo = - Terrat_github_evaluator3.S.Repo.make + Terrat_vcs_github.S.Repo.make ~id:repository.Gw.Repository.id ~name:repository.Gw.Repository.name ~owner:repository.Gw.Repository.owner.Gw.User.login @@ -277,10 +277,10 @@ struct repository.Gw.Repository.owner.Gw.User.login repository.Gw.Repository.name sender.Gw.User.login); - let account = Terrat_github_evaluator3.S.Account.make ~installation_id () in - let user = Terrat_github_evaluator3.S.User.make sender.Gw.User.login in + let account = Terrat_vcs_github.S.Account.make ~installation_id () in + let user = Terrat_vcs_github.S.User.make sender.Gw.User.login in let repo = - Terrat_github_evaluator3.S.Repo.make + Terrat_vcs_github.S.Repo.make ~id:repository.Gw.Repository.id ~name:repository.Gw.Repository.name ~owner:repository.Gw.Repository.owner.Gw.User.login @@ -312,10 +312,10 @@ struct repository.Gw.Repository.owner.Gw.User.login repository.Gw.Repository.name sender.Gw.User.login); - let account = Terrat_github_evaluator3.S.Account.make ~installation_id () in - let user = Terrat_github_evaluator3.S.User.make sender.Gw.User.login in + let account = Terrat_vcs_github.S.Account.make ~installation_id () in + let user = Terrat_vcs_github.S.User.make sender.Gw.User.login in let repo = - Terrat_github_evaluator3.S.Repo.make + Terrat_vcs_github.S.Repo.make ~id:repository.Gw.Repository.id ~name:repository.Gw.Repository.name ~owner:repository.Gw.Repository.owner.Gw.User.login @@ -347,10 +347,10 @@ struct repository.Gw.Repository.owner.Gw.User.login repository.Gw.Repository.name sender.Gw.User.login); - let account = Terrat_github_evaluator3.S.Account.make ~installation_id () in - let user = Terrat_github_evaluator3.S.User.make sender.Gw.User.login in + let account = Terrat_vcs_github.S.Account.make ~installation_id () in + let user = Terrat_vcs_github.S.User.make sender.Gw.User.login in let repo = - Terrat_github_evaluator3.S.Repo.make + Terrat_vcs_github.S.Repo.make ~id:repository.Gw.Repository.id ~name:repository.Gw.Repository.name ~owner:repository.Gw.Repository.owner.Gw.User.login @@ -387,10 +387,10 @@ struct repository.Gw.Repository.owner.Gw.User.login repository.Gw.Repository.name sender.Gw.User.login); - let account = Terrat_github_evaluator3.S.Account.make ~installation_id () in - let user = Terrat_github_evaluator3.S.User.make sender.Gw.User.login in + let account = Terrat_vcs_github.S.Account.make ~installation_id () in + let user = Terrat_vcs_github.S.User.make sender.Gw.User.login in let repo = - Terrat_github_evaluator3.S.Repo.make + Terrat_vcs_github.S.Repo.make ~id:repository.Gw.Repository.id ~name:repository.Gw.Repository.name ~owner:repository.Gw.Repository.owner.Gw.User.login @@ -479,10 +479,10 @@ struct sender.Gw.User.login); match Terrat_comment.parse comment_body with | Ok comment -> - let account = Terrat_github_evaluator3.S.Account.make ~installation_id () in - let user = Terrat_github_evaluator3.S.User.make sender.Gw.User.login in + let account = Terrat_vcs_github.S.Account.make ~installation_id () in + let user = Terrat_vcs_github.S.User.make sender.Gw.User.login in let repo = - Terrat_github_evaluator3.S.Repo.make + Terrat_vcs_github.S.Repo.make ~id:repository.Gw.Repository.id ~name:repository.Gw.Repository.name ~owner:repository.Gw.Repository.owner.Gw.User.login @@ -599,15 +599,15 @@ struct match event.Gw.Push_event.installation with | Some installation_lite when CCString.equal ref_ default_ref -> let installation_id = installation_lite.Gw.Installation_lite.id in - let account = Terrat_github_evaluator3.S.Account.make ~installation_id () in + let account = Terrat_vcs_github.S.Account.make ~installation_id () in let repo = - Terrat_github_evaluator3.S.Repo.make + Terrat_vcs_github.S.Repo.make ~id:repository.Gw.Repository.id ~name:repository.Gw.Repository.name ~owner:repository.Gw.Repository.owner.Gw.User.login () in - let user = Terrat_github_evaluator3.S.User.make event.Gw.Push_event.sender.Gw.User.login in + let user = Terrat_vcs_github.S.User.make event.Gw.Push_event.sender.Gw.User.login in Github_evaluator.run_push ~ctx:(Terrat_vcs_provider.Ctx.make ~request_id ~config ~storage ()) ~account diff --git a/code/src/terrat_vcs_github/terrat_vcs_github_ep_events3.mli b/code/src/terrat_vcs_github/terrat_vcs_github_ep_events3.mli new file mode 100644 index 000000000..39cdbda83 --- /dev/null +++ b/code/src/terrat_vcs_github/terrat_vcs_github_ep_events3.mli @@ -0,0 +1,10 @@ +module Make + (Terratc : + Terratc_intf.S + with type Github.Client.t = Terrat_vcs_github.S.Client.t + and type Github.Account.t = Terrat_vcs_github.S.Account.t + and type Github.Repo.t = Terrat_vcs_github.S.Repo.t + and type Github.Remote_repo.t = Terrat_vcs_github.S.Remote_repo.t + and type Github.Ref.t = Terrat_vcs_github.S.Ref.t) : sig + val post : Terrat_config.t -> Terrat_storage.t -> Brtl_rtng.Handler.t +end diff --git a/code/src/terrat/terrat_ep_github_work_manifest3.ml b/code/src/terrat_vcs_github/terrat_vcs_github_ep_work_manifest.ml similarity index 96% rename from code/src/terrat/terrat_ep_github_work_manifest3.ml rename to code/src/terrat_vcs_github/terrat_vcs_github_ep_work_manifest.ml index 30a6d6fa1..bfca43e71 100644 --- a/code/src/terrat/terrat_ep_github_work_manifest3.ml +++ b/code/src/terrat_vcs_github/terrat_vcs_github_ep_work_manifest.ml @@ -1,13 +1,13 @@ module Make (Terratc : Terratc_intf.S - with type Github.Client.t = Terrat_github_evaluator3.S.Client.t - and type Github.Account.t = Terrat_github_evaluator3.S.Account.t - and type Github.Repo.t = Terrat_github_evaluator3.S.Repo.t - and type Github.Remote_repo.t = Terrat_github_evaluator3.S.Remote_repo.t - and type Github.Ref.t = Terrat_github_evaluator3.S.Ref.t) = + with type Github.Client.t = Terrat_vcs_github.S.Client.t + and type Github.Account.t = Terrat_vcs_github.S.Account.t + and type Github.Repo.t = Terrat_vcs_github.S.Repo.t + and type Github.Remote_repo.t = Terrat_vcs_github.S.Remote_repo.t + and type Github.Ref.t = Terrat_vcs_github.S.Ref.t) = struct - module Github_evaluator = Terrat_github_evaluator3.Make (Terratc) + module Github_evaluator = Terrat_vcs_github.Make (Terratc) let response_headers = Cohttp.Header.of_list [ ("content-type", "application/json") ] diff --git a/code/src/terrat/terrat_ep_github_work_manifest3.mli b/code/src/terrat_vcs_github/terrat_vcs_github_ep_work_manifest.mli similarity index 65% rename from code/src/terrat/terrat_ep_github_work_manifest3.mli rename to code/src/terrat_vcs_github/terrat_vcs_github_ep_work_manifest.mli index adbe568b0..3c208eea8 100644 --- a/code/src/terrat/terrat_ep_github_work_manifest3.mli +++ b/code/src/terrat_vcs_github/terrat_vcs_github_ep_work_manifest.mli @@ -1,10 +1,11 @@ module Make - (Terratc : Terratc_intf.S - with type Github.Client.t = Terrat_github_evaluator3.S.Client.t - and type Github.Account.t = Terrat_github_evaluator3.S.Account.t - and type Github.Repo.t = Terrat_github_evaluator3.S.Repo.t - and type Github.Remote_repo.t = Terrat_github_evaluator3.S.Remote_repo.t - and type Github.Ref.t = Terrat_github_evaluator3.S.Ref.t) : sig + (Terratc : + Terratc_intf.S + with type Github.Client.t = Terrat_vcs_github.S.Client.t + and type Github.Account.t = Terrat_vcs_github.S.Account.t + and type Github.Repo.t = Terrat_vcs_github.S.Repo.t + and type Github.Remote_repo.t = Terrat_vcs_github.S.Remote_repo.t + and type Github.Ref.t = Terrat_vcs_github.S.Ref.t) : sig module Initiate : sig val post : Terrat_config.t -> diff --git a/code/src/terrat/terrat_github_installation.ml b/code/src/terrat_vcs_github/terrat_vcs_github_installation.ml similarity index 100% rename from code/src/terrat/terrat_github_installation.ml rename to code/src/terrat_vcs_github/terrat_vcs_github_installation.ml diff --git a/code/src/terrat/terrat_github_installation.mli b/code/src/terrat_vcs_github/terrat_vcs_github_installation.mli similarity index 100% rename from code/src/terrat/terrat_github_installation.mli rename to code/src/terrat_vcs_github/terrat_vcs_github_installation.mli diff --git a/code/src/terrat/terrat_github_user.ml b/code/src/terrat_vcs_github/terrat_vcs_github_user.ml similarity index 100% rename from code/src/terrat/terrat_github_user.ml rename to code/src/terrat_vcs_github/terrat_vcs_github_user.ml diff --git a/code/src/terrat/terrat_github_user.mli b/code/src/terrat_vcs_github/terrat_vcs_github_user.mli similarity index 100% rename from code/src/terrat/terrat_github_user.mli rename to code/src/terrat_vcs_github/terrat_vcs_github_user.mli diff --git a/code/src/terrat_vcs_provider/terrat_vcs_provider.ml b/code/src/terrat_vcs_provider/terrat_vcs_provider.ml index 52376a678..904630ed8 100644 --- a/code/src/terrat_vcs_provider/terrat_vcs_provider.ml +++ b/code/src/terrat_vcs_provider/terrat_vcs_provider.ml @@ -136,6 +136,10 @@ end module type S = sig module Db = Pgsql_io + module Routes : sig + val get : (Brtl_rtng.Method.t * Brtl_rtng.Handler.t Brtl_rtng.Route.Route.t) list + end + module User : sig type t [@@deriving yojson] diff --git a/code/src/terrat_vcs_provider/terrat_vcs_provider.mli b/code/src/terrat_vcs_provider/terrat_vcs_provider.mli index b806bb06e..d1d31a983 100644 --- a/code/src/terrat_vcs_provider/terrat_vcs_provider.mli +++ b/code/src/terrat_vcs_provider/terrat_vcs_provider.mli @@ -130,6 +130,10 @@ end module type S = sig module Db = Pgsql_io + module Routes : sig + val get : (Brtl_rtng.Method.t * Brtl_rtng.Handler.t Brtl_rtng.Route.Route.t) list + end + module User : sig type t [@@deriving yojson] From af09017cf689467f356a305a39831c097bb79a5c Mon Sep 17 00:00:00 2001 From: Malcolm Date: Tue, 11 Feb 2025 13:36:19 +0100 Subject: [PATCH 2/2] #150 UPDATE Base image --- config/base_image_config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/base_image_config.sh b/config/base_image_config.sh index 3170da931..6e03742a5 100644 --- a/config/base_image_config.sh +++ b/config/base_image_config.sh @@ -1,5 +1,5 @@ : "${CONTAINER_REGISTRY:=ghcr.io}" : "${GITHUB_REPOSITORY_OWNER:=terrateamio}" : "${BASE_IMAGE_NAME:=terrat-base}" -BASE_IMAGE_TAG="20250210-1333-5567914" +BASE_IMAGE_TAG="20250211-1016-95b2442" BASE_IMAGE="${CONTAINER_REGISTRY}/${GITHUB_REPOSITORY_OWNER}/${BASE_IMAGE_NAME}:${BASE_IMAGE_TAG}"