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 testing #392

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
16 changes: 16 additions & 0 deletions lib/build.ml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,19 @@ let freebsd ~build =
) acc [`X86_64]
) [] default_compilers

let windows ~build =
let build ~distro ~arch ~compiler =
let variant = Variant.v ~arch ~distro ~compiler in
let label = Fmt.str "%s-%s" (Variant.docker_tag variant) (Ocaml_version.string_of_arch arch) in
build ~opam_version ~lower_bounds:false ~revdeps:false label variant
in
List.fold_left (fun acc comp ->
let comp = Ocaml_version.to_string comp in
List.fold_left (fun acc arch ->
build ~distro:Variant.windows_server ~arch ~compiler:(comp, None) :: acc
) acc [`X86_64]
) [] default_compilers

(* Non-linux-x86_64 compiler variants. eg ls390x, arm64, flambda, afl etc *)
let extras ~build =
let build ~opam_version ~distro ~arch ~compiler label =
Expand Down Expand Up @@ -190,6 +203,8 @@ let get_base ~arch variant =
Current.return (Spec.Macos (Variant.docker_tag variant))
| `Freebsd ->
Current.return (Spec.Freebsd (Variant.docker_tag variant))
| `Windows ->
Current.return (Spec.Windows (Variant.docker_tag variant))
| `Linux -> (* TODO: Use docker images as base for both MacOS and Linux *)
let+ repo_id =
Docker.peek ~schedule:weekly ~arch:(Ocaml_version.to_docker_arch arch)
Expand Down Expand Up @@ -271,6 +286,7 @@ let with_cluster ~ocluster ~analysis ~lint ~master source =
Node.branch ~label:"distributions" (linux_distributions ~arch:`X86_64 ~build);
Node.branch ~label:"macos" (macos ~build);
Node.branch ~label:"freebsd" (freebsd ~build);
Node.branch ~label:"windows" (windows ~build);
Node.branch ~label:"extras" (extras ~build);
]

Expand Down
10 changes: 10 additions & 0 deletions lib/build.mli
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ val freebsd :
'a) ->
'a list

