Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Windows support as experimental #980

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions gitlab/pipeline.ml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ let gitlab_status_of_state head result =
let local_test ~query_uri ~solver repo () =
let platforms =
Conf.fetch_platforms ~query_uri ~include_macos:false ~include_freebsd:false
()
~include_windows:false ()
in
let src = Git.Local.head_commit repo in
let src_content = Repo_content.extract src in
Expand All @@ -207,7 +207,8 @@ let local_test ~query_uri ~solver repo () =

let v ?ocluster ~app ~query_uri ~solver ~migrations () =
let platforms =
Conf.fetch_platforms ~query_uri ~include_macos:true ~include_freebsd:true ()
Conf.fetch_platforms ~query_uri ~include_macos:true ~include_freebsd:true
~include_windows:true ()
in
let ocluster =
Option.map (Cluster_build.config ~timeout:(Duration.of_hour 1)) ocluster
Expand Down
15 changes: 11 additions & 4 deletions lib/build_info.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ let of_label label = { label; variant = None }
If it is experimental we allow those builds to fail without failing the
overall build for a commit. *)
let experimental_variant s =
Astring.String.(
is_prefix ~affix:Variant.lower_bound_label s.label
|| is_prefix ~affix:Variant.opam_label s.label)
if
Astring.String.(
is_prefix ~affix:Variant.lower_bound_label s.label
|| is_prefix ~affix:Variant.opam_label s.label)
then true
else
match s.variant with
| None -> false
| Some v -> Astring.String.equal "windows-server-2022" (Variant.distro v)

(** Like [experimental_variant], but takes strings for when a [build_info]
record is unavailable.
Expand All @@ -24,4 +30,5 @@ let experimental_variant s =
let experimental_variant_str s =
Astring.String.(
is_prefix ~affix:Variant.lower_bound_label s
|| is_prefix ~affix:Variant.opam_label s)
|| is_prefix ~affix:Variant.opam_label s
|| is_prefix ~affix:"windows-server-2022" s)
18 changes: 15 additions & 3 deletions lib/opam_build.ml
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ let install_project_deps ~opam_version ~opam_files ~selection =
let prefix =
match Variant.os variant with
| `macOS -> "~/local"
| `linux -> "/usr"
| `windows | `linux -> "/usr"
| `freeBSD -> "/usr/local"
in
let ln =
match Variant.os variant with
| `macOS -> "ln"
| `windows | `macOS -> "ln"
| `linux | `freeBSD -> "sudo ln"
in
let groups = group_opam_files opam_files in
Expand All @@ -115,6 +115,11 @@ let install_project_deps ~opam_version ~opam_files ~selection =
Obuilder_spec.Cache.v download_cache
~target:"/home/opam/.opam/download-cache";
]
| `windows ->
[
Obuilder_spec.Cache.v download_cache
~target:"/Users/opam/AppData/local/opam/download-cache";
]
| `macOS ->
[
Obuilder_spec.Cache.v download_cache
Expand All @@ -133,12 +138,13 @@ let install_project_deps ~opam_version ~opam_files ~selection =

let home_dir =
match Variant.os selection.Selection.variant with
| `macOS -> None
| `windows | `macOS -> None
| `linux -> Some "/src"
| `freeBSD -> Some "/src"
in
let work_dir =
match Variant.os selection.Selection.variant with
| `windows -> Some (Fpath.v "/Users/opam/Documents")
| `macOS -> Some (Fpath.v "./src/")
| `linux -> None
| `freeBSD -> None
Expand Down Expand Up @@ -202,6 +208,7 @@ let spec ~base ~opam_version ~opam_files ~selection =
let to_name x = OpamPackage.of_string x |> OpamPackage.name_to_string in
let home_dir =
match Variant.os selection.Selection.variant with
| `windows -> "/Users/opam/Documents"
| `macOS -> "./src"
| `linux -> "/src"
| `freeBSD -> "/src"
Expand All @@ -213,6 +220,11 @@ let spec ~base ~opam_version ~opam_files ~selection =
in
let run_build =
match Variant.os selection.Selection.variant with
| `windows ->
run
"cd /cygdrive/c/Users/opam/Documents && opam exec -- dune build%s \
@install @check @runtest && rm -rf _build"
only_packages
| `macOS ->
run
"cd ./src && opam exec -- dune build%s @install @check @runtest && \
Expand Down
3 changes: 3 additions & 0 deletions lib/platform.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module Pool_name = struct
| `Linux_riscv64
| `Macos_x86_64
| `Macos_ARM64
| `Windows_x86_64
| `FreeBSD_x86_64 ]

