Skip to content

Commit 5a1b5f6

Browse files
committed
Add Windows testing
1 parent 2653281 commit 5a1b5f6

File tree

10 files changed

+53
-9
lines changed

10 files changed

+53
-9
lines changed

lib/build.ml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,19 @@ let freebsd ~build =
121121
) acc [`X86_64]
122122
) [] default_compilers
123123

124+
let windows ~build =
125+
let build ~distro ~arch ~compiler =
126+
let variant = Variant.v ~arch ~distro ~compiler in
127+
let label = Fmt.str "%s-%s" (Variant.docker_tag variant) (Ocaml_version.string_of_arch arch) in
128+
build ~opam_version ~lower_bounds:false ~revdeps:false label variant
129+
in
130+
List.fold_left (fun acc comp ->
131+
let comp = Ocaml_version.to_string comp in
132+
List.fold_left (fun acc arch ->
133+
build ~distro:Variant.windows_server ~arch ~compiler:(comp, None) :: acc
134+
) acc [`X86_64]
135+
) [] default_compilers
136+
124137
(* Non-linux-x86_64 compiler variants. eg ls390x, arm64, flambda, afl etc *)
125138
let extras ~build =
126139
let build ~opam_version ~distro ~arch ~compiler label =
@@ -190,6 +203,8 @@ let get_base ~arch variant =
190203
Current.return (Spec.Macos (Variant.docker_tag variant))
191204
| `Freebsd ->
192205
Current.return (Spec.Freebsd (Variant.docker_tag variant))
206+
| `Windows ->
207+
Current.return (Spec.Windows (Variant.docker_tag variant))
193208
| `Linux -> (* TODO: Use docker images as base for both MacOS and Linux *)
194209
let+ repo_id =
195210
Docker.peek ~schedule:weekly ~arch:(Ocaml_version.to_docker_arch arch)
@@ -271,6 +286,7 @@ let with_cluster ~ocluster ~analysis ~lint ~master source =
271286
Node.branch ~label:"distributions" (linux_distributions ~arch:`X86_64 ~build);
272287
Node.branch ~label:"macos" (macos ~build);
273288
Node.branch ~label:"freebsd" (freebsd ~build);
289+
Node.branch ~label:"windows" (windows ~build);
274290
Node.branch ~label:"extras" (extras ~build);
275291
]
276292

lib/build.mli

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ val freebsd :
4242
'a) ->
4343
'a list
4444