val windows :
build:
(opam_version:[> `Dev ] ->
lower_bounds:bool ->
revdeps:bool ->
string ->
Opam_ci_check.Variant.t ->
'a) ->
'a list

val extras :
build:
(opam_version:Opam_ci_check.Opam_version.t ->
Expand Down
5 changes: 3 additions & 2 deletions lib/cluster_build.ml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ let pool_of_variant v =
| `Macos -> "macos"
| `Freebsd -> "freebsd"
| `Linux -> "linux"
| `Windows -> "windows"
in
let arch = match Variant.arch v with
| `X86_64 | `I386 -> "x86_64"
| `X86_64 | `I386 -> if os = "windows" then "amd64" else "x86_64"
| `Aarch32 | `Aarch64 -> "arm64"
| `Ppc64le -> "ppc64"
| `S390x -> "s390x"
Expand Down Expand Up @@ -107,7 +108,7 @@ module Op = struct
| `Riscv64 -> Int64.mul timeout 2L
| _ -> timeout in
let os = match Variant.os variant with
| `Macos | `Linux | `Freebsd -> `Unix
| `Macos | `Linux | `Freebsd | `Windows -> `Unix
in
let build_config = {Spec.variant; ty} in
Current.Job.write job
Expand Down
3 changes: 2 additions & 1 deletion lib/local_build.ml
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,13 @@ module Op = struct
{ Key.commit; ty; variant } =
let { docker_context; pool; build_timeout } = config in
let os = match Variant.os variant with
| `Macos | `Linux | `Freebsd -> `Unix
| `Macos | `Linux | `Freebsd | `Windows -> `Unix
in
let build_config = {Spec.variant; ty}
in
let image =
match base with
| Windows _s -> failwith "Local Windows OBuilder worker not supported"
| Macos _s -> failwith "Local MacOS OBuilder worker not supported"
| Freebsd _s -> failwith "Local FreeBSD OBuilder worker not supported"
| Docker image -> image
Expand Down
1 change: 1 addition & 0 deletions lib/status_tree.ml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ let status (s, elms1) elms2 =
let tag_experimental b =
(* TODO: Remove this *)
if Astring.String.is_prefix ~affix:"macos-homebrew" b ||
Astring.String.is_prefix ~affix:"windows" b ||
Astring.String.is_prefix ~affix:"freebsd" b
then b ^ " (experimental)"
else b
Expand Down
16 changes: 11 additions & 5 deletions opam-ci-check/lib/opam_build.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ let cache ~variant =
match Variant.os variant with
| `Freebsd
| `Linux -> [ Obuilder_spec.Cache.v download_cache ~target:"/home/opam/.opam/download-cache" ]
| `Windows -> [ Obuilder_spec.Cache.v download_cache ~target:"c:\\Users\\opam\\AppData\\local\\opam\\download-cache" ]
| `Macos -> [ Obuilder_spec.Cache.v download_cache ~target:"/Users/mac1000/.opam/download-cache";
Obuilder_spec.Cache.v "homebrew" ~target:"/Users/mac1000/Library/Caches/Homebrew" ]
let network = ["host"]
Expand Down Expand Up @@ -84,30 +85,35 @@ let setup_repository ?(local=false) ~variant ~for_docker ~opam_version () =
let open Obuilder_spec in
let home_dir = match Variant.os variant with
| `Macos -> None
| `Windows -> Some "/cygdrive/c/Users/opam"
| `Freebsd
| `Linux -> Some "/home/opam"
in
let prefix = match Variant.os variant with
| `Macos -> "~/local"
| `Freebsd -> "/usr/local"
| `Linux -> "/usr"
| `Windows | `Linux -> "/usr"
in
let ln = match Variant.os variant with
| `Macos -> "ln"
| `Windows | `Macos -> "ln"
| `Freebsd | `Linux -> "sudo ln"
in
let dst = match Variant.os variant with
| `Windows -> "/Users/opam/opam-repository/"
| `Macos | `Freebsd | `Linux -> "opam-repository/"
in
let opam_version_str = Opam_version.to_string opam_version
in
let opam_repo_args = match Variant.os variant with
| `Macos -> " -k local" (* TODO: (copy ...) do not copy the content of .git or something like that and make the subsequent opam pin fail *)
| `Freebsd | `Linux -> ""
| `Windows | `Freebsd | `Linux -> ""
in
let opamrc = match Variant.os variant with
(* NOTE: [for_docker] is required because docker does not support bubblewrap in docker build *)
(* docker run has --privileged but docker build does not have it *)
(* so we need to remove the part re-enabling the sandbox. *)
| `Linux when not for_docker -> " --config .opamrc-sandbox"
| `Freebsd | `Macos | `Linux -> ""
| `Windows | `Freebsd | `Macos | `Linux -> ""
(* TODO: On MacOS, the sandbox is always (and should be) enabled by default but does not have those ~/.opamrc-sandbox files *)
in
(* If we are testing a minimal opam-repository without
Expand All @@ -130,7 +136,7 @@ let setup_repository ?(local=false) ~variant ~for_docker ~opam_version () =
env "CI" "true" :: env "OPAM_REPO_CI" "true" :: (* Advertise CI for test frameworks *)
[
run "rm -rf opam-repository/";
copy ["."] ~dst:"opam-repository/";
copy ["."] ~dst;
run "opam repository set-url%s --strict default opam-repository/" opam_repo_args;
run ~network "opam %s || true" (match opam_version with `V2_1 | `V2_2 | `V2_3 | `Dev -> "update --depexts" | `V2_0 -> "depext -u");
] @
Expand Down
2 changes: 2 additions & 0 deletions opam-ci-check/lib/spec.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ type base =
| Docker of string
| Macos of string
| Freebsd of string
| Windows of string

let base_to_string = function
| Docker img -> img
| Macos base -> base
| Freebsd base -> base
| Windows base -> base

type package = OpamPackage.t

Expand Down
1 change: 1 addition & 0 deletions opam-ci-check/lib/spec.mli
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type base =
| Docker of string
| Macos of string
| Freebsd of string
| Windows of string

val base_to_string : base -> string

Expand Down
3 changes: 3 additions & 0 deletions opam-ci-check/lib/variant.ml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ let pp f t = Fmt.pf f "%s/%s" (docker_tag t) (Ocaml_version.string_of_arch t.arc

let freebsd = "freebsd"
let macos_homebrew = "macos-homebrew"
let windows_server = "windows-server-2022-amd64"

let macos_distributions = [
macos_homebrew;
Expand All @@ -41,6 +42,8 @@ let os { distribution; _ } =
`Macos
else if List.exists (String.equal distribution) [ "freebsd" ] then
`Freebsd
else if List.exists (String.equal distribution) [ windows_server ] then
`Windows
else
`Linux

Expand Down
5 changes: 4 additions & 1 deletion opam-ci-check/lib/variant.mli
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ val ocaml_version_to_string : t -> string
val arch : t -> arch
val docker_tag : t -> string
val distribution : t -> string
val os : t -> [ `Linux | `Macos | `Freebsd ]
val os : t -> [ `Linux | `Macos | `Freebsd | `Windows ]

val pp : t Fmt.t

Expand All @@ -22,3 +22,6 @@ val macos_homebrew : string

(** The FreeBSD distribution *)
val freebsd : string

(** The Windows Server distribution *)
val windows_server : string