let to_string = function
Expand All @@ -22,6 +23,7 @@ module Pool_name = struct
| `Linux_riscv64 -> "linux-riscv64"
| `Macos_x86_64 -> "macos-x86_64"
| `Macos_ARM64 -> "macos-arm64"
| `Windows_x86_64 -> "test"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll want sensible string encodings of the Windows platform here.

| `FreeBSD_x86_64 -> "freebsd-x86_64"

let of_string = function
Expand All @@ -32,6 +34,7 @@ module Pool_name = struct
| "linux-riscv64" -> Ok `Linux_riscv64
| "macos-x86_64" -> Ok `Macos_x86_64
| "macos-arm64" -> Ok `Macos_ARM64
| "test" -> Ok `Windows_x86_64
| "freebsd-x86_64 " -> Ok `FreeBSD_x86_64
| s -> Error (`Msg (s ^ ": invalid pool name"))
end
Expand Down
1 change: 1 addition & 0 deletions lib/platform.mli
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module Pool_name : sig
| `Linux_riscv64
| `Macos_x86_64
| `Macos_ARM64
| `Windows_x86_64
| `FreeBSD_x86_64 ]

val to_string : t -> string
Expand Down
4 changes: 2 additions & 2 deletions lib/query.ml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ let prepare_image ~variant =
let prefix =
match Variant.os variant with
| `macOS -> "~/local"
| `linux -> "/usr"
| `windows | `linux -> "/usr"
| `freeBSD -> "/usr/local"
in
let ln =
match Variant.os variant with
| `macOS -> "ln"
| `windows | `macOS -> "ln"
| `linux | `freeBSD -> "sudo ln"
in
(* XXX: don't overwrite default config? *)
Expand Down
4 changes: 2 additions & 2 deletions lib/query_local.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ let prepare_image ~job ~docker_context ~tag variant image =
let prefix =
match Variant.os variant with
| `macOS -> "~/local"
| `linux -> "/usr"
| `windows | `linux -> "/usr"
| `freeBSD -> "/usr/local"
in
let ln =
match Variant.os variant with
| `macOS -> "ln"
| `windows | `macOS -> "ln"
| `linux | `freeBSD -> "sudo ln"
in
(* XXX: don't overwrite default config? *)
Expand Down
2 changes: 2 additions & 0 deletions lib/variant.ml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ type t = {
[@@deriving yojson, ord, eq]

let macos_distributions = [ "macos-homebrew" ]
let windows_distributions = [ "windows-server-2022" ]
let freebsd_distributions = [ "freebsd" ]

let os { distro; _ } =
if List.exists (String.equal distro) macos_distributions then `macOS
else if List.exists (String.equal distro) windows_distributions then `windows
else if List.exists (String.equal distro) freebsd_distributions then `freeBSD
else `linux

Expand Down
2 changes: 1 addition & 1 deletion lib/variant.mli
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ val docker_tag : t -> string
val pp : t Fmt.t
val to_string : t -> string
val of_string : string -> t
val os : t -> [> `linux | `macOS | `freeBSD ]
val os : t -> [> `linux | `windows | `macOS | `freeBSD ]
28 changes: 25 additions & 3 deletions service/conf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,22 @@ type platform = {
lower_bound : bool;
}

(* Support OCaml 4.14 on Windows. *)
let windows_distros =
List.map
(fun ocaml_version ->
{
label = "windows-server-2022";
builder = Builders.local;
pool = `Windows_x86_64;
distro = "windows-server-2022";
ocaml_version;
arch = `X86_64;
opam_version = `V2_2;
lower_bound = false;
})
default_compilers

(* Support OCaml default compilers on FreeBSD platform. *)
let freebsd_distros =
List.map
Expand Down Expand Up @@ -141,7 +157,8 @@ let pool_of_arch = function
| `Ppc64le -> `Linux_ppc64
| `Riscv64 -> `Linux_riscv64

let platforms ~profile ~include_macos ~include_freebsd opam_version =
let platforms ~profile ~include_macos ~include_freebsd ~include_windows
opam_version =
let v ?(arch = `X86_64) ?(lower_bound = false) label distro ocaml_version =
{
arch;
Expand Down Expand Up @@ -188,6 +205,7 @@ let platforms ~profile ~include_macos ~include_freebsd opam_version =
distros
|> List.append (if include_macos then macos_distros else [])
|> List.append (if include_freebsd then freebsd_distros else [])
|> List.append (if include_windows then windows_distros else [])
in
(* The first one in this list is used for lint actions *)
let ovs = List.rev OV.Releases.recent @ OV.Releases.unreleased_betas in
Expand Down Expand Up @@ -247,7 +265,8 @@ let merge_lower_bound_platforms platforms =
in
upper_bound @ lower_bound

let fetch_platforms ~query_uri ~include_macos ~include_freebsd () =
let fetch_platforms ~query_uri ~include_macos ~include_freebsd ~include_windows
() =
let open Ocaml_ci in
let conn =
Option.map
Expand All @@ -270,7 +289,9 @@ let fetch_platforms ~query_uri ~include_macos ~include_freebsd () =
lower_bound;
} =
match (conn, distro) with
| Some conn, "macos-homebrew" | Some conn, "freebsd" ->
| Some conn, "windows-server-2022"
| Some conn, "macos-homebrew"
| Some conn, "freebsd" ->
(* FreeBSD and MacOS uses ZFS snapshots rather than docker images. *)
let docker_image_name =
Fmt.str "%s-ocaml-%d.%d" distro (OV.major ocaml_version)
Expand Down Expand Up @@ -308,6 +329,7 @@ let fetch_platforms ~query_uri ~include_macos ~include_freebsd () =
in
let v2_2 =
platforms ~profile:platforms_profile `V2_2 ~include_macos ~include_freebsd
~include_windows
|> merge_lower_bound_platforms
in
Current.list_seq (List.map v v2_2) |> Current.map List.flatten
5 changes: 3 additions & 2 deletions service/pipeline.ml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ let set_active_refs ~repo refs default_ref =
let local_test ~query_uri ~solver repo () =
let platforms =
Conf.fetch_platforms ~query_uri ~include_macos:false ~include_freebsd:false
()
~include_windows:false ()
in
let src = Git.Local.head_commit repo in
let src_content = Repo_content.extract src in
Expand All @@ -130,7 +130,8 @@ let v ?ocluster ~app ~solver ~query_uri ~migrations () =
Option.map (Cluster_build.config ~timeout:(Duration.of_hour 1)) ocluster
in
let platforms =
Conf.fetch_platforms ~query_uri ~include_macos:true ~include_freebsd:true ()
Conf.fetch_platforms ~query_uri ~include_macos:true ~include_freebsd:true
~include_windows:true ()
in
let migrations =
match migrations with
Expand Down
6 changes: 3 additions & 3 deletions test/service/test_conf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let to_tag d = DD.((resolve_alias d :> t) |> tag_of_distro)
let test_platforms () =
let platforms =
Service.Conf.platforms ~profile:`All ~include_macos:true
~include_freebsd:true `V2_1
~include_freebsd:true ~include_windows:true `V2_1
|> List.map extract
in
let exists =
Expand Down Expand Up @@ -59,7 +59,7 @@ let test_platforms () =
let test_macos_platforms () =
let platforms =
Service.Conf.platforms ~profile:`All ~include_macos:true
~include_freebsd:true `V2_1
~include_freebsd:true ~include_windows:true `V2_1
|> List.map extract
in
let exists =
Expand Down Expand Up @@ -96,7 +96,7 @@ let test_macos_platforms () =
let test_distro_arches () =
let platforms =
Service.Conf.platforms ~profile:`All ~include_macos:true
~include_freebsd:true `V2_1
~include_freebsd:true ~include_windows:true `V2_1
|> List.map extract
in
(* Test that these distros don't occur with these arches under any OCaml version *)
Expand Down