Introduce buf checks [KVL-980] (#10411)

CHANGELOG_BEGIN
CHANGELOG_END
This commit is contained in:
Miklos 2021-07-27 16:23:39 +02:00 committed by GitHub
parent 1c4ae5023d
commit 4d1249390e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 44 additions and 0 deletions

27
buf.yaml Normal file
View File

@ -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

BIN
buf_image.bin Normal file

Binary file not shown.

1
dev-env/bin/buf Symbolic link
View File

@ -0,0 +1 @@
../lib/dade-exec-nix-tool

14
fmt.sh
View File

@ -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=()
@ -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
;;
@ -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
@ -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:"

View File

@ -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;