diff --git a/lib/opam_build.ml b/lib/opam_build.ml index f0569f8d..21c0cc38 100644 --- a/lib/opam_build.ml +++ b/lib/opam_build.ml @@ -2,7 +2,7 @@ let download_cache = "opam-archives" let cache = [ Obuilder_spec.Cache.v download_cache ~target:"/home/opam/.opam/download-cache" ] let network = ["host"] -let opam_install ~upgrade_opam ~pin ~with_tests ~pkg = +let opam_install ~variant ~upgrade_opam ~pin ~with_tests ~pkg = let pkg = OpamPackage.to_string pkg in let open Obuilder_spec in let pin = @@ -16,34 +16,31 @@ let opam_install ~upgrade_opam ~pin ~with_tests ~pkg = [] in pin @ [ - run ~cache "opam remove -y %s" pkg; (* TODO: Replace by two calls to opam install + opam install -t using the OPAMDROPINSTALLEDPACKAGES feature *) - if upgrade_opam then - run ~cache ~network "opam install -y%s %s" (if with_tests then "t" else "") pkg - else - run ~cache ~network "opam depext -uivy%s %s" (if with_tests then "t" else "") pkg + run ~cache ~network {| + opam remove -y %s && opam %s%s %s + res=$? + test "$res" = 0 && exit 0 + test "$res" != 31 && exit 1 + export OPAMCLI=2.0 + build_dir=$(opam var prefix)/.opam-switch/build + failed=$(ls "$build_dir") + for pkg in $failed; do + if opam show -f x-ci-accept-failures: "$pkg" | grep -qF "\"%s\""; then + echo "A package failed and has been disabled for CI using the 'x-ci-accept-failures' field." + fi + done + exit 1 + |} + pkg + (if upgrade_opam then "install -y" else "depext -uivy") + (if with_tests then "t" else "") + pkg + (Variant.distribution variant) ] -let setup_repository ~upgrade_opam ~variant = +let setup_repository ~upgrade_opam = let open Obuilder_spec in - let variant = Variant.docker_tag variant in - let opam_extras = - if Astring.String.is_suffix ~affix:"-ocaml-4.07" variant || - Astring.String.is_suffix ~affix:"-ocaml-4.06" variant || - Astring.String.is_suffix ~affix:"-ocaml-4.05" variant || - Astring.String.is_suffix ~affix:"-ocaml-4.04" variant || - Astring.String.is_suffix ~affix:"-ocaml-4.03" variant || - Astring.String.is_suffix ~affix:"-ocaml-4.02" variant then - [ run ~cache ~network "opam install -y ocaml-secondary-compiler" ] (* Speed up builds for dune >= 2.0 *) - else - [] - in - let distro_extras = - if Astring.String.is_prefix ~affix:"fedora" variant then - [ run ~network "sudo dnf install -y findutils" ] (* (we need xargs) *) - else - [] - in (if upgrade_opam then [ run "sudo mv /usr/bin/opam-2.1 /usr/bin/opam"; env "OPAMDEPEXTYES" "1"] else []) @ @@ -51,7 +48,8 @@ let setup_repository ~upgrade_opam ~variant = env "OPAMERRLOGLEN" "0" :: (* Show the whole log if it fails *) env "OPAMSOLVERTIMEOUT" "500" :: (* Increase timeout. Poor mccs is doing its best *) env "OPAMPRECISETRACKING" "1" :: (* Mitigate /~https://github.com/ocaml/opam/issues/3997 *) - user ~uid:1000 ~gid:1000 :: distro_extras @ opam_extras @ [ + [ + user ~uid:1000 ~gid:1000; copy ["."] ~dst:"/src/"; run "opam repository set-url --strict default file:///src"; ] @@ -66,28 +64,28 @@ let spec ~upgrade_opam ~base ~variant ~revdep ~with_tests ~pkg = let open Obuilder_spec in let revdep = match revdep with | None -> [] - | Some revdep -> opam_install ~upgrade_opam ~pin:false ~with_tests:false ~pkg:revdep + | Some revdep -> opam_install ~variant ~upgrade_opam ~pin:false ~with_tests:false ~pkg:revdep and tests = match with_tests, revdep with - | true, None -> opam_install ~upgrade_opam ~pin:false ~with_tests:true ~pkg - | true, Some revdep -> opam_install ~upgrade_opam ~pin:false ~with_tests:true ~pkg:revdep + | true, None -> opam_install ~variant ~upgrade_opam ~pin:false ~with_tests:true ~pkg + | true, Some revdep -> opam_install ~variant ~upgrade_opam ~pin:false ~with_tests:true ~pkg:revdep | false, _ -> [] in { from = base; ops = set_personality ~variant - @ setup_repository ~upgrade_opam ~variant - @ opam_install ~upgrade_opam ~pin:true ~with_tests:false ~pkg + @ setup_repository ~upgrade_opam + @ opam_install ~variant ~upgrade_opam ~pin:true ~with_tests:false ~pkg @ revdep @ tests } -let revdeps ~with_tests ~base ~variant ~pkg = +let revdeps ~with_tests ~base ~variant:_ ~pkg = let open Obuilder_spec in let pkg = Filename.quote (OpamPackage.to_string pkg) in let with_tests = if with_tests then " --with-test" else "" in { from = base; ops = - setup_repository ~upgrade_opam:false ~variant + setup_repository ~upgrade_opam:false @ [ run "echo '@@@OUTPUT' && \ opam list -s --color=never --depends-on %s --coinstallable-with %s --installable --all-versions --recursive --depopts%s && \ diff --git a/lib/variant.ml b/lib/variant.ml index 80705f50..4e4b71fd 100644 --- a/lib/variant.ml +++ b/lib/variant.ml @@ -3,13 +3,22 @@ type arch = Ocaml_version.arch let arch_to_yojson arch = `String (Ocaml_version.string_of_arch arch) type t = { - docker_tag : string; + distribution : string; + ocaml_version : string; + ocaml_variant : string option; arch : arch; } [@@deriving to_yojson] let arch t = t.arch -let docker_tag t = t.docker_tag +let docker_tag t = + let variant = match t.ocaml_variant with + | None -> "" + | Some variant -> "-"^variant + in + t.distribution^"-ocaml-"^t.ocaml_version^variant +let distribution t = t.distribution -let pp f { docker_tag; arch } = Fmt.pf f "%s/%s" docker_tag (Ocaml_version.string_of_arch arch) +let pp f t = Fmt.pf f "%s/%s" (docker_tag t) (Ocaml_version.string_of_arch t.arch) -let v ~arch docker_tag = { arch; docker_tag } +let v ~arch ~distro ~compiler:(ocaml_version, ocaml_variant) = + { arch; distribution = distro; ocaml_version; ocaml_variant } diff --git a/service/pipeline.ml b/service/pipeline.ml index 27e68914..4aac1079 100644 --- a/service/pipeline.ml +++ b/service/pipeline.ml @@ -200,7 +200,7 @@ let build_with_cluster ~ocluster ~analysis ~master source = let v = Ocaml_version.with_just_major_and_minor v in let revdeps = Ocaml_version.equal v default_compiler in (* TODO: Remove this when the cluster is ready *) let v = Ocaml_version.to_string v in - let variant = Variant.v ~arch:`X86_64 @@ master_distro^"-ocaml-"^v in + let variant = Variant.v ~arch:`X86_64 ~distro:master_distro ~compiler:(v, None) in build ~revdeps v variant ) end @@ -213,14 +213,14 @@ let build_with_cluster ~ocluster ~analysis ~master source = acc else let distro = Dockerfile_distro.tag_of_distro distro in - let variant = Variant.v ~arch:`X86_64 @@ distro^"-ocaml-"^default_compiler in + let variant = Variant.v ~arch:`X86_64 ~distro ~compiler:(default_compiler, None) in build ~revdeps:false distro variant :: acc ) [] end and+ extras = let master_distro = Dockerfile_distro.tag_of_distro master_distro in let default_compiler = Ocaml_version.to_string default_compiler in - let flambda = Variant.v ~arch:`X86_64 (master_distro^"-ocaml-"^default_compiler^"-flambda") in + let flambda = Variant.v ~arch:`X86_64 ~distro:master_distro ~compiler:(default_compiler, Some "flambda") in Current.list_seq ( build ~upgrade_opam:true ~revdeps:false "flambda" flambda :: List.fold_left (fun acc arch -> @@ -228,7 +228,7 @@ let build_with_cluster ~ocluster ~analysis ~master source = acc else let label = Ocaml_version.to_opam_arch arch in - let variant = Variant.v ~arch (master_distro^"-ocaml-"^default_compiler) in + let variant = Variant.v ~arch ~distro:master_distro ~compiler:(default_compiler, None) in build ~upgrade_opam:true ~revdeps:false label variant :: acc ) [] Ocaml_version.arches )