Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce buf checks [KVL-980] #10411

Merged
merged 14 commits into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
15 changes: 15 additions & 0 deletions fmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ cd "$(dirname "$0")"
# load the dev-env
eval "$(dev-env/bin/dade-assist)"

# Location of reference image used for buf breaking check.
# Note that in case breaking changes have been introduced, running ./fmt.sh will simply overwrite
# this image. Hence, before committing the new image you should review the errors reported by buf
# by restoring the reference image and running './fmt.sh --test'.
miklos-da marked this conversation as resolved.
Show resolved Hide resolved
buf_image="buf_image.bin"

## Config ##
is_test=
scalafmt_args=()
Expand Down Expand Up @@ -62,6 +68,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 +86,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 +156,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