Skip to content

Commit 9c65e1b

Browse files
authored
Merge pull request #17461 from MinaProtocol/dkijania/verify_dockers_in_ci
Post build Verification for dockers and debians in CI
2 parents 39d4282 + fb4d425 commit 9c65e1b

File tree

10 files changed

+392
-137
lines changed

10 files changed

+392
-137
lines changed

buildkite/scripts/release/manager.sh

Lines changed: 153 additions & 100 deletions
Large diffs are not rendered by default.

buildkite/src/Command/DockerImage.dhall

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ let Network = ../Constants/Network.dhall
2626

2727
let DockerPublish = ../Constants/DockerPublish.dhall
2828

29+
let VerifyDockers = ../Command/Packages/VerifyDockers.dhall
30+
31+
let Extensions = ../Lib/Extensions.dhall
32+
2933
let ReleaseSpec =
3034
{ Type =
3135
{ deps : List Command.TaggedKey.Type
@@ -45,6 +49,7 @@ let ReleaseSpec =
4549
, build_flags : BuildFlags.Type
4650
, step_key_suffix : Text
4751
, docker_publish : DockerPublish.Type
52+
, verify : Bool
4853
, if : Optional B/If
4954
}
5055
, default =
@@ -65,6 +70,7 @@ let ReleaseSpec =
6570
, no_cache = False
6671
, no_debian = False
6772
, step_key_suffix = "-docker-image"
73+
, verify = False
6874
, if = None B/If
6975
}
7076
}
@@ -105,6 +111,43 @@ let generateStep =
105111

106112
else " && ./scripts/debian/aptly.sh stop"
107113

114+
let suffix =
115+
Extensions.joinOptionals
116+
"-"
117+
[ merge
118+
{ Standard = None Text
119+
, Mainnet = None Text
120+
, Dev = None Text
121+
, Lightnet = Some
122+
"${Profiles.toSuffixLowercase spec.deb_profile}"
123+
}
124+
spec.deb_profile
125+
, merge
126+
{ None = None Text
127+
, Instrumented = Some
128+
"${BuildFlags.toSuffixLowercase spec.build_flags}"
129+
}
130+
spec.build_flags
131+
]
132+
133+
let maybeVerify =
134+
if spec.verify
135+
&& DockerPublish.shouldPublish
136+
spec.docker_publish
137+
spec.service
138+
139+
then " && "
140+
++ VerifyDockers.verify
141+
VerifyDockers.Spec::{
142+
, artifacts = [ spec.service ]
143+
, networks = [ spec.network ]
144+
, version = spec.deb_version
145+
, codenames = [ spec.deb_codename ]
146+
, suffix = suffix
147+
}
148+
149+
else ""
150+
108151
let buildDockerCmd =
109152
"./scripts/docker/build.sh"
110153
++ " --service ${Artifacts.dockerName spec.service}"
@@ -151,6 +194,7 @@ let generateStep =
151194
++ buildDockerCmd
152195
++ " && "
153196
++ releaseDockerCmd
197+
++ maybeVerify
154198
)
155199
]
156200

@@ -169,6 +213,7 @@ let generateStep =
169213
++ " && "
170214
++ releaseDockerCmd
171215
++ maybeStopDebianRepo
216+
++ maybeVerify
172217
)
173218
]
174219
}

buildkite/src/Command/MinaArtifact.dhall

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ let docker_step
163163
, docker_publish = docker_publish
164164
, deb_repo = DebianRepo.Type.Local
165165
, deb_legacy_version = spec.deb_legacy_version
166+
, verify = True
166167
, if = spec.if
167168
}
168169
]
@@ -213,6 +214,7 @@ let docker_step
213214
, docker_publish = docker_publish
214215
, deb_repo = DebianRepo.Type.Local
215216
, deb_legacy_version = spec.deb_legacy_version
217+
, verify = True
216218
, if = spec.if
217219
}
218220
]
@@ -226,6 +228,7 @@ let docker_step
226228
, docker_publish = docker_publish
227229
, deb_repo = DebianRepo.Type.Local
228230
, deb_legacy_version = spec.deb_legacy_version
231+
, verify = True
229232
, if = spec.if
230233
}
231234
]

buildkite/src/Command/PublishPackages.dhall renamed to buildkite/src/Command/Packages/Publish.dhall

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,40 @@
1-
let Prelude = ../External/Prelude.dhall
1+
let Prelude = ../../External/Prelude.dhall
22

3-
let Optional/map = Prelude.Optional.map
4-
5-
let Optional/default = Prelude.Optional.default
6-
7-
let List/drop = Prelude.List.drop
3+
let Extensions = ../../Lib/Extensions.dhall
84

9-
let List/concatMap = Prelude.List.concatMap
5+
let join = Extensions.join
106

11-
let Text/concat = Prelude.Text.concat
12-
13-
let Artifacts = ../Constants/Artifacts.dhall
14-
15-
let Size = ../Command/Size.dhall
7+
let Optional/map = Prelude.Optional.map
168