45+
val windows :
46+
build:
47+
(opam_version:[> `Dev ] ->
48+
lower_bounds:bool ->
49+
revdeps:bool ->
50+
string ->
51+
Variant.t ->
52+
'a) ->
53+
'a list
54+
4555
val extras :
4656
build:
4757
(opam_version:Opam_ci_check.Opam_version.t ->

lib/cluster_build.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ let pool_of_variant v =
4343
| `Macos -> "macos"
4444
| `Freebsd -> "freebsd"
4545
| `Linux -> "linux"
46+
| `Windows -> "windows"
4647
in
4748
let arch = match Variant.arch v with
48-
| `X86_64 | `I386 -> "x86_64"
49+
| `X86_64 | `I386 -> if os = "windows" then "amd64" else "x86_64"
4950
| `Aarch32 | `Aarch64 -> "arm64"
5051
| `Ppc64le -> "ppc64"
5152
| `S390x -> "s390x"
@@ -107,7 +108,7 @@ module Op = struct
107108
| `Riscv64 -> Int64.mul timeout 2L
108109
| _ -> timeout in
109110
let os = match Variant.os variant with
110-
| `Macos | `Linux | `Freebsd -> `Unix
111+
| `Macos | `Linux | `Freebsd | `Windows -> `Unix
111112
in
112113
let build_config = {Spec.variant; ty} in
113114
Current.Job.write job

lib/local_build.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,13 @@ module Op = struct
145145
{ Key.commit; ty; variant } =
146146
let { docker_context; pool; build_timeout } = config in
147147
let os = match Variant.os variant with
148-
| `Macos | `Linux | `Freebsd -> `Unix
148+
| `Macos | `Linux | `Freebsd | `Windows -> `Unix
149149
in
150150
let build_config = {Spec.variant; ty}
151151
in
152152
let image =
153153
match base with
154+
| Windows _s -> failwith "Local Windows OBuilder worker not supported"
154155
| Macos _s -> failwith "Local MacOS OBuilder worker not supported"
155156
| Freebsd _s -> failwith "Local FreeBSD OBuilder worker not supported"
156157
| Docker image -> image

lib/status_tree.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ let status (s, elms1) elms2 =
7979
let tag_experimental b =
8080
(* TODO: Remove this *)
8181
if Astring.String.is_prefix ~affix:"macos-homebrew" b ||
82+
Astring.String.is_prefix ~affix:"windows" b ||
8283
Astring.String.is_prefix ~affix:"freebsd" b
8384
then b ^ " (experimental)"
8485
else b

opam-ci-check/lib/opam_build.ml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ let cache ~variant =
55
match Variant.os variant with
66
| `Freebsd
77
| `Linux -> [ Obuilder_spec.Cache.v download_cache ~target:"/home/opam/.opam/download-cache" ]
8+
| `Windows -> [ Obuilder_spec.Cache.v download_cache ~target:"c:\\Users\\opam\\AppData\\local\\opam\\download-cache" ]
89
| `Macos -> [ Obuilder_spec.Cache.v download_cache ~target:"/Users/mac1000/.opam/download-cache";
910
Obuilder_spec.Cache.v "homebrew" ~target:"/Users/mac1000/Library/Caches/Homebrew" ]
1011
let network = ["host"]
@@ -84,30 +85,35 @@ let setup_repository ?(local=false) ~variant ~for_docker ~opam_version () =
8485
let open Obuilder_spec in
8586
let home_dir = match Variant.os variant with
8687
| `Macos -> None
88+
| `Windows -> Some "/cygdrive/c/Users/opam"
8789
| `Freebsd
8890
| `Linux -> Some "/home/opam"
8991
in
9092
let prefix = match Variant.os variant with
9193
| `Macos -> "~/local"
9294
| `Freebsd -> "/usr/local"
93-
| `Linux -> "/usr"
95+
| `Windows | `Linux -> "/usr"
9496
in
9597
let ln = match Variant.os variant with
96-
| `Macos -> "ln"
98+
| `Windows | `Macos -> "ln"
9799
| `Freebsd | `Linux -> "sudo ln"
98100
in
101+
let dst = match Variant.os variant with
102+
| `Windows -> "/Users/opam/opam-repository/"
103+
| `Macos | `Freebsd | `Linux -> "opam-repository/"
104+
in
99105
let opam_version_str = Opam_version.to_string opam_version
100106
in
101107
let opam_repo_args = match Variant.os variant with
102108
| `Macos -> " -k local" (* TODO: (copy ...) do not copy the content of .git or something like that and make the subsequent opam pin fail *)
103-
| `Freebsd | `Linux -> ""
109+
| `Windows | `Freebsd | `Linux -> ""
104110
in
105111
let opamrc = match Variant.os variant with
106112
(* NOTE: [for_docker] is required because docker does not support bubblewrap in docker build *)
107113
(* docker run has --privileged but docker build does not have it *)
108114
(* so we need to remove the part re-enabling the sandbox. *)
109115
| `Linux when not for_docker -> " --config .opamrc-sandbox"
110-
| `Freebsd | `Macos | `Linux -> ""
116+
| `Windows | `Freebsd | `Macos | `Linux -> ""
111117
(* TODO: On MacOS, the sandbox is always (and should be) enabled by default but does not have those ~/.opamrc-sandbox files *)
112118
in
113119
(* If we are testing a minimal opam-repository without
@@ -130,7 +136,7 @@ let setup_repository ?(local=false) ~variant ~for_docker ~opam_version () =
130136
env "CI" "true" :: env "OPAM_REPO_CI" "true" :: (* Advertise CI for test frameworks *)
131137
[
132138
run "rm -rf opam-repository/";
133-
copy ["."] ~dst:"opam-repository/";
139+
copy ["."] ~dst;
134140
run "opam repository set-url%s --strict default opam-repository/" opam_repo_args;
135141
run ~network "opam %s || true" (match opam_version with `V2_1 | `V2_2 | `V2_3 | `Dev -> "update --depexts" | `V2_0 -> "depext -u");
136142
] @

opam-ci-check/lib/spec.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ type base =
33
| Docker of string
44
| Macos of string
55
| Freebsd of string
6+
| Windows of string
67

78
let base_to_string = function
89
| Docker img -> img
910
| Macos base -> base
1011
| Freebsd base -> base
12+
| Windows base -> base
1113

1214
type package = OpamPackage.t
1315

opam-ci-check/lib/spec.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ type base =
77
| Docker of string
88
| Macos of string
99
| Freebsd of string
10+
| Windows of string
1011

1112
val base_to_string : base -> string
1213

opam-ci-check/lib/variant.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ let pp f t = Fmt.pf f "%s/%s" (docker_tag t) (Ocaml_version.string_of_arch t.arc
2929

3030
let freebsd = "freebsd"
3131
let macos_homebrew = "macos-homebrew"
32+
let windows_server = "windows-server-2022-amd64"
3233

3334
let macos_distributions = [
3435
macos_homebrew;
@@ -41,6 +42,8 @@ let os { distribution; _ } =
4142
`Macos
4243
else if List.exists (String.equal distribution) [ "freebsd" ] then
4344
`Freebsd
45+
else if List.exists (String.equal distribution) [ windows_server ] then
46+
`Windows
4447
else
4548
`Linux
4649

opam-ci-check/lib/variant.mli

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ val ocaml_version_to_string : t -> string
1313
val arch : t -> arch
1414
val docker_tag : t -> string
1515
val distribution : t -> string
16-
val os : t -> [ `Linux | `Macos | `Freebsd ]
16+
val os : t -> [ `Linux | `Macos | `Freebsd | `Windows ]
1717

1818
val pp : t Fmt.t
1919

@@ -22,3 +22,6 @@ val macos_homebrew : string
2222

2323
(** The FreeBSD distribution *)
2424
val freebsd : string
25+
26+
(** The Windows Server distribution *)
27+
val windows_server : string

0 commit comments

Comments
 (0)