Skip to content

Commit ab8c41d

Browse files
authored
Merge pull request #11570 from MinaProtocol/ylecornec/check_opam_switch-develop
check opam switch - develop
2 parents 87db948 + d632c21 commit ab8c41d

File tree

11 files changed

+67
-15
lines changed

11 files changed

+67
-15
lines changed

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,15 @@ ocaml_version:
7070
ocaml_word_size:
7171
@if ! ocamlopt -config | grep "word_size:" | grep $(WORD_SIZE); then echo "invalid machine word size, expected $(WORD_SIZE)" ; exit 1; fi
7272

73-
ocaml_checks: ocaml_version ocaml_word_size
73+
74+
# Checks that the current opam switch contains the packages from opam.export at the same version.
75+
# This check is disabled in the pure nix environment (that does not use opam).
76+
check_opam_switch:
77+
ifneq ($(DISABLE_CHECK_OPAM_SWITCH), true)
78+
check_opam_switch opam.export
79+
endif
80+
81+
ocaml_checks: ocaml_version ocaml_word_size check_opam_switch
7482

7583
libp2p_helper:
7684
make -C src/app/libp2p_helper

README-dev.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ Refer to [/dev](/dev).
5050

5151
Mina has a variety of opam and system dependencies.
5252

53-
To get all the opam dependencies you need, you run `opam switch import
54-
src/opam.export`.
53+
To get all the opam dependencies you need, you run `opam switch import opam.export`.
54+
> *_NOTE:_* The switch provides a `dune_wrapper` binary that you can use instead of dune, and will fail early if your switch becomes out of sync with the `opam.export` file.
5555
5656
Some of our dependencies aren't taken from `opam`, and aren't integrated
5757
with `dune`, so you need to add them manually, by running `scripts/pin-external-packages.sh`.

buildkite/src/Constants/ContainerImages.dhall

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
-- NOTE: minaToolchainStretch is also used for building Ubuntu Bionic packages in CI
33
{
44
toolchainBase = "codaprotocol/ci-toolchain-base:v3",
5-
minaToolchainBullseye = "gcr.io/o1labs-192920/mina-toolchain@sha256:106a6c5a5a8a4df8b26464edf9b0bd1cec35124ecf7d8340af4561a54812c701",
6-
minaToolchainBuster = "gcr.io/o1labs-192920/mina-toolchain@sha256:1fe11f2e4f6d7483411d0966509cb5d0b108d903e7dccee94b97a710be78ff40",
7-
minaToolchainStretch = "gcr.io/o1labs-192920/mina-toolchain@sha256:56e8058904ada5081e0839468c7ac7c7d2438a49a452e9f263b271bc87946db5",
8-
minaToolchainFocal = "gcr.io/o1labs-192920/mina-toolchain@sha256:421b0dcf6adbd2622264b45b1a5deadcc0ace69841fd484492cdd7e3bec330bd",
5+
minaToolchainStretch = "gcr.io/o1labs-192920/mina-toolchain@sha256:36ed8f899635354fadf05a8504c054f4ca2a71950164c4aa8bea31f4f760afdb",
6+
minaToolchainBuster = "gcr.io/o1labs-192920/mina-toolchain@sha256:6de0eb2aded56dd3f1c21df727e2d1ea53194095c0a45b025eaa93cc74166185",
7+
minaToolchainBullseye = "gcr.io/o1labs-192920/mina-toolchain@sha256:77444cd510dc40efd8c62e5c1a53485a05f3e42d4f883d2cfe74158847763af2",
8+
minaToolchainFocal = "gcr.io/o1labs-192920/mina-toolchain@sha256:0b6167a26de97ca715bdcc4cbe759e3117d2fd0c0f5e03038a382fc25c60afcb",
99
delegationBackendToolchain = "gcr.io/o1labs-192920/delegation-backend-production@sha256:8ca5880845514ef56a36bf766a0f9de96e6200d61b51f80d9f684a0ec9c031f4",
1010
elixirToolchain = "elixir:1.10-alpine",
1111
nodeToolchain = "node:14.13.1-stretch-slim",

buildkite/src/Jobs/Release/MinaToolchainArtifact.dhall

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Pipeline.build
2323
S.strictlyStart (S.contains "dockerfiles/stages/2-"),
2424
S.strictlyStart (S.contains "dockerfiles/stages/3-"),
2525
S.strictlyStart (S.contains "buildkite/src/Jobs/Release/MinaToolchainArtifact"),
26-
S.strictly (S.contains "src/opam.export")
26+
S.strictly (S.contains "opam.export")
2727
],
2828
path = "Release",
2929
name = "MinaToolchainArtifact"

