diff --git a/lib/cluster_build.ml b/lib/cluster_build.ml index f9156f3..782648e 100644 --- a/lib/cluster_build.ml +++ b/lib/cluster_build.ml @@ -107,9 +107,9 @@ module Op = struct let base = Spec.base_to_string base in match ty with | `Opam (`List_revdeps { opam_version }, pkg) -> - Opam_build.revdeps ~for_docker ~opam_version ~base ~variant ~pkg + Opam_build.revdeps ~for_docker ~opam_version ~base ~variant pkg | `Opam (`Build { revdep; lower_bounds; with_tests; opam_version }, pkg) -> - Opam_build.spec ~for_docker ~opam_version ~base ~variant ~revdep ~lower_bounds ~with_tests ~pkg + Opam_build.spec ~for_docker ~opam_version ~base ~variant ~revdep ~lower_bounds ~with_tests pkg in Current.Job.write job (Fmt.str "@.\ diff --git a/lib/local_build.ml b/lib/local_build.ml index 7a013a8..e88b3aa 100644 --- a/lib/local_build.ml +++ b/lib/local_build.ml @@ -77,6 +77,7 @@ module Op = struct master : Current_git.Commit.t; urgent : ([`High | `Low] -> bool) option; base : Spec.base; + test_config : Integration_test.t option; } let id = "ci-build" @@ -138,7 +139,7 @@ module Op = struct end | _ -> Lwt_result.return "" - let build { config; master = _; urgent = _; base } job + let build { config; master = _; urgent = _; base; test_config } job { Key.commit; ty; variant } = let { docker_context; pool; build_timeout } = config in let os = match Variant.os variant with @@ -148,9 +149,9 @@ module Op = struct let base = Spec.base_to_string base in match ty with | `Opam (`List_revdeps { opam_version }, pkg) -> - Opam_build.revdeps ~for_docker:true ~opam_version ~base ~variant ~pkg + Opam_build.revdeps ~test_config ~for_docker:true ~opam_version ~base ~variant pkg | `Opam (`Build { revdep; lower_bounds; with_tests; opam_version }, pkg) -> - Opam_build.spec ~for_docker:true ~opam_version ~base ~variant ~revdep ~lower_bounds ~with_tests ~pkg + Opam_build.spec ~for_docker:true ~opam_version ~base ~variant ~revdep ~lower_bounds ~with_tests pkg in let base = match base with @@ -209,7 +210,7 @@ let v ?test_config ~label ~spec ~base ~master ~urgent commit = and> commit = Git.fetch commit and> master and> urgent in - let t = { Op.config = local_builder; master; urgent; base } in + let t = { Op.config = local_builder; master; urgent; base; test_config } in match test_config with | None -> BC.get t { commit; ty; variant } @@ -236,7 +237,7 @@ let list_revdeps ?test_config ~variant ~opam_version ~pkgopt ~base ~master ~afte and> commit = Git.fetch commit and> master and> () = after in - let t = { Op.config = local_builder; master; urgent; base } in + let t = { Op.config = local_builder; master; urgent; base; test_config } in let ty = `Opam (`List_revdeps {Spec.opam_version}, pkg) in let f () = BC.get t { commit; ty; variant } diff --git a/lib/opam_build.ml b/lib/opam_build.ml index fea3a9b..1a3b5db 100644 --- a/lib/opam_build.ml +++ b/lib/opam_build.ml @@ -117,7 +117,7 @@ let setup_repository ~variant ~for_docker ~opam_version = (* TODO: MacOS seems to have a bug in (copy ...) so I am forced to remove the (workdir ...) here. Otherwise the "opam pin" after the "opam repository set-url" will fail (cannot find the new package for some reason) *) run "%s -f %s/bin/opam-%s %s/bin/opam" ln prefix opam_version_str prefix :: - run ~network "opam init --reinit%s -ni" opamrc :: (* TODO: Remove ~network when https://github.com/ocurrent/ocaml-dockerfile/pull/132 is merged *) + run "opam init --reinit%s -ni" opamrc :: run "uname -rs && opam exec -- ocaml -version && opam --version" :: env "OPAMDOWNLOADJOBS" "1" :: (* Try to avoid github spam detection *) env "OPAMERRLOGLEN" "0" :: (* Show the whole log if it fails *) @@ -137,7 +137,7 @@ let set_personality ~variant = else [] -let spec ~for_docker ~opam_version ~base ~variant ~revdep ~lower_bounds ~with_tests ~pkg = +let spec ~for_docker ~opam_version ~base ~variant ~revdep ~lower_bounds ~with_tests pkg = let opam_install = opam_install ~variant ~opam_version in let revdep = match revdep with | None -> [] @@ -159,11 +159,23 @@ let spec ~for_docker ~opam_version ~base ~variant ~revdep ~lower_bounds ~with_te @ tests ) -let revdeps ~for_docker ~opam_version ~base ~variant ~pkg = +(* If we are integration-testing the revdeps, we replace the + existing opam-repository with a dummy one. However, this + removes the required base compiler packages. This command + pins them to keep them around. + Related: https://github.com/ocaml/opam/issues/5895 *) +let keep_installed = function + | Some Integration_test.List_revdeps -> [ + Obuilder_spec.run "for pkg in $(opam list -s --installed) ; do opam pin --current \"$pkg\" ; done" + ] + | _ -> [] + +let revdeps ?(test_config=None) ~for_docker ~opam_version ~base ~variant pkg = let open Obuilder_spec in let pkg = Filename.quote (OpamPackage.to_string pkg) in Obuilder_spec.stage ~from:base ( setup_repository ~variant ~for_docker ~opam_version + @ keep_installed test_config @ [ run "echo '@@@OUTPUT' && \ opam list -s --color=never --depends-on %s --coinstallable-with %s --installable --all-versions --depopts && \ diff --git a/lib/opam_build.mli b/lib/opam_build.mli index e6619ac..c8e2906 100644 --- a/lib/opam_build.mli +++ b/lib/opam_build.mli @@ -6,13 +6,14 @@ val spec : revdep:OpamPackage.t option -> lower_bounds:bool -> with_tests:bool -> - pkg:OpamPackage.t -> + OpamPackage.t -> Obuilder_spec.t val revdeps : + ?test_config:Integration_test.t option -> for_docker:bool -> opam_version:[`V2_0 | `V2_1 | `Dev] -> base:string -> variant:Variant.t -> - pkg:OpamPackage.t -> + OpamPackage.t -> Obuilder_spec.t diff --git a/test/patches/a-1-insignificant-change.patch b/test/patches/a-1-insignificant-change.patch new file mode 100644 index 0000000..a69100f --- /dev/null +++ b/test/patches/a-1-insignificant-change.patch @@ -0,0 +1,26 @@ +diff --git a/packages/a-1/a-1.0.0.1/opam b/packages/a-1/a-1.0.0.1/opam +index 5246a83..c17a1ba 100644 +--- a/packages/a-1/a-1.0.0.1/opam ++++ b/packages/a-1/a-1.0.0.1/opam +@@ -1,7 +1,7 @@ + opam-version: "2.0" + synopsis: "Synopsis" + description: "Description" +-maintainer: "Maintainer" ++maintainer: "Another maintainer" + author: "Author" + license: "Apache-2.0" + homepage: "https://github.com/ocurrent/opam-repo-ci" +diff --git a/packages/a-1/a-1.0.0.2/opam b/packages/a-1/a-1.0.0.2/opam +index 5246a83..c018682 100644 +--- a/packages/a-1/a-1.0.0.2/opam ++++ b/packages/a-1/a-1.0.0.2/opam +@@ -1,7 +1,7 @@ + opam-version: "2.0" + synopsis: "Synopsis" + description: "Description" +-maintainer: "Maintainer" ++maintainer: "Someone else" + author: "Author" + license: "Apache-2.0" + homepage: "https://github.com/ocurrent/opam-repo-ci" diff --git a/test/revdeps-correct.t b/test/revdeps.t similarity index 93% rename from test/revdeps-correct.t rename to test/revdeps.t index ce18371..4f27d46 100644 --- a/test/revdeps-correct.t +++ b/test/revdeps.t @@ -7,4 +7,5 @@ $ git add . $ git commit -qm a-1-update $ opam-repo-ci-local --repo="." --branch=new-branch --revdeps-only - Ok () + b.0.0.1 + b.0.0.2