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

Speedup and trim the jobs #175

Merged
merged 4 commits into from
Jul 26, 2022
Merged
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
3 changes: 2 additions & 1 deletion lib/build.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module Spec = struct
revdep : package option;
with_tests : bool;
lower_bounds : bool;
opam_version : [`V2_0 | `V2_1];
opam_version : [`V2_0 | `V2_1 | `Dev];
} [@@deriving to_yojson]

type ty = [
Expand Down Expand Up @@ -55,6 +55,7 @@ module Spec = struct
(match opam_version with
| `V2_0 -> "2.0"
| `V2_1 -> "2.1"
| `Dev -> "dev"
)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/build.mli
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Spec : sig
platform:Platform.t ->
lower_bounds:bool ->
with_tests:bool ->
opam_version:[`V2_0 | `V2_1] ->
opam_version:[`V2_0 | `V2_1 | `Dev] ->
OpamPackage.t ->
t
end
Expand Down
8 changes: 6 additions & 2 deletions lib/opam_build.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let opam_install ~variant ~opam_version ~pin ~lower_bounds ~with_tests ~pkg =
else
[]
) @ [
run ~network "opam %s" (match opam_version with `V2_1 -> "update --depexts" | `V2_0 -> "depext -u");
run ~network "opam %s" (match opam_version with `V2_1 | `Dev -> "update --depexts" | `V2_0 -> "depext -u");
(* TODO: Replace by two calls to opam install + opam install -t using the OPAMDROPINSTALLEDPACKAGES feature *)
run ~cache ~network
{|opam remove %s%s && opam install --deps-only%s %s && opam install -v%s %s;
Expand All @@ -38,7 +38,7 @@ let opam_install ~variant ~opam_version ~pin ~lower_bounds ~with_tests ~pkg =
fi;
done;
exit 1|}
pkg (match opam_version with `V2_1 -> "" | `V2_0 -> " && opam depext"^with_tests_opt^" "^pkg) with_tests_opt pkg with_tests_opt pkg
pkg (match opam_version with `V2_1 | `Dev -> "" | `V2_0 -> " && opam depext"^with_tests_opt^" "^pkg) with_tests_opt pkg with_tests_opt pkg
(Variant.distribution variant)
]

Expand All @@ -59,6 +59,10 @@ let setup_repository ~variant ~for_docker ~opam_version =
let opam_version_str = match opam_version with
| `V2_0 -> "2.0"
| `V2_1 -> "2.1"
| `Dev ->
match Variant.os variant with
| `macOS -> "2.1" (* TODO: Remove that when macOS has a proper up-to-date docker image *)
| `linux -> "dev"
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 *)
Expand Down
2 changes: 1 addition & 1 deletion lib/opam_build.mli
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
val spec :
for_docker:bool ->
opam_version:[`V2_0 | `V2_1] ->
opam_version:[`V2_0 | `V2_1 | `Dev] ->
base:string ->
variant:Variant.t ->
revdep:OpamPackage.t option ->
Expand Down
44 changes: 16 additions & 28 deletions service/pipeline.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module Common = Opam_repo_ci_api.Common
let master_distro = (Dockerfile_distro.resolve_alias Dockerfile_distro.master_distro :> Dockerfile_distro.t)
let default_compiler_full = Ocaml_version.Releases.latest
let default_compiler = Ocaml_version.with_just_major_and_minor default_compiler_full
let opam_version = `Dev

let weekly = Current_cache.Schedule.v ~valid_for:(Duration.of_day 7) ()

Expand Down Expand Up @@ -144,16 +145,14 @@ let build_with_cluster ~ocluster ~analysis ~lint ~master source =
let build = Node.action `Built image
and tests = Node.action `Built tests
and lower_bounds_check =
match opam_version, lower_bounds with
| `V2_1, true ->
if lower_bounds then
let action =
let spec = lower_bounds_spec ~platform ~opam_version pkg in
Build.v ocluster ~label:"lower-bounds" ~base ~spec ~master ~urgent source
in
let action = Node.action `Built action in
Node.leaf ~label:"lower-bounds" action
| `V2_0, true
| (`V2_1 | `V2_0), false ->
else
Node.empty
and revdeps =
if revdeps then test_revdeps ~ocluster ~opam_version ~master ~base ~platform ~pkgopt source ~after:image
Expand All @@ -169,7 +168,7 @@ let build_with_cluster ~ocluster ~analysis ~lint ~master source =
|> (fun x -> Node.branch ~label [x])
|> Node.collapse ~key:"platform" ~value:label ~input:analysis
in
let compilers ~opam_version =
let compilers =
let master_distro = Dockerfile_distro.tag_of_distro master_distro in
(Ocaml_version.Releases.recent @ Ocaml_version.Releases.unreleased_betas) |>
List.map (fun v ->
Expand All @@ -180,13 +179,15 @@ let build_with_cluster ~ocluster ~analysis ~lint ~master source =
build ~opam_version ~lower_bounds:true ~revdeps v variant
)
in
let distributions ~opam_version =
let distributions =
let default_compiler = Ocaml_version.to_string default_compiler in
let linux_distributions =
Dockerfile_distro.active_distros `X86_64 |>
List.fold_left (fun acc distro ->
if Dockerfile_distro.compare distro master_distro = 0 (* TODO: Add Dockerfile_distro.equal *)
|| Dockerfile_distro.os_family_of_distro distro <> `Linux then (* TODO: Unlock this when Windows is ready *)
|| Dockerfile_distro.os_family_of_distro distro <> `Linux (* TODO: Unlock this when Windows is ready *)
|| Dockerfile_distro.compare distro (`CentOS `V7 : Dockerfile_distro.t) = 0 (* TODO: Remove when it has been removed in ocaml-dockerfile *)
|| Dockerfile_distro.compare distro (`OracleLinux `V7 : Dockerfile_distro.t) = 0 then
acc
else
let distro = Dockerfile_distro.tag_of_distro distro in
Expand All @@ -205,13 +206,12 @@ let build_with_cluster ~ocluster ~analysis ~lint ~master source =
in
let analysis = Node.action `Analysed analysis
and lint = Node.action `Linted lint
and compilers_2_0 = compilers ~opam_version:`V2_0
and compilers_2_1 = compilers ~opam_version:`V2_1
and distributions_2_0 = distributions ~opam_version:`V2_0
and distributions_2_1 = distributions ~opam_version:`V2_1
and extras =
let master_distro = Dockerfile_distro.tag_of_distro master_distro in
let default_comp = Ocaml_version.to_string default_compiler in
let default_variant = Variant.v ~arch:`X86_64 ~distro:master_distro ~compiler:(default_comp, None) in
build ~opam_version:`V2_0 ~lower_bounds:false ~revdeps:false "opam-2.0" default_variant ::
build ~opam_version:`V2_1 ~lower_bounds:false ~revdeps:false "opam-2.1" default_variant ::
List.filter_map (fun v ->
match Ocaml_version.extra v with
| None -> None
Expand All @@ -220,35 +220,23 @@ let build_with_cluster ~ocluster ~analysis ~lint ~master source =
(* TODO: The same code is used in docker-base-images *)
let label = String.map (function '+' -> '-' | c -> c) label in
let variant = Variant.v ~arch:`X86_64 ~distro:master_distro ~compiler:(default_comp, Some label) in
Some (build ~opam_version:`V2_1 ~lower_bounds:false ~revdeps:false label variant)
Some (build ~opam_version ~lower_bounds:false ~revdeps:false label variant)
) (Ocaml_version.Opam.V2.switches `X86_64 default_compiler_full) @
List.filter_map (function
| `X86_64 -> None
| `Riscv64 -> None (* TODO: unlock this one when more machines are available *)
| arch ->
let label = Ocaml_version.to_opam_arch arch in
let variant = Variant.v ~arch ~distro:master_distro ~compiler:(default_comp, None) in
Some (build ~opam_version:`V2_1 ~lower_bounds:false ~revdeps:false label variant)
Some (build ~opam_version ~lower_bounds:false ~revdeps:false label variant)
) Ocaml_version.arches
in
let opam_2_0 =
[
Node.branch ~label:"compilers" compilers_2_0;
Node.branch ~label:"distributions" distributions_2_0;
]
in
let opam_2_1 =
[
Node.branch ~label:"compilers" compilers_2_1;
Node.branch ~label:"distributions" distributions_2_1;
Node.branch ~label:"extras" extras;
]
in
Node.root [
Node.leaf ~label:"(analysis)" analysis;
Node.leaf ~label:"(lint)" lint;
Node.branch ~label:"opam-2.0" opam_2_0;
Node.branch ~label:"opam-2.1" opam_2_1;
Node.branch ~label:"compilers" compilers;
Node.branch ~label:"distributions" distributions;
Node.branch ~label:"extras" extras;
]


Expand Down