17-
let Package = ../Constants/DebianPackage.dhall
9+
let Optional/default = Prelude.Optional.default
1810

19-
let Network = ../Constants/Network.dhall
11+
let Artifacts = ../../Constants/Artifacts.dhall
2012

21-
let DebianChannel = ../Constants/DebianChannel.dhall
13+
let Size = ../../Command/Size.dhall
2214

23-
let Profiles = ../Constants/Profiles.dhall
15+
let Package = ../../Constants/DebianPackage.dhall
2416

25-
let Artifact = ../Constants/Artifacts.dhall
17+
let Network = ../../Constants/Network.dhall
2618

27-
let DebianVersions = ../Constants/DebianVersions.dhall
19+
let DebianChannel = ../../Constants/DebianChannel.dhall
2820

29-
let DebianRepo = ../Constants/DebianRepo.dhall
21+
let Profiles = ../../Constants/Profiles.dhall
3022

31-
let Toolchain = ../Constants/Toolchain.dhall
23+
let Artifact = ../../Constants/Artifacts.dhall
3224

33-
let ContainerImages = ../Constants/ContainerImages.dhall
25+
let DebianVersions = ../../Constants/DebianVersions.dhall
3426

35-
let Command = ./Base.dhall
27+
let DebianRepo = ../../Constants/DebianRepo.dhall
3628

37-
let Cmd = ../Lib/Cmds.dhall
29+
let Toolchain = ../../Constants/Toolchain.dhall
3830

39-
let Mina = ./Mina.dhall
31+
let ContainerImages = ../../Constants/ContainerImages.dhall
4032

41-
let join =
42-
\(sep : Text)
43-
-> \(xs : List Text)
44-
-> let concatWithSepAtStart =
45-
List/concatMap Text Text (\(item : Text) -> [ sep, item ]) xs
33+
let Command = ../Base.dhall
4634

47-
let concat = List/drop 1 Text concatWithSepAtStart
35+
let Cmd = ../../Lib/Cmds.dhall
4836

49-
in Text/concat concat
37+
let Mina = ../Mina.dhall
5038

