Skip to content

Commit

Permalink
Introduce buf checks [KVL-980] (#10411)
Browse files Browse the repository at this point in the history
CHANGELOG_BEGIN
CHANGELOG_END
  • Loading branch information
miklos-da authored Jul 27, 2021
1 parent 1c4ae50 commit 4d12493
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
27 changes: 27 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

version: v1beta1
build:
roots:
- daml-lf/archive/src/main/protobuf/
- daml-lf/transaction/src/main/protobuf/
- ledger/ledger-configuration/protobuf/
- ledger/participant-state/kvutils/src/main/protobuf/
excludes:
# We have to exclude these to avoid duplicate definitions of e.g. Unit within the same package.
- daml-lf/archive/src/main/protobuf/com/daml/daml_lf_1_11/
- daml-lf/archive/src/main/protobuf/com/daml/daml_lf_1_12/
- daml-lf/archive/src/main/protobuf/com/daml/daml_lf_1_13/
- daml-lf/archive/src/main/protobuf/com/daml/daml_lf_1_14/
- daml-lf/archive/src/main/protobuf/com/digitalasset/

lint:
use:
- DEFAULT
except:
- PACKAGE_VERSION_SUFFIX

breaking:
use:
- WIRE_JSON
Binary file added buf_image.bin
Binary file not shown.
1 change: 1 addition & 0 deletions dev-env/bin/buf
14 changes: 14 additions & 0 deletions fmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ cd "$(dirname "$0")"
# load the dev-env
eval "$(dev-env/bin/dade-assist)"

# Location of reference image used for buf breaking check.
# In case breaking changes have been introduced, running './fmt.sh --rebuild-buf-image' will
# overwrite this image.
buf_image="buf_image.bin"

## Config ##
is_test=
scalafmt_args=()
Expand Down Expand Up @@ -62,6 +67,7 @@ Usage: ./fmt.sh [options]
Options:
-h, --help: shows this help
--test: only test for formatting changes, used by CI
--rebuild-buf-image: rebuilds reference image used for buf breaking checks
USAGE
exit
;;
Expand All @@ -79,6 +85,11 @@ USAGE
scalafmt_args+=('--mode=diff' "--diff-branch=${merge_base}")
diff_mode=true
;;
--rebuild-buf-image)
shift
run buf build -o "${buf_image}"
exit
;;
*)
echo "fmt.sh: unknown argument $1" >&2
exit 1
Expand Down Expand Up @@ -144,6 +155,9 @@ run scalafmt "${scalafmt_args[@]:-}"
# check for Bazel build files code formatting
run bazel run "$buildifier_target"

# Run buf checks.
run buf check breaking --against "${buf_image}"

# Note that we cannot use a symlink here because Windows.
if ! diff .bazelrc compatibility/.bazelrc >/dev/null; then
echo ".bazelrc and compatibility/.bazelrc are out of sync:"
Expand Down
2 changes: 2 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ in rec {

javafmt = pkgs.callPackage ./tools/google-java-format {};

buf = pkgs.buf;

scala = bazel_dependencies.scala_2_13;
fsc = scala;
scalac = scala;
Expand Down

0 comments on commit 4d12493

Please sign in to comment.