dockerfiles/stages/2-opam-deps

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ WORKDIR $HOME/$MINA_DIR
3636
ENV OPAMYES 1
3737

3838
# --- Import Opam Switch
39-
# TODO: handle this opam work without cloning the full repository (directly pull src/opam.export)
40-
RUN opam switch import src/opam.export
39+
# TODO: handle this opam work without cloning the full repository (directly pull opam.export)
40+
RUN opam switch import opam.export
4141

4242
# --- Pin external packages / submodules
43-
# TODO: Would be really nice to pull this script, the git submodules, and src/opam.export exclusively in this stage
43+
# TODO: Would be really nice to pull this script, the git submodules, and opam.export exclusively in this stage
4444
RUN eval $(opam config env) \
4545
&& scripts/pin-external-packages.sh \
4646
&& opam clean --logs -cs

nix/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ If you wish to update all the inputs of this flake, run `nix flake update` . If
196196

197197
The "pure" build is performed with the help of
198198
[opam-nix](https://github.com/tweag/opam-nix). The switch is imported
199-
from `src/opam.export`, and then external deps (from `src/external`)
199+
from `opam.export`, and then external deps (from `src/external`)
200200
are added on top. Also, all in-tree Rust dependencies
201201
(`kimchi_bindings` in particular) are built as separate derivations
202202
using `rustPlatform`. Implicit native dependencies are taken from

nix/checks.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ inputs: pkgs: {
5151
buildPhase = "make check-format";
5252
installPhase = "touch $out";
5353
meta.checkDescription = "that OCaml code is formatted properly";
54+
DISABLE_CHECK_OPAM_SWITCH = "true";
5455
};
5556

5657
# todo: libp2p_ipc

nix/impure-shell.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pkgs.mkShell {
3232
tput bold
3333
printf 'opam init --bare # Only if you are running opam for the first time\n'
3434
printf 'opam update\n'
35-
printf 'opam switch import src/opam.export --strict\n'
35+
printf 'opam switch import opam.export --strict\n'
3636
printf 'eval $(opam env)\n'
3737
printf './scripts/pin-external-packages.sh\n'
3838
tput sgr0

nix/ocaml.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ let
1515
opam-nix.makeOpamRepoRec ../src/external; # Pin external packages
1616
repos = [ external-repo inputs.opam-repository ];
1717

18-
export = opam-nix.importOpam ../src/opam.export;
18+
export = opam-nix.importOpam ../opam.export;
1919
external-packages = pkgs.lib.getAttrs [ "sodium" "base58" ]
2020
(builtins.mapAttrs (_: pkgs.lib.last) (opam-nix.listRepo external-repo));
2121

@@ -144,6 +144,7 @@ let
144144
# and copy it from within a dune rule
145145
# (see src/lib/crypto/kimchi_bindings/stubs/dune)
146146
MARLIN_PLONK_STUBS = "${pkgs.kimchi_bindings_stubs}";
147+
DISABLE_CHECK_OPAM_SWITCH = "true";
147148

148149
PLONK_WASM_NODEJS = "${pkgs.plonk_wasm}/nodejs";
149150
PLONK_WASM_WEB = "${pkgs.plonk_wasm}/web";

src/opam.export renamed to opam.export

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ roots: [
77
"bitstring.4.1.0"
88
"camlp4.4.14+1"
99
"capnp.3.4.0"
10+
"check_opam_switch.~dev"
1011
"cohttp-async.5.0.0"
1112
"core_extended.v0.14.0"
1213
"extlib.1.7.8"
@@ -68,6 +69,7 @@ installed: [
6869
"caqti-async.1.3.0"
6970
"caqti-driver-postgresql.1.5.1"
7071
"charInfo_width.1.1.0"
72+
"check_opam_switch.~dev"
7173
"cmdliner.1.0.3"
7274
"cohttp.5.0.0"
7375
"cohttp-async.5.0.0"
@@ -142,6 +144,7 @@ installed: [
142144
"merlin-extend.0.6.1"
143145
"mew.0.1.0"
144146
"mew_vi.0.5.0"
147+
"minicli.5.0.2"
145148
"mmap.1.1.0"
146149
"num.1.1"
147150
"ocaml.4.14.0"
@@ -163,7 +166,10 @@ installed: [
163166
"octavius.1.2.2"
164167
"odoc.2.1.0"
165168
"odoc-parser.1.0.0"
169+
"opam-core.2.1.2"
166170
"opam-depext.1.2.1"
171+
"opam-file-format.2.1.4"
172+
"opam-format.2.1.2"
167173
"parsexp.v0.14.2"
168174
"postgresql.5.0.0"
169175
"ppx_assert.v0.14.0"
@@ -243,11 +249,46 @@ installed: [
243249
"zed.3.1.0"
244250
]
245251
pinned: [
252+
"check_opam_switch.~dev"
246253
"graphql_ppx.1.2.2"
247254
"capnp.3.4.0"
248255
"rpc_parallel.v0.14.0"
249256
"async_kernel.v0.14.0"
250257
]
258+
package "check_opam_switch" {
259+
opam-version: "2.0"
260+
version: "~dev"
261+
synopsis:
262+
"A tool to check that the current opam environment is up to date with an opam.export file"
263+
description:
264+
"A tool to check that the current opam environment is up to date with an opam.export file"
265+
maintainer: "[email protected]"
266+
depends: [
267+
"dune" {>= "3.3"}
268+
"opam-core" {>= "2.0.0"}
269+
"opam-format" {>= "2.0.0"}
270+
"minicli" {>= "5.0.0"}
271+
"odoc" {with-doc}
272+
]
273+
build: [
274+
["dune" "subst"] {dev}
275+
[
276+
"dune"
277+
"build"
278+
"-p"
279+
name
280+
"-j"
281+
jobs
282+
"@install"
283+
"@runtest" {with-test}
284+
"@doc" {with-doc}
285+
]
286+
]
287+
url {
288+
src: "https://github.com/tweag/check_opam_switch/archive/d0aa49884e0f9fd4bbb2cd1a32b798a12f84b603.tar.gz"
289+
checksum: "sha256=24ab29ea4aff9da9d649f0b577c5d4e27ce2bef51058e139965cc9be25494a46"
290+
}
291+
}
251292
package "graphql_ppx" {
252293
opam-version: "2.0"
253294
version: "1.2.2"
@@ -278,6 +319,7 @@ package "graphql_ppx" {
278319
checksum: "sha256=8aff33988218c99a95a91fb04ef703a3b8cde0676b7a90ee72478959829867d8"
279320
}
280321
}
322+
281323
package "capnp" {
282324
opam-version: "2.0"
283325
version: "3.4.0"

scripts/select-opam-deps.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set -eou pipefail
88

99
RES=()
1010
for lib in $@; do
11-
RES+=($(cat src/opam.export | grep '"'"$lib"'\.' | awk -F'"' '{ print $2 }'))
11+
RES+=($(cat opam.export | grep '"'"$lib"'\.' | awk -F'"' '{ print $2 }'))
1212
done
1313

1414
echo "${RES[@]}"

0 commit comments

Comments
 (0)