5139
let Spec =
5240
{ Type =
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
let Prelude = ../../External/Prelude.dhall
2+
3+
let Extensions = ../../Lib/Extensions.dhall
4+
5+
let join = Extensions.join
6+
7+
let Artifacts = ../../Constants/Artifacts.dhall
8+
9+
let Package = ../../Constants/DebianPackage.dhall
10+
11+
let Network = ../../Constants/Network.dhall
12+
13+
let Artifact = ../../Constants/Artifacts.dhall
14+
15+
let DebianVersions = ../../Constants/DebianVersions.dhall
16+
17+
let Spec =
18+
{ Type =
19+
{ artifacts : List Artifact.Type
20+
, networks : List Network.Type
21+
, version : Text
22+
, codenames : List DebianVersions.DebVersion
23+
, published_to_docker_io : Bool
24+
, suffix : Optional Text
25+
}
26+
, default =
27+
{ artifacts = [] : List Package.Type
28+
, networks = [ Network.Type.Mainnet, Network.Type.Devnet ]
29+
, codenames =
30+
[ DebianVersions.DebVersion.Focal
31+
, DebianVersions.DebVersion.Bullseye
32+
]
33+
, published_to_docker_io = False
34+
, suffix = None Text
35+
}
36+
}
37+
38+
let joinArtifacts
39+
: Spec.Type -> Text
40+
= \(spec : Spec.Type) -> join "," (Artifacts.dockerNames spec.artifacts)
41+
42+
let joinNetworks
43+
: Spec.Type -> Text
44+
= \(spec : Spec.Type)
45+
-> join
46+
","
47+
( Prelude.List.map
48+
Network.Type
49+
Text
50+
(\(network : Network.Type) -> Network.lowerName network)
51+
spec.networks
52+
)
53+
54+
let joinCodenames
55+
: Spec.Type -> Text
56+
= \(spec : Spec.Type)
57+
-> join
58+
","
59+
( Prelude.List.map
60+
DebianVersions.DebVersion
61+
Text
62+
( \(debian : DebianVersions.DebVersion)
63+
-> DebianVersions.lowerName debian
64+
)
65+
spec.codenames
66+
)
67+
68+
let verify
69+
: Spec.Type -> Text
70+
= \(spec : Spec.Type)
71+
-> ". ./buildkite/scripts/export-git-env-vars.sh && "
72+
++ "./buildkite/scripts/release/manager.sh verify "
73+
++ "--artifacts ${joinArtifacts spec} "
74+
++ "--networks ${joinNetworks spec} "
75+
++ "--version ${spec.version} "
76+
++ "--codenames ${joinCodenames spec} "
77+
++ merge
78+
{ None = ""
79+
, Some = \(suffix : Text) -> "--docker-suffix ${suffix} "
80+
}
81+
spec.suffix
82+
++ "--only-dockers "
83+
84+
in { verify = verify, Spec = Spec }

buildkite/src/Entrypoints/PublishPackages.dhall

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
let S = ../Lib/SelectFiles.dhall
22

3-
let PublishPackages = ../Command/PublishPackages.dhall
3+
let PublishPackages = ../Command/Packages/Publish.dhall
44

55
let Profile = ../Constants/Profiles.dhall
66

buildkite/src/Jobs/Promote/AutoPromoteNightly.dhall

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ let PipelineTag = ../../Pipeline/Tag.dhall
2222

2323
let Pipeline = ../../Pipeline/Dsl.dhall
2424

25-
let PublishPackages = ../../Command/PublishPackages.dhall
25+
let PublishPackages = ../../Command/Packages/Publish.dhall
2626

2727
let new_tags =
2828
\(codename : DebianVersions.DebVersion)

buildkite/src/Lib/Extensions.dhall

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
-- This package provides utility functions which are not part of the
2+
-- standard Prelude, such as `join` for concatenating lists of text with a separator.
3+
4+
let Prelude = ../External/Prelude.dhall
5+
6+
let List/concatMap = Prelude.List.concatMap
7+
8+
let List/drop = Prelude.List.drop
9+
10+
let List/fold_ = Prelude.List.fold
11+
12+
let Text/concat = Prelude.Text.concat
13+
14+
let join =
15+
\(sep : Text)
16+
-> \(xs : List Text)
17+
-> let concatWithSepAtStart =
18+
List/concatMap Text Text (\(item : Text) -> [ sep, item ]) xs
19+
20+
let concat = List/drop 1 Text concatWithSepAtStart
21+
22+
in Text/concat concat
23+
24+
let joinOptionals
25+
: Text -> List (Optional Text) -> Optional Text
26+
= \(sep : Text)
27+
-> \(xs : List (Optional Text))
28+
-> List/fold_
29+
(Optional Text)
30+
xs
31+
(Optional Text)
32+
( \(acc : Optional Text)
33+
-> \(x : Optional Text)
34+
-> merge
35+
{ Some =
36+
\(text : Text)
37+
-> merge
38+
{ None = Some text
39+
, Some =
40+
\(accText : Text)
41+
-> Some (accText ++ sep ++ text)
42+
}
43+
acc
44+
, None = acc
45+
}
46+
x
47+
)
48+
(None Text)
49+
50+
in { join = join, joinOptionals = joinOptionals }

changes/17461.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added post docker & debian build verification jobs to CI

scripts/docker/verify.sh

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#!/usr/bin/env bash
2-
set +x
2+
3+
# Verify that the Docker image for a given package and version is working correctly.
4+
# This script pulls the Docker image and runs a set of simplest commands (fetch help and version)
5+
# to ensure that the package dependencies are correctly resolved.
6+
# Usage: ./scripts/docker/verify.sh -p <package> -c <codename> [-s <suffix>] [-r <repo>] [-v <version>]
7+
8+
set -eo pipefail
39

410
REPO=gcr.io/o1labs-192920
511
VERSION=3.0.0-f872d85
@@ -13,9 +19,34 @@ while [[ "$#" -gt 0 ]]; do case $1 in
1319
*) echo "Unknown parameter passed: $1"; exit 1;;
1420
esac; shift; done
1521

16-
if ! docker pull $REPO/$PACKAGE:$VERSION-${CODENAME}${SUFFIX} ; then
22+
COMMANDS=(--version --help)
23+
24+
case $PACKAGE in
25+
mina-archive) APPS=mina-archive ;;
26+
mina-logproc) APPS=(); echo "skipped execution for mina-logproc" ;;
27+
mina-rosetta*) APPS=("mina" "mina-archive" "mina-rosetta") ;;
28+
mina-*) APPS=("mina");;
29+
*) echo "❌ Unknown package passed: $PACKAGE"; exit 1;;
30+
esac
31+
32+
DOCKER_IMAGE="$REPO/$PACKAGE:$VERSION-${CODENAME}${SUFFIX}"
33+
34+
if ! docker pull "$DOCKER_IMAGE" ; then
1735
echo "❌ Docker verification for $CODENAME $PACKAGE failed"
36+
echo "❌ Please check if the image $DOCKER_IMAGE exists."
1837
exit 1
19-
else
20-
echo "✅ Docker verification for $CODENAME $PACKAGE passed"
2138
fi
39+
40+
for APP in "${APPS[@]}"; do
41+
for COMMAND in "${COMMANDS[@]}"; do
42+
echo "📋 Testing $APP $COMMAND in $DOCKER_IMAGE"
43+
# Do not quote $COMMAND, because it may contain spaces or other special characters
44+
# shellcheck disable=SC2086
45+
if ! docker run --entrypoint "$APP" --rm "$DOCKER_IMAGE" $COMMAND; then
46+
echo "❌ KO: ERROR running $APP $COMMAND"
47+
exit 1
48+
fi
49+
done
50+
done
51+
52+
echo '✅ OK: ALL WORKED FINE!'

0 commit comments

Comments
 (0)