Skip to content

Commit

Permalink
LF check stable proto with buf and md5sum. (#11888)
Browse files Browse the repository at this point in the history
The resulting tests should be faster and more reliable

fixes #11443

CHANGELOG_BEGIN
CHANGELOG_END
  • Loading branch information
remyhaemmerle-da authored Nov 25, 2021
1 parent 056fc52 commit b0dda53
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 248 deletions.
9 changes: 9 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -908,3 +908,12 @@ dev_env_tool(
],
win_tool = "msys2",
)

nixpkgs_package(
name = "buf",
attribute_path = "buf",
fail_not_supported = False,
nix_file = "//nix:bazel.nix",
nix_file_deps = common_nix_file_deps,
repositories = dev_env_nix_repos,
)
50 changes: 36 additions & 14 deletions daml-lf/archive/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,6 @@ da_scala_test_suite(
data = [
":DarReaderTest.dalf",
":DarReaderTest.dar",
":daml_lf_1.11_archive_proto_srcs",
":daml_lf_1.12_archive_proto_srcs",
":daml_lf_1.13_archive_proto_srcs",
":daml_lf_1.14_archive_proto_srcs",
":daml_lf_1.6_archive_proto_srcs",
":daml_lf_1.7_archive_proto_srcs",
":daml_lf_1.8_archive_proto_srcs",
],
scala_deps = [
"@maven//:org_scalacheck_scalacheck",
Expand All @@ -152,13 +145,6 @@ da_scala_test_suite(
],
scalacopts = lf_scalacopts,
deps = [
":daml_lf_1.11_archive_proto_java",
":daml_lf_1.12_archive_proto_java",
":daml_lf_1.13_archive_proto_java",
":daml_lf_1.14_archive_proto_java",
":daml_lf_1.6_archive_proto_java",
":daml_lf_1.7_archive_proto_java",
":daml_lf_1.8_archive_proto_java",
":daml_lf_archive_reader",
":daml_lf_dev_archive_proto_java",
"//bazel_tools/runfiles:scala_runfiles",
Expand Down Expand Up @@ -211,3 +197,39 @@ da_scala_binary(
"//daml-lf/language",
],
)

SNASPSHOT_VERSIONS = [
"1.11",
"1.12",
"1.13",
"1.14",
]

[
sh_test(
name = "proto_breaking_changes_%s_test" % version,
srcs = ["proto_breaking_changes.sh"],
args = [
"$(location @buf//:bin/buf)",
"%s" % mangle_for_java(version),
],
data = [
"buf.yaml",
"proto_breaking_changes.sh",
"src/main/protobuf/com/daml/daml_lf_dev",
":daml_lf_%s_archive_proto_srcs" % version,
":daml_lf_dev_archive_proto_srcs",
"@buf//:bin/buf",
],
)
for version in SNASPSHOT_VERSIONS
] if not is_windows else []

sh_test(
name = "proto_immutability_test",
srcs = ["proto_check_hash.sh"],
data = [
":daml_lf_%s_archive_proto_srcs" % version
for version in SNASPSHOT_VERSIONS
],
) if not is_windows else []
8 changes: 8 additions & 0 deletions daml-lf/archive/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

version: v1beta1

breaking:
use:
- WIRE
19 changes: 19 additions & 0 deletions daml-lf/archive/proto_breaking_changes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

set -e

readonly arch_dir="daml-lf/archive"
readonly buf_exe="$1"
readonly version="$2"
readonly config_file="${arch_dir}/buf.yaml"
readonly stable_dir="${arch_dir}/src/stable/protobuf"
readonly main_dir="${arch_dir}/src/main/protobuf"

#We check the directories contains exactly 2 proto files
for dir in "${stable_dir}" "${main_dir}"; do
find "${dir}/" -follow -name '*.proto' | wc -l | grep -x 2
done

"${buf_exe}" breaking --config "${config_file}" --against "${stable_dir}" "${main_dir}"
21 changes: 21 additions & 0 deletions daml-lf/archive/proto_check_hash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0


set -e

declare -a checkSums=(
"500eefd480e9af6940adf12e7ec4c2cf4975d4cb9b25096c15edb0d57d364de8 daml-lf/archive/src/stable/protobuf/com/daml/daml_lf_1_14/daml_lf_1.proto"
"455dfb894ce9648a86dadb408d1ee96c36d180e0f1d625706371ea9eca95c767 daml-lf/archive/src/stable/protobuf/com/daml/daml_lf_1_14/daml_lf.proto"
"83207610fc117b47ef1da586e36c791706504911ff41cbee8fc5d1da12128147 daml-lf/archive/src/stable/protobuf/com/daml/daml_lf_1_12/daml_lf_1.proto"
"6dbc0a0288c2447af690284e786c3fc1b58a296f2786e9cd5b4053069ff7c045 daml-lf/archive/src/stable/protobuf/com/daml/daml_lf_1_12/daml_lf.proto"
"6d0869fd8b326cc82f7507ec9deb37520af23ccc4c03a78af623683eb5df2bee daml-lf/archive/src/stable/protobuf/com/daml/daml_lf_1_13/daml_lf_1.proto"
"2038b49e33825c4730b0119472073f3d5da9b0bd3df2f6d21d9d338c04a49c47 daml-lf/archive/src/stable/protobuf/com/daml/daml_lf_1_13/daml_lf.proto"
"9a9c86f4072ec08ac292517d377bb07b1436c2b9133da9ba03216c3ae8d3d27c daml-lf/archive/src/stable/protobuf/com/daml/daml_lf_1_11/daml_lf_1.proto"
"05eb95f6bb15042624d2ca89d366e3bcd8618934471c6093efeecc09bb9d7df4 daml-lf/archive/src/stable/protobuf/com/daml/daml_lf_1_11/daml_lf.proto"
)

for checkSum in "${checkSums[@]}"; do
echo ${checkSum} | sha256sum -c
done

This file was deleted.

1 change: 1 addition & 0 deletions nix/bazel.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
}:
let shared = rec {
inherit (pkgs)
buf
coreutils
curl
docker
Expand Down

0 comments on commit b0dda53

Please sign in to comment.