diff --git a/Dockerfile.gitlab b/Dockerfile.gitlab deleted file mode 100644 index 2eca6715..00000000 --- a/Dockerfile.gitlab +++ /dev/null @@ -1,45 +0,0 @@ -# syntax=docker/dockerfile:1 -FROM ocaml/opam:debian-13-ocaml-4.14 AS build -RUN sudo ln -sf /usr/bin/opam-2.5 /usr/bin/opam && opam init --reinit -ni -RUN sudo rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' | sudo tee /etc/apt/apt.conf.d/keep-cache -RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ - --mount=type=cache,target=/var/lib/apt,sharing=locked \ - sudo apt update && sudo apt-get --no-install-recommends install -y \ - capnproto \ - graphviz \ - libev-dev \ - libgmp-dev \ - libsqlite3-dev \ - m4 \ - pkg-config -RUN cd ~/opam-repository && git fetch -q origin master && git reset --hard 94c943996066236b7203cad4027522be61e33f45 && opam update -COPY --chown=opam --link ocaml-ci.opam ocaml-ci-gitlab.opam ocaml-ci-service.opam ocaml-ci-api.opam /src/ -WORKDIR /src -ENV OPAMSOLVERTIMEOUT=900 -RUN --mount=type=cache,target=/home/opam/.opam/download-cache,sharing=locked,uid=1000,gid=1000 \ - opam install -y --deps-only . -ADD --chown=opam . . -RUN opam exec -- dune build ./_build/install/default/bin/ocaml-ci-gitlab - -FROM debian:13 -RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache -RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ - --mount=type=cache,target=/var/lib/apt,sharing=locked \ - apt update && apt-get --no-install-recommends install -y \ - ca-certificates \ - curl \ - docker-cli \ - dumb-init \ - git \ - graphviz \ - libev4 \ - libsqlite3-dev \ - netbase \ - openssh-client -WORKDIR /var/lib/ocurrent -ENTRYPOINT ["dumb-init", "/usr/local/bin/ocaml-ci-gitlab"] -ENV OCAMLRUNPARAM=a=2 -# Enable experimental for docker manifest support -ENV DOCKER_CLI_EXPERIMENTAL=enabled -COPY --from=build --link /src/_build/install/default/bin/ocaml-ci-gitlab /usr/local/bin/ -COPY --from=build --link /src/migrations /migrations diff --git a/Dockerfile.web b/Dockerfile.web index c38b6cc1..b7240807 100644 --- a/Dockerfile.web +++ b/Dockerfile.web @@ -41,9 +41,6 @@ COPY --from=build --link /src/_build/install/default/bin/ocaml-ci-web /usr/local ## Load profile-pictures of registered organisations RUN mkdir -p /profile-pictures/github -RUN mkdir -p /profile-pictures/gitlab COPY --from=build --link /src/bin/add-profile-picture /usr/local/bin COPY --from=build --link /src/deploy-data/github-organisations.txt /github-organisations.txt -COPY --from=build --link /src/deploy-data/gitlab-organisations.txt /gitlab-organisations.txt RUN xargs -n 1 /usr/local/bin/add-profile-picture --github < /github-organisations.txt -RUN xargs -n 1 /usr/local/bin/add-profile-picture --gitlab < /gitlab-organisations.txt diff --git a/README.md b/README.md index 97ea021f..b065b33f 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,6 @@ If you want to build the whole system, the easiest way is using Docker: ```sh docker build -f Dockerfile -t ocaml-ci-service . -docker build -f Dockerfile.gitlab -t ocaml-ci-gitlab . docker build -f Dockerfile.web -t ocaml-ci-web . ``` @@ -136,7 +135,7 @@ $ ocaml-ci mirage/irmin pull/867 alpine-3.10-ocaml-4.08 cancel ## Deployment -`ocaml-ci` is deployed as three docker images built from `Dockerfile`, `Dockerfile.gitlab` and `Dockerfile.web`, with +`ocaml-ci` is deployed as two docker images built from `Dockerfile` and `Dockerfile.web`, with the live service following `live-engine` for the backend and `live-www` for the frontend. An ocurrent-deployer [pipeline](deploy.ci.dev) watches these branches, performing a docker build and deploy whenever it sees a new commit. The live branches should typically contain commits from `master` plus potentially diff --git a/bin/add-profile-picture b/bin/add-profile-picture index f65c8b47..ffe377d9 100755 --- a/bin/add-profile-picture +++ b/bin/add-profile-picture @@ -2,13 +2,11 @@ usage() { cat >&2 <&2 "Unknown flag: $1" usage @@ -40,15 +34,9 @@ if [ $# -ne 1 ]; then usage fi -PROFILE_PICTURE_URL="" ORGANISATION_NAME=$1 PROFILE_PICTURE_PATH="/profile-pictures/$GITFORGE/$ORGANISATION_NAME.png" - -if [ "$GITFORGE" = "github" ]; then - PROFILE_PICTURE_URL="https://github.com/$ORGANISATION_NAME.png?size=200" -else - PROFILE_PICTURE_URL="$(curl -X GET https://gitlab.com/api/v4/users\?username="$ORGANISATION_NAME" | jq '.[] | .avatar_url' | sed 's/"//g')" >/dev/null -fi +PROFILE_PICTURE_URL="https://github.com/$ORGANISATION_NAME.png?size=200" if [ "$PROFILE_PICTURE_URL" = "" ]; then echo "ERROR: Profile picture lookup for $ORGANISATION_NAME" diff --git a/deploy-data/gitlab-organisations.txt b/deploy-data/gitlab-organisations.txt deleted file mode 100644 index ae4c9df0..00000000 --- a/deploy-data/gitlab-organisations.txt +++ /dev/null @@ -1,5 +0,0 @@ -talex5 -tmcgilchrist -nomadic-labs -maiste -raphael-proust diff --git a/doc/gitlab-dev.md b/doc/gitlab-dev.md deleted file mode 100644 index d364be2d..00000000 --- a/doc/gitlab-dev.md +++ /dev/null @@ -1,18 +0,0 @@ -## Running the GitLab pipeline locally - -You will need the following: - -1. The GitLab API token with permissions to the repositories to build -2. GitLab secret associated with webhooks -3. A capability file for submitting jobs to a cluster, in this case the main ocaml-ci cluster as documented in https://github.com/ocurrent/ocluster#admin - -``` shell -dune exec -- ocaml-ci-gitlab \ - --gitlab-token-file \ - --gitlab-webhook-secret-file \ - --submission-service \ - --capnp-listen-address tcp:127.0.0.1:9800 - --migration-path "$PWD/migrations" -``` - -This will generate a capability file. See the logs for `Wrote capability reference to "./capnp-secrets/ocaml-ci-gitlab-admin.cap"` diff --git a/dune-project b/dune-project index 70a6638c..f05d5589 100644 --- a/dune-project +++ b/dune-project @@ -87,27 +87,6 @@ (prometheus-app (>= 1.2)) (timedesc (>= 0.9.0)))) -(package - (name ocaml-ci-gitlab) - (synopsis "Test OCaml projects on GitLab") - (description "Test OCaml projects on GitLab") - (depends - (ocaml (>= 4.14)) - dune - ocaml-ci - ocaml-ci-service - current - current_git - current_gitlab - current_docker - (alcotest (and (>= 1.7.0) :with-test)) - (cmdliner (>= 1.1.1)) - (fmt (>= 0.8.9)) - (gitlab-unix (>= 0.1.8)) - (logs (>= 0.7.0)) - (odoc :with-doc) - (prometheus-app (>= 1.2)))) - (package (name ocaml-ci-client) (synopsis "Command-line client for ocaml-ci") diff --git a/gitlab/dune b/gitlab/dune deleted file mode 100644 index b46de4e1..00000000 --- a/gitlab/dune +++ /dev/null @@ -1,72 +0,0 @@ -(library - (name ocaml_ci_gitlab) - (public_name ocaml-ci-gitlab) - (libraries - ocaml-ci - ocaml-ci-service - current - current_git - current_github - current_gitlab - current_docker - current_web - gitlab-unix - prometheus-app.unix - cmdliner) - (modules pipeline gitlab)) - -(executables - (names main local) - (libraries - logs.fmt - logs.cli - fmt.tty - fmt.cli - current - current_web - current_docker - current_git - current_github - current_gitlab - current_rpc - dockerfile-opam - ocluster-api - capnp-rpc-unix - mirage-crypto-rng.unix - ocaml-ci - ocaml-ci-api - ocaml_ci_service - ocaml_ci_gitlab - prometheus-app.unix) - (modules main local)) - -; This is a hack to work around https://github.com/ocaml/dune/issues/3499 -; We first build the binaries, then copy them to a new name, then install them. -; This allows us to add in the run-time dependency on solver-service in the -; copy step. - -(install - (section bin) - (package ocaml-ci-gitlab) - (files - (main-copy.exe as ocaml-ci-gitlab))) - -(install - (section bin) - (package ocaml-ci-gitlab) - (files - (local-copy.exe as ocaml-ci-gitlab-local))) - -(rule - (target main-copy.exe) - (deps - (package solver-service)) - (action - (copy main.exe main-copy.exe))) - -(rule - (target local-copy.exe) - (deps - (package solver-service)) - (action - (copy local.exe local-copy.exe))) diff --git a/gitlab/gitlab.ml b/gitlab/gitlab.ml deleted file mode 100644 index 504630e2..00000000 --- a/gitlab/gitlab.ml +++ /dev/null @@ -1,17 +0,0 @@ -(* Access control policy. *) -let has_role user = function - | `Viewer | `Monitor -> true - | `Builder | `Admin -> ( - match Option.map Current_web.User.id user with - | Some "gitlab:tmcgilchrist" -> true - | Some _ | None -> false) - -let webhook_route ~webhook_secret = - Routes.( - (s "webhooks" / s "gitlab" /? nil) - @--> Current_gitlab.webhook ~webhook_secret) - -let login_route gitlab_auth = - Routes.((s "login" /? nil) @--> Current_gitlab.Auth.login gitlab_auth) - -let authn auth = Option.map Current_gitlab.Auth.make_login_uri auth diff --git a/gitlab/local.ml b/gitlab/local.ml deleted file mode 100644 index 27a5fb9d..00000000 --- a/gitlab/local.ml +++ /dev/null @@ -1,51 +0,0 @@ -(* Utility program for testing the CI pipeline on a local repository. *) - -let setup_log default_level = - Unix.putenv "DOCKER_BUILDKIT" "1"; - Unix.putenv "PROGRESS_NO_TRUNC" "1"; - Prometheus_unix.Logging.init ?default_level () - -let main () config mode repo : ('a, [ `Msg of string ]) result = - let solver = Ocaml_ci.Backend_solver.v None in - let repo = Current_git.Local.v (Fpath.v repo) in - let engine = - Current.Engine.create ~config - (Ocaml_ci_gitlab.Pipeline.local_test ~query_uri:None ~solver repo) - in - let site = - Current_web.Site.(v ~has_role:allow_all) - ~name:"ocaml-ci-local" - (Current_web.routes engine) - in - Lwt_main.run - (Lwt.choose [ Current.Engine.thread engine; Current_web.run ~mode site ]) - -(* Command-line parsing *) - -open Cmdliner - -let setup_log = - let docs = Manpage.s_common_options in - Term.(const setup_log $ Logs_cli.level ~docs ()) - -let repo = - Arg.required - @@ Arg.pos 0 Arg.(some dir) None - @@ Arg.info ~doc:"The directory containing the .git subdirectory." ~docv:"DIR" - [] - -let cmd = - let doc = "Test ocaml-ci on a local Git clone" in - let info = - Cmd.info "ocaml-ci-local" ~doc ~envs:Ocaml_ci_service.Conf.cmdliner_envs - in - Cmd.v info - Term.( - term_result - (const main - $ setup_log - $ Current.Config.cmdliner - $ Current_web.cmdliner - $ repo)) - -let () = exit @@ Cmd.eval cmd diff --git a/gitlab/main.ml b/gitlab/main.ml deleted file mode 100644 index 0f6442f4..00000000 --- a/gitlab/main.ml +++ /dev/null @@ -1,233 +0,0 @@ -open Lwt.Infix -open Capnp_rpc_lwt - -module Metrics = struct - open Prometheus - open Ocaml_ci - - let namespace = "ocamlci" - let subsystem = "gitlab_pipeline" - - let master = - let help = "Number of master branches by state" in - Gauge.v_label ~label_name:"state" ~help ~namespace ~subsystem - "master_state_total" - - type stats = { ok : int; failed : int; active : int } - - let count_repo ~owner name (acc : stats) = - let repo = { Repo_id.owner; name } in - match - Index.Ref_map.find_opt "refs/heads/master" (Index.get_active_refs repo) - with - | None -> acc - | Some { Index.hash; _ } -> ( - match Index.Commit_cache.(find ~owner ~name ~hash |> get_status) with - | `Failed -> { acc with failed = acc.failed + 1 } - | `Passed -> { acc with ok = acc.ok + 1 } - | `Not_started | `Pending -> { acc with active = acc.active + 1 }) - - let count_owner owner (acc : stats) = - Index.Repo_set.fold (count_repo ~owner) (Index.get_active_repos ~owner) acc - - let update () = - let owners = Index.get_active_owners () in - let { ok; failed; active } = - Index.Owner_set.fold count_owner owners { ok = 0; failed = 0; active = 0 } - in - Gauge.set (master "ok") (float_of_int ok); - Gauge.set (master "failed") (float_of_int failed); - Gauge.set (master "active") (float_of_int active) -end - -(* TODO Isolate gitlab specific configuration from general service config. *) -module Conf = Ocaml_ci_service.Conf - -let setup_log default_level = - Prometheus_unix.Logging.init ?default_level (); - Mirage_crypto_rng_unix.initialize (module Mirage_crypto_rng.Fortuna); - Prometheus.CollectorRegistry.(register_pre_collect default) Metrics.update; - (match Conf.capnp_profile with - | `Production -> Logs.info (fun f -> f "Using production capnp configuration") - | `Dev -> Logs.info (fun f -> f "Using dev capnp configuration")); - match Conf.platforms_profile with - | `All -> Logs.info (fun f -> f "Testing all platforms") - | `Minimal -> Logs.info (fun f -> f "Testing minimal platforms") - -let or_die = function Ok x -> x | Error (`Msg m) -> failwith m - -let check_dir x = - Lwt.catch - (fun () -> - Lwt_unix.stat x >|= function - | Unix.{ st_kind = S_DIR; _ } -> `Present - | _ -> Fmt.failwith "Exists, but is not a directory: %S" x) - (function - | Unix.Unix_error (Unix.ENOENT, _, _) -> Lwt.return `Missing - | exn -> Lwt.fail exn) - -let ensure_dir path = - check_dir path >>= function - | `Present -> Lwt.return_unit - | `Missing -> Lwt_unix.mkdir path 0o777 - -let run_capnp capnp_public_address capnp_listen_address = - match (capnp_public_address, capnp_listen_address) with - | None, None -> Lwt.return (Capnp_rpc_unix.client_only_vat (), None) - | Some _, None -> - Lwt.fail_invalid_arg - "Public address for Cap'n Proto RPC can't be set without setting a \ - capnp-listen-address to listen on." - | Some _, Some _ | None, Some _ -> - let listen_address = - match capnp_listen_address with - | Some listen_address -> listen_address - | None -> - Capnp_rpc_unix.Network.Location.tcp ~host:"0.0.0.0" - ~port:Conf.Capnp.internal_port - in - let public_address = - match capnp_public_address with - | None -> listen_address - | Some public_address -> public_address - in - ensure_dir Conf.Capnp.cap_secrets >>= fun () -> - let config = - Capnp_rpc_unix.Vat_config.create ~public_address - ~secret_key:(`File Conf.Capnp.secret_key) listen_address - in - let rpc_engine, rpc_engine_resolver = Capability.promise () in - let service_id = Capnp_rpc_unix.Vat_config.derived_id config "ci" in - let restore = Capnp_rpc_net.Restorer.single service_id rpc_engine in - Capnp_rpc_unix.serve config ~restore >>= fun vat -> - Capnp_rpc_unix.Cap_file.save_service vat service_id - (Conf.Capnp.cap_secrets ^ "/ocaml-ci-gitlab-admin.cap") - |> or_die; - Logs.app (fun f -> - f "Wrote capability reference to %S" Conf.Capnp.cap_file); - Lwt.return (vat, Some rpc_engine_resolver) - -let main () config mode app capnp_public_address capnp_listen_address - gitlab_auth submission_uri solver_uri query_uri migrations : - ('a, [ `Msg of string ]) result = - let open Ocaml_ci_gitlab in - Lwt_main.run - (let solver = Ocaml_ci.Backend_solver.v solver_uri in - run_capnp capnp_public_address capnp_listen_address - >>= fun (vat, rpc_engine_resolver) -> - let ocluster = - Option.map (Capnp_rpc_unix.Vat.import_exn vat) submission_uri - in - let engine = - Current.Engine.create ~config - (Pipeline.v ?ocluster ~app ~solver ~query_uri ~migrations) - in - rpc_engine_resolver - |> Option.iter (fun r -> - Capability.resolve_ok r (Ocaml_ci_service.Api_impl.make_ci ~engine)); - let authn = Gitlab.authn gitlab_auth in - let webhook_secret = Current_gitlab.Api.webhook_secret app in - let has_role = - if gitlab_auth = None then Current_web.Site.allow_all - else Gitlab.has_role - in - let secure_cookies = gitlab_auth <> None in - let routes = - Gitlab.webhook_route ~webhook_secret - :: Gitlab.login_route gitlab_auth - :: Current_web.routes engine - in - let site = - Current_web.Site.v ?authn ~has_role ~secure_cookies - ~name:"ocaml-ci-gitlab" routes - in - Lwt.choose [ Current.Engine.thread engine; Current_web.run ~mode site ]) - -(* Command-line parsing *) - -open Cmdliner - -let setup_log = - let docs = Manpage.s_common_options in - Term.(const setup_log $ Logs_cli.level ~docs ()) - -let capnp_public_address = - Arg.value - @@ Arg.opt (Arg.some Capnp_rpc_unix.Network.Location.cmdliner_conv) None - @@ Arg.info - ~doc: - "Public address (SCHEME:HOST:PORT) for Cap'n Proto RPC (default: no \ - RPC).\n\ - \ If --capnp-listen-address isn't set it will run no RPC." - ~docv:"ADDR" [ "capnp-public-address" ] - -let capnp_listen_address = - let i = - Arg.info ~docv:"ADDR" - ~doc: - "Address to listen on, e.g. $(b,unix:/run/my.socket) (default: no RPC)." - [ "capnp-listen-address" ] - in - Arg.( - value - @@ opt (Arg.some Capnp_rpc_unix.Network.Location.cmdliner_conv) None - @@ i) - -let submission_service = - Arg.value - @@ Arg.opt Arg.(some Capnp_rpc_unix.sturdy_uri) None - @@ Arg.info ~doc:"The submission.cap file for the build scheduler service" - ~docv:"FILE" [ "submission-service" ] - -let migrations = - Arg.( - value - @@ opt (some dir) None - @@ info ~docv:"MIGRATIONS_PATH" - ~doc: - "Specify the path to the migration directory. If no path is given \ - the migration step is ignored." - [ "migration-path" ]) - -let submission_solver_service = - Arg.value - @@ Arg.opt Arg.(some Capnp_rpc_unix.sturdy_uri) None - @@ Arg.info - ~doc: - "The submission-solve.cap file for a scheduler service which handles \ - a solver-worker. The cap file could be the same as \ - $(b,--submission-service)." - ~docv:"FILE" - [ "submission-solver-service" ] - -let submission_query_service = - Arg.value - @@ Arg.opt Arg.(some Capnp_rpc_unix.sturdy_uri) None - @@ Arg.info - ~doc: - "The query-solve.cap file which handles building opam variables for \ - various platforms. The cap file could be the same as \ - $(b,--submission-service) or omitted to use the local system." - ~docv:"FILE" - [ "submission-query-service" ] - -let cmd = - let doc = "Build OCaml projects on GitLab" in - let info = Cmd.info "ocaml-ci-gitlab" ~doc in - Cmd.v info - Term.( - term_result - (const main - $ setup_log - $ Current.Config.cmdliner - $ Current_web.cmdliner - $ Current_gitlab.Api.cmdliner - $ capnp_public_address - $ capnp_listen_address - $ Current_gitlab.Auth.cmdliner - $ submission_service - $ submission_solver_service - $ submission_query_service - $ migrations)) - -let () = exit @@ Cmd.eval cmd diff --git a/gitlab/pipeline.ml b/gitlab/pipeline.ml deleted file mode 100644 index 8adfea6c..00000000 --- a/gitlab/pipeline.ml +++ /dev/null @@ -1,299 +0,0 @@ -open Current.Syntax -open Ocaml_ci -open Pipeline -module Conf = Ocaml_ci_service.Conf -module Git = Current_git -module Gitlab = Current_gitlab -module Docker = Current_docker.Default - -module Metrics = struct - open Prometheus - - let namespace = "ocurrent" - let subsystem = "gitlab" - - let repositories_total = - let help = "Total number of active repositories" in - Gauge.v_label ~label_name:"account" ~help ~namespace ~subsystem - "repositories_total" -end - -let program_name = "ocaml-ci" - -(* Link for GitLab statuses. *) -let url ~owner ~name ~hash = - Uri.of_string - (Printf.sprintf "%s/gitlab/%s/%s/commit/%s" Conf.website_scheme_and_domain - owner name hash) - -(* Watch the opam-repository for changes. *) -let opam_repository_commit = - let module Github = Current_github in - let repo = { Github.Repo_id.owner = "ocaml"; name = "opam-repository" } in - Github.Api.Anonymous.head_of repo @@ `Ref "refs/heads/master" - -(* TODO Sometime later, grab these from Index/DB table. *) -let gitlab_repos : Gitlab.Repo_id.t list = - [ - { - Gitlab.Repo_id.owner = "tmcgilchrist"; - Gitlab.Repo_id.name = "ocaml-gitlab"; - project_id = 29798678; - }; - { - Gitlab.Repo_id.owner = "talex5"; - Gitlab.Repo_id.name = "gemini-eio"; - project_id = 28169706; - }; - { - Gitlab.Repo_id.owner = "nomadic-labs"; - Gitlab.Repo_id.name = "resto"; - project_id = 16269987; - }; - { - Gitlab.Repo_id.owner = "nomadic-labs"; - Gitlab.Repo_id.name = "data-encoding"; - project_id = 14134943; - }; - { - Gitlab.Repo_id.owner = "nomadic-labs"; - Gitlab.Repo_id.name = "ringo"; - project_id = 15200071; - }; - { - Gitlab.Repo_id.owner = "nomadic-labs"; - Gitlab.Repo_id.name = "ocaml-secp256k1-internal"; - project_id = 17524462; - }; - { - Gitlab.Repo_id.owner = "nomadic-labs"; - Gitlab.Repo_id.name = "lwt-exit"; - project_id = 22943026; - }; - { - Gitlab.Repo_id.owner = "nomadic-labs"; - Gitlab.Repo_id.name = "lwt-watcher"; - project_id = 14672501; - }; - { - Gitlab.Repo_id.owner = "nomadic-labs"; - Gitlab.Repo_id.name = "lwt-canceler"; - project_id = 14702762; - }; - { - Gitlab.Repo_id.owner = "nomadic-labs"; - Gitlab.Repo_id.name = "ctypes_stubs_js"; - project_id = 31956063; - }; - { - Gitlab.Repo_id.owner = "nomadic-labs"; - Gitlab.Repo_id.name = "seqes"; - project_id = 41118330; - }; - { - Gitlab.Repo_id.owner = "nomadic-labs"; - Gitlab.Repo_id.name = "tezt"; - project_id = 41852995; - }; - { - Gitlab.Repo_id.owner = "raphael-proust"; - Gitlab.Repo_id.name = "queenshead"; - project_id = 50742201; - }; - { - Gitlab.Repo_id.owner = "raphael-proust"; - Gitlab.Repo_id.name = "entombed"; - project_id = 30307357; - }; - ] - -(* Fake Installation module, we don't have this in GitLab. *) -module Installation = struct - type t = { name : string } - - let compare = compare - let pp f t = Fmt.string f t.name -end - -let gitlab_installations = - gitlab_repos - |> List.map (fun x -> { Installation.name = x.Gitlab.Repo_id.owner }) - |> List.sort_uniq Installation.compare - -let set_active_installations (accounts : Installation.t list Current.t) = - let+ accounts in - accounts - |> List.fold_left - (fun acc i -> Index.Owner_set.add i.Installation.name acc) - Index.Owner_set.empty - |> Index.set_active_owners; - accounts - -let set_active_repos ~installation repos = - let+ repos and+ installation in - repos - |> List.fold_left - (fun acc r -> Index.Repo_set.add r.Gitlab.Repo_id.name acc) - Index.Repo_set.empty - |> Index.set_active_repos ~owner:installation.Installation.name; - Prometheus.Gauge.set - (Metrics.repositories_total installation.Installation.name) - (float_of_int (List.length repos)); - repos - -let gref_from_commit x = Git.Commit_id.gref @@ Gitlab.Api.Commit.id x - -let ref_name c = - match (Gitlab.Api.Commit.branch_name c, Gitlab.Api.Commit.mr_name c) with - | Some name, None | None, Some name -> name - | _ -> failwith "Commit is neither a branch nor a MR" - -let set_active_refs ~(repo : Gitlab.Repo_id.t Current.t) ~default commits = - let+ repo and+ commits and+ default in - let repo = { Repo_id.owner = repo.owner; name = repo.name } in - let refs = - commits - |> List.fold_left - (fun acc commit -> - let commit_id = Gitlab.Api.Commit.id commit in - let gref = Git.Commit_id.gref commit_id in - let hash = Git.Commit_id.hash commit_id in - let name = ref_name commit in - let message = Gitlab.Api.Commit.message commit in - Index.Ref_map.add gref { Index.hash; message; name } acc) - Index.Ref_map.empty - in - let default_gref = gref_from_commit default in - Index.set_active_refs ~repo refs default_gref; - commits - -let repositories (installation : Installation.t Current.t) = - let+ installation in - List.filter - (fun repo -> repo.Gitlab.Repo_id.owner == installation.name) - gitlab_repos - -let gitlab_status_of_state head result = - let+ head and+ result in - let { Gitlab.Repo_id.owner; name; project_id = _ } = - Gitlab.Api.Commit.repo_id head - in - let hash = Gitlab.Api.Commit.hash head in - let url = url ~owner ~name ~hash in - match result with - | Ok () -> - Gitlab.Api.Status.v ~url `Success ~description:"Passed" ~name:program_name - | Error (`Active _) -> Gitlab.Api.Status.v ~url `Pending ~name:program_name - | Error (`Msg m) when Astring.String.is_prefix ~affix:"[SKIP]" m -> - Gitlab.Api.Status.v ~url `Success ~description:m ~name:program_name - | Error (`Msg m) -> - Gitlab.Api.Status.v ~url `Failure ~description:m ~name:program_name - -let local_test ~query_uri ~solver repo () = - let platforms = - Conf.fetch_platforms ~query_uri ~include_macos:false ~include_freebsd:false - ~include_windows:false ~include_openbsd:false () - in - let src = Git.Local.head_commit repo in - let src_content = Repo_content.extract src in - let repo = Current.return { Repo_id.owner = "local"; name = "test" } - and analysis = - Analyse.examine ~solver ~platforms ~opam_repository_commit src src_content - in - Current.component "summarise" - |> let> results = build_with_docker ~repo ~analysis ~platforms src in - let result = summarise results in - Current_incr.const (result, None) - -let v ?ocluster ~app ~query_uri ~solver ~migrations () = - let platforms = - Conf.fetch_platforms ~query_uri ~include_macos:true ~include_freebsd:true - ~include_windows:true ~include_openbsd:true () - in - let ocluster = - Option.map (Cluster_build.config ~timeout:(Duration.of_hour 1)) ocluster - in - let migrations = - match migrations with - | Some path -> Index.migrate path - | None -> Current.return () - in - Current.with_context migrations @@ fun () -> - Current.with_context opam_repository_commit @@ fun () -> - Current.with_context platforms @@ fun () -> - Current.return gitlab_installations - |> set_active_installations - |> Current.list_iter ~collapse_key:"org" (module Installation) - @@ fun installation -> - repositories installation - |> set_active_repos ~installation - |> Current.list_iter ~collapse_key:"repo" (module Gitlab.Repo_id) - @@ fun repo -> - let* repo_id = repo in - let default = Gitlab.Api.head_commit app repo_id in - let refs = - let refs = - Gitlab.Api.ci_refs app ~staleness:Conf.max_staleness repo_id - in - set_active_refs ~repo ~default refs - in - refs - |> Current.list_iter (module Gitlab.Api.Commit) @@ fun head -> - let src = Git.fetch (Current.map Gitlab.Api.Commit.id head) in - let src_content = Repo_content.extract src in - let analysis = - Analyse.examine ~solver ~platforms ~opam_repository_commit src - src_content - in - let* on_cancel = - match ocluster with - | None -> Current.return None - | Some _ -> - let+ commit = head in - let gref = Git.Commit_id.gref @@ Gitlab.Api.Commit.id commit in - let repo = Gitlab.Api.Commit.repo_id commit in - let repo = { Repo_id.owner = repo.owner; name = repo.name } in - let hash = Gitlab.Api.Commit.hash commit in - Some - (fun _ -> Index.record_summary_on_cancel ~repo ~gref ~hash) - in - let builds = - let repo = - Current.map - (fun repo -> - { - Repo_id.owner = repo.Gitlab.Repo_id.owner; - name = repo.name; - }) - repo - in - build_with_docker ?ocluster ?on_cancel ~repo ~analysis ~platforms - src - in - let summary = Current.map summarise builds in - let status = - let+ summary in - match summary with - | Ok () -> `Passed - | Error (`Active `Running) -> `Pending - | Error (`Msg _) -> `Failed - in - let index = - let+ commit = head and+ builds and+ status in - let gref = Git.Commit_id.gref @@ Gitlab.Api.Commit.id commit in - let repo = - Gitlab.Api.Commit.repo_id commit |> fun repo -> - { Repo_id.owner = repo.owner; name = repo.name } - in - let hash = Gitlab.Api.Commit.hash commit in - let jobs = - List.map - (fun (s, (_, job_id)) -> (s.Build_info.label, job_id)) - builds - in - Index.record ~repo ~hash ~status ~gref jobs - and set_gitlab_status = - gitlab_status_of_state head summary - |> Gitlab.Api.Commit.set_status head "ocaml-ci" - in - Current.all [ index; set_gitlab_status ] diff --git a/gitlab/pipeline.mli b/gitlab/pipeline.mli deleted file mode 100644 index c028b883..00000000 --- a/gitlab/pipeline.mli +++ /dev/null @@ -1,21 +0,0 @@ -(** Pipeline for testing GitLab hosted repositories. *) - -val local_test : - query_uri:Uri.t option -> - solver:Ocaml_ci.Backend_solver.t -> - Current_git.Local.t -> - unit -> - unit Current.t -(** [local_test ~solver repo] is a pipeline that tests local repository [repo] - as the GitLab CI pipeline would. *) - -val v : - ?ocluster:Cluster_api.Raw.Client.Submission.t Capnp_rpc_lwt.Sturdy_ref.t -> - app:Current_gitlab.Api.t -> - query_uri:Uri.t option -> - solver:Ocaml_ci.Backend_solver.t -> - migrations:string option -> - unit -> - unit Current.t -(** The main ocaml-ci pipeline for testing GitLab hosted repositories. If - [migration] is [Some path], it automatically executes the migrations.*) diff --git a/lib/build.mli b/lib/build.mli index d7a49ea1..efc66108 100644 --- a/lib/build.mli +++ b/lib/build.mli @@ -8,8 +8,7 @@ val v : ([> `Built | `Checked ] Current_term.Output.t * Current.job_id option) Current.t (** Build and test all the opam packages in a given build context on the given - platform. [~repo] is the ID of the repository-under-test on a Git Forge - (e.g. GitHub or GitLab). *) + platform. [~repo] is the ID of the repository-under-test on GitHub. *) val make_build_spec : base:Current_docker.Raw.Image.t -> diff --git a/lib/cluster_build.mli b/lib/cluster_build.mli index 51e501af..fdc64592 100644 --- a/lib/cluster_build.mli +++ b/lib/cluster_build.mli @@ -17,8 +17,7 @@ val v : ([> `Built | `Checked ] Current_term.Output.t * Current.job_id option) Current.t (** Build and test all the opam packages in a given build context on the given - platform. [~repo] is the ID of the repository-under-test on a Git Forge - (e.g. GitHub or GitLab). + platform. [~repo] is the ID of the repository-under-test on GitHub. @param on_cancel The callback function to call if the job is cancelled. @param repo The ID of the repository-under-test on GitHub. *) diff --git a/ocaml-ci-gitlab.opam b/ocaml-ci-gitlab.opam deleted file mode 100644 index 0d39ccb6..00000000 --- a/ocaml-ci-gitlab.opam +++ /dev/null @@ -1,43 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -synopsis: "Test OCaml projects on GitLab" -description: "Test OCaml projects on GitLab" -maintainer: ["Mark.Elvers "] -authors: ["talex5@gmail.com"] -license: "MIT" -homepage: "https://github.com/ocurrent/ocaml-ci" -doc: "https://ocaml.ci.dev/documentation" -bug-reports: "https://github.com/ocurrent/ocaml-ci/issues" -depends: [ - "ocaml" {>= "4.14"} - "dune" {>= "3.20"} - "ocaml-ci" - "ocaml-ci-service" - "current" - "current_git" - "current_gitlab" - "current_docker" - "alcotest" {>= "1.7.0" & with-test} - "cmdliner" {>= "1.1.1"} - "fmt" {>= "0.8.9"} - "gitlab-unix" {>= "0.1.8"} - "logs" {>= "0.7.0"} - "odoc" {with-doc} - "prometheus-app" {>= "1.2"} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] -dev-repo: "git+https://github.com/ocurrent/ocaml-ci.git" -x-maintenance-intent: ["(latest)"] diff --git a/stack.yml.in b/stack.yml.in index 2ee7b605..10604b1b 100644 --- a/stack.yml.in +++ b/stack.yml.in @@ -2,8 +2,6 @@ version: '3.1' volumes: data: capnp-secrets: - gitlab-data: - gitlab-capnp-secrets: secrets: ocaml-ci-github-key: @@ -14,12 +12,6 @@ secrets: external: true ocaml-ci-webhook-secret: external: true - ocaml-ci-gitlab-oauth: - external: true - ocaml-ci-gitlab-token: - external: true - ocaml-ci-gitlab-webhook-secret: - external: true ocaml-ci-solver-cap: external: true @@ -62,51 +54,14 @@ services: sysctls: - 'net.ipv4.tcp_keepalive_time=60' - gitlab: - image: ocurrent/ocaml-ci-gitlab-service:live - # image: ocaml-ci-gitlab-service - # For local deploys using docker -c ocaml.ci.dev build -t ocaml-ci-gitlab-service -f Dockerfile.gitlab . - command: > - --gitlab-oauth /run/secrets/ocaml-ci-gitlab-oauth - --gitlab-token-file /run/secrets/ocaml-ci-gitlab-token - --gitlab-webhook-secret-file /run/secrets/ocaml-ci-gitlab-webhook-secret - --submission-service /run/secrets/ocaml-ci-submission-cap - --submission-solver-service /run/secrets/ocaml-ci-solver-cap - --submission-query-service /run/secrets/ocaml-ci-submission-cap - --capnp-public-address=tcp:ocaml.ci.dev:8202 - --capnp-listen-address=tcp:0.0.0.0:9000 - --migration-path /migrations - --verbosity info - environment: - - "CAPNP_PROFILE=production" - - "PLATFORMS=all" - - "DOCKER_BUILDKIT=1" - - "PROGRESS_NO_TRUNC=1" - ports: - - '8202:9000' - volumes: - - 'gitlab-data:/var/lib/ocurrent' - - '/var/run/docker.sock:/var/run/docker.sock' - - 'gitlab-capnp-secrets:/capnp-secrets' - secrets: - - 'ocaml-ci-gitlab-oauth' - - 'ocaml-ci-gitlab-token' - - 'ocaml-ci-submission-cap' - - 'ocaml-ci-solver-cap' - - 'ocaml-ci-gitlab-webhook-secret' - sysctls: - - 'net.ipv4.tcp_keepalive_time=60' - web: image: ocurrent/ocaml-ci-web:live # image: ocaml-ci-web # For local deploys using docker -c ocaml.ci.dev build -t ocaml-ci-web -f Dockerfile.web . command: > --backend /capnp-secrets/ocaml-ci-admin.cap - --gitlab-backend /gitlab-capnp-secrets/ocaml-ci-gitlab-admin.cap --listen-prometheus=9090 volumes: - 'capnp-secrets:/capnp-secrets:ro' - - 'gitlab-capnp-secrets:/gitlab-capnp-secrets:ro' sysctls: - 'net.ipv4.tcp_keepalive_time=60' diff --git a/web-ui/README.md b/web-ui/README.md index 9127b9c3..f7f7bb46 100644 --- a/web-ui/README.md +++ b/web-ui/README.md @@ -13,7 +13,7 @@ These are some principles for `web-ui` that we will hold to: There should be no template or markup related code here. - Routes are in `web-ui/router.ml` -- these call controllers. - Concerns related to serialising and deserialising to JSON are in `representation` - - A `Git_forge` functorises controllers and views allowing for implementation of GitHub and GitLab git-forges. + - A `Git_forge` functorises controllers and views allowing for implementation of git-forges (currently GitHub). The dependencies in web-ui are described below: diff --git a/web-ui/controller/api/gitlab.ml b/web-ui/controller/api/gitlab.ml deleted file mode 100644 index 719e6bba..00000000 --- a/web-ui/controller/api/gitlab.ml +++ /dev/null @@ -1 +0,0 @@ -include Git_forge.Make (Api_view.Gitlab) diff --git a/web-ui/controller/api/gitlab.mli b/web-ui/controller/api/gitlab.mli deleted file mode 100644 index d9bea40c..00000000 --- a/web-ui/controller/api/gitlab.mli +++ /dev/null @@ -1 +0,0 @@ -include Git_forge.Api_controller diff --git a/web-ui/controller/gitlab.ml b/web-ui/controller/gitlab.ml deleted file mode 100644 index 96284a85..00000000 --- a/web-ui/controller/gitlab.ml +++ /dev/null @@ -1 +0,0 @@ -include Git_forge.Make (View.Gitlab) diff --git a/web-ui/controller/gitlab.mli b/web-ui/controller/gitlab.mli deleted file mode 100644 index 3b2abf63..00000000 --- a/web-ui/controller/gitlab.mli +++ /dev/null @@ -1 +0,0 @@ -include Git_forge.Controller diff --git a/web-ui/main.ml b/web-ui/main.ml index 5d5fcf41..2bafdde4 100644 --- a/web-ui/main.ml +++ b/web-ui/main.ml @@ -17,12 +17,10 @@ let setup_logs level = Logs.set_level level; Dream.initialize_log () -let main interface port github_pipeline_cap gitlab_pipeline_cap - prometheus_config log_level = +let main interface port github_pipeline_cap prometheus_config log_level = Lwt_main.run (let () = setup_logs log_level in let github = Option.map Backend.make github_pipeline_cap in - let gitlab = Option.map Backend.make gitlab_pipeline_cap in let web = Dream.serve ~interface ~port ~error_handler: @@ -31,7 +29,7 @@ let main interface port github_pipeline_cap gitlab_pipeline_cap @@ Middleware.no_trailing_slash @@ Dream.memory_sessions @@ Dream.flash - @@ Router.create ~github ~gitlab + @@ Router.create ~github in Lwt.choose (web :: Prometheus_unix.serve prometheus_config)) @@ -57,13 +55,6 @@ let backend_cap = ~doc:"The capability file giving access to the GitHub backend service." ~docv:"CAP" [ "backend" ] -let gitlab_backend_cap = - Arg.value - @@ Arg.opt (Arg.some Capnp_rpc_unix.sturdy_uri) None - @@ Arg.info - ~doc:"The capability file giving access to the GitLab backend service." - ~docv:"CAP" [ "gitlab-backend" ] - let cmd = let doc = "A web front-end for OCaml-CI" in let info = Cmd.info "ocaml-ci-web" ~doc in @@ -73,7 +64,6 @@ let cmd = $ interface $ port $ backend_cap - $ gitlab_backend_cap $ Prometheus_unix.opts $ Logs_cli.level ()) diff --git a/web-ui/router.ml b/web-ui/router.ml index 49a2d338..20154e30 100644 --- a/web-ui/router.ml +++ b/web-ui/router.ml @@ -256,37 +256,18 @@ let documentation = @@ Controller.Documentation.user_guide website_scheme_and_domain); ] -let root ~gitlab ~github = +let root ~github = [ Dream.get "/" (fun _ -> - match (github, gitlab) with - | None, None -> + match github with + | None -> Dream.log "No backend available"; Dream.empty `Internal_Server_Error - | Some github, None -> + | Some github -> let orgs = [ ("github", "GitHub", github) ] in - Controller.Index.list_orgs ~orgs - | None, Some gitlab -> - Controller.Index.list_orgs ~orgs:[ ("gitlab", "GitLab", gitlab) ] - | Some github, Some gitlab -> - let orgs = - [ ("github", "GitHub", github); ("gitlab", "GitLab", gitlab) ] - in Controller.Index.list_orgs ~orgs); ] -let build_gitlab_route gitlab = - let module Gitlab = Route (struct - let prefix = "gitlab" - let request = "merge-request" - let backend = gitlab - let extra_routes = [] - - module Api = Api_controller.Gitlab - module Controller = Controller.Gitlab - end) in - Gitlab.routes () - let build_github_route github = let module Github = Route (struct let prefix = "github" @@ -322,12 +303,8 @@ let build_github_route github = end) in Github.routes () -let create ~github ~gitlab = - let gitlab_route = - match gitlab with None -> [] | Some gitlab -> build_gitlab_route gitlab - in +let create ~github = let github_route = match github with None -> [] | Some github -> build_github_route github in - Dream.router - (root ~gitlab ~github @ static @ documentation @ gitlab_route @ github_route) + Dream.router (root ~github @ static @ documentation @ github_route) diff --git a/web-ui/router.mli b/web-ui/router.mli index bd0ddf74..382239e4 100644 --- a/web-ui/router.mli +++ b/web-ui/router.mli @@ -1,4 +1 @@ -val create : - github:Controller.Backend.t option -> - gitlab:Controller.Backend.t option -> - Dream.handler +val create : github:Controller.Backend.t option -> Dream.handler diff --git a/web-ui/static/images/gitlab-logo-500.png b/web-ui/static/images/gitlab-logo-500.png deleted file mode 100644 index b4c82efe..00000000 Binary files a/web-ui/static/images/gitlab-logo-500.png and /dev/null differ diff --git a/web-ui/static/images/index-page-search.png b/web-ui/static/images/index-page-search.png deleted file mode 100644 index 7542bf89..00000000 Binary files a/web-ui/static/images/index-page-search.png and /dev/null differ diff --git a/web-ui/view/api/git_forge.ml b/web-ui/view/api/git_forge.ml index b51bb62b..5db12d2c 100644 --- a/web-ui/view/api/git_forge.ml +++ b/web-ui/view/api/git_forge.ml @@ -20,10 +20,9 @@ end (* This module is starting out as very thin wrapper on a string. It's meant to help stay consistent with the design intent of implementing - different git-forges via a functorial approach. As we round out the - Gitlab work this module may grow. If the implementation between the different - git-forges turns out to be the same, this module will not grow and we may - choose to back away from this approach. *) + different git-forges via a functorial approach. If the implementation + between the different git-forges turns out to be the same, this module + will not grow and we may choose to back away from this approach. *) module type M_Git_forge = sig val prefix : string end diff --git a/web-ui/view/api/gitlab.ml b/web-ui/view/api/gitlab.ml deleted file mode 100644 index 2356f146..00000000 --- a/web-ui/view/api/gitlab.ml +++ /dev/null @@ -1,3 +0,0 @@ -include Git_forge.Make (struct - let prefix = "gitlab" -end) diff --git a/web-ui/view/api/gitlab.mli b/web-ui/view/api/gitlab.mli deleted file mode 100644 index 9d4d42de..00000000 --- a/web-ui/view/api/gitlab.mli +++ /dev/null @@ -1 +0,0 @@ -include Git_forge.Api diff --git a/web-ui/view/common.ml b/web-ui/view/common.ml index 2a9a26ec..41ca0950 100644 --- a/web-ui/view/common.ml +++ b/web-ui/view/common.ml @@ -335,21 +335,6 @@ let github_logo = []; ]) -let gitlab_logo = - Tyxml.Svg.( - Tyxml.Html.svg - ~a:[ a_class [ "w-4 h-4" ]; a_fill `None; a_viewBox (0., 0., 380., 380.) ] - [ - path - ~a: - [ - a_class [ "svg-fill" ]; - a_d - "M282.83,170.73l-.27-.69-26.14-68.22a6.81,6.81,0,0,0-2.69-3.24,7,7,0,0,0-8,.43,7,7,0,0,0-2.32,3.52l-17.65,54H154.29l-17.65-54A6.86,6.86,0,0,0,134.32,99a7,7,0,0,0-8-.43,6.87,6.87,0,0,0-2.69,3.24L97.44,170l-.26.69a48.54,48.54,0,0,0,16.1,56.1l.09.07.24.17,39.82,29.82,19.7,14.91,12,9.06a8.07,8.07,0,0,0,9.76,0l12-9.06,19.7-14.91,40.06-30,.1-.08A48.56,48.56,0,0,0,282.83,170.73Z"; - ] - []; - ]) - let information_icon = Tyxml.Svg.( Tyxml.Html.svg diff --git a/web-ui/view/documentation.ml b/web-ui/view/documentation.ml index 9c33fd7d..fe8bda5c 100644 --- a/web-ui/view/documentation.ml +++ b/web-ui/view/documentation.ml @@ -278,7 +278,7 @@ let user_guide website_scheme_and_domain = txt " : An organisation that owns projects that they want to \ build. This typically corresponds to an account on GitHub \ - or GitLab for example."; + for example."; ]; p [ diff --git a/web-ui/view/documentation/build_page.ml b/web-ui/view/documentation/build_page.ml index f70b64a8..3e0fe6a8 100644 --- a/web-ui/view/documentation/build_page.ml +++ b/web-ui/view/documentation/build_page.ml @@ -12,8 +12,8 @@ let show = repository's health following the additional changes introduced by \ the commit. It shows the overall status as well as an overview of \ the steps that constitute the build. When examining a commit on \ - GitHub or GitLab, clicking on the commit's build status will bring \ - you to this page."; + GitHub, clicking on the commit's build status will bring you to \ + this page."; ]; img ~a:[ a_class [ "border border-solid" ] ] diff --git a/web-ui/view/documentation/index_page.ml b/web-ui/view/documentation/index_page.ml index c5d227ce..f6226431 100644 --- a/web-ui/view/documentation/index_page.ml +++ b/web-ui/view/documentation/index_page.ml @@ -17,22 +17,11 @@ let show = [ txt "The index page of OCaml-CI lists all organisations that OCaml-CI \ - knows about, across both GitHub and GitLab. The logo of the Git \ - forge is used to indicate the source of the organisation. Note that \ - if no repositories are registered with OCaml-CI, the organisation \ - will not be listed."; + knows about. Note that if no repositories are registered with \ + OCaml-CI, the organisation will not be listed."; ]; img ~a:[ a_class [ "border border-solid" ] ] ~src:"/images/index-page-overview.png" ~alt:"index-page-overview" (); - p - [ - txt - "A filter is provided to select between GitHub or GitLab. Search is \ - also available."; - ]; - img - ~a:[ a_class [ "border border-solid" ] ] - ~src:"/images/index-page-search.png" ~alt:"index-page-search" (); p [ txt "To see its repositories, click on the organisation." ]; ] diff --git a/web-ui/view/documentation/user_guide.ml b/web-ui/view/documentation/user_guide.ml index 75acc3de..cab48831 100644 --- a/web-ui/view/documentation/user_guide.ml +++ b/web-ui/view/documentation/user_guide.ml @@ -130,8 +130,8 @@ let concepts_and_terms = [ strong [ txt "Git forge" ]; txt - " : A service that hosts Git repositories. Currently GitHub and \ - GitLab are supported."; + " : A service that hosts Git repositories. Currently GitHub is \ + supported."; ]; p [ diff --git a/web-ui/view/gitlab.ml b/web-ui/view/gitlab.ml deleted file mode 100644 index dbe2d357..00000000 --- a/web-ui/view/gitlab.ml +++ /dev/null @@ -1,26 +0,0 @@ -include Git_forge.Make (struct - let prefix = "gitlab" - let request_abbrev = "MR" - let request_prefix = "merge-request" - let org_url ~org = Printf.sprintf "https://gitlab.com/%s" org - let repo_url ~org ~repo = Printf.sprintf "https://gitlab.com/%s/%s" org repo - - let commit_url ~org ~repo ~hash = - Printf.sprintf "https://gitlab.com/%s/%s/-/commit/%s" org repo hash - - let branch_url ~org ~repo ref = - Fmt.str "https://gitlab.com/%s/%s/-/tree/%s" org repo ref - - let request_url ~org ~repo id = - Fmt.str "https://gitlab.com/%s/%s/-/merge_requests/%s" org repo id - - let parse_ref r = - match Astring.String.cuts ~sep:"/" r with - | "refs" :: "heads" :: branch -> - let branch = Astring.String.concat ~sep:"/" branch in - `Branch branch - | [ "refs"; "merge-requests"; id; "head" ] -> - let id = int_of_string id in - `Request id - | _ -> `Unknown r -end) diff --git a/web-ui/view/gitlab.mli b/web-ui/view/gitlab.mli deleted file mode 100644 index 74feb354..00000000 --- a/web-ui/view/gitlab.mli +++ /dev/null @@ -1 +0,0 @@ -include Git_forge.View diff --git a/web-ui/view/organisation.ml b/web-ui/view/organisation.ml index 66faa81a..65f296e8 100644 --- a/web-ui/view/organisation.ml +++ b/web-ui/view/organisation.ml @@ -25,10 +25,7 @@ module Make (M : Forge_prefix) = struct ()) let logo = - match M.prefix with - | "github" -> Common.github_logo - | "gitlab" -> Common.gitlab_logo - | _ -> raise Not_found + match M.prefix with "github" -> Common.github_logo | _ -> raise Not_found let git_forge_url org = Printf.sprintf "https://%s.com/%s" M.prefix org diff --git a/web-ui/view/ref.ml b/web-ui/view/ref.ml index 70210a6c..b9d509e1 100644 --- a/web-ui/view/ref.ml +++ b/web-ui/view/ref.ml @@ -6,10 +6,7 @@ module Make (M : Git_forge_intf.Forge) = struct type t = Branch of string | PR of { title : string; id : string } let logo = - match M.prefix with - | "github" -> Common.github_logo - | "gitlab" -> Common.gitlab_logo - | _ -> raise Not_found + match M.prefix with "github" -> Common.github_logo | _ -> raise Not_found let row ~ref ~short_hash ~started_at ~ran_for ~status ~ref_uri ~message = let ref_title = @@ -122,7 +119,6 @@ module Make (M : Git_forge_intf.Forge) = struct | _, "refs" :: "heads" :: branch -> Branch (Astring.String.concat ~sep:"/" branch) | "github", [ "refs"; "pull"; id; "head" ] -> PR { title; id } - | "gitlab", [ "refs"; "merge-requests"; id; "head" ] -> PR { title; id } | _ -> Branch (Printf.sprintf "Bad ref format %S" gref) let list ~org ~repo ~default_ref ~refs = @@ -165,11 +161,6 @@ module Make (M : Git_forge_intf.Forge) = struct Client.Ref_map.filter (fun ref _ -> String.starts_with ~prefix:"refs/pull/" ref) refs - | "gitlab" -> - Client.Ref_map.filter - (fun ref _ -> - String.starts_with ~prefix:"refs/merge-requests/" ref) - refs | _ -> Client.Ref_map.empty (* FIXME: This should lead to an error. *) in let n_prs = Client.Ref_map.cardinal prs in diff --git a/web-ui/view/step.ml b/web-ui/view/step.ml index 4bad2613..e6307506 100644 --- a/web-ui/view/step.ml +++ b/web-ui/view/step.ml @@ -142,7 +142,6 @@ module Make (M : Git_forge_intf.Forge) = struct Common.form_cancel ~hash ~csrf_token ~show:can_cancel () :: Common.rebuild_button ~hash ~csrf_token ~show:show_rebuild () in - (* FIXME: Remove below when we are ready to show history for Gitlab as well. *) let title_card = Build.title_card ~status:build_status ~card_title:message ~hash_link:(link_forge_commit ~org ~repo ~hash:(Common.short_hash hash))