tvl-depot/nix/bufCheck/default.nix
Florian Klink a2ac8a66c1 feat(nix/bufCheck): ensure .pb.go is up to date
Change-Id: I03e1c3aced266966f6959dbce05c1f1fb1480b5a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7323
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
2022-12-27 13:27:40 +00:00

22 lines
672 B
Nix

# Check protobuf syntax and breaking.
#
{ depot, pkgs, ... }:
pkgs.writeShellScriptBin "ci-buf-check" ''
export PATH="$PATH:${pkgs.lib.makeBinPath [ pkgs.buf pkgs.protoc-gen-go pkgs.protoc-gen-go-grpc ]}"
buf lint .
# Run buf generate, and bail out if generated files are changed.
buf generate --path tvix/store/protos
# Check if any files have changed
if [[ -n "$(git status --porcelain -unormal)" ]]; then
echo "-----------------------------"
echo ".pb.go files need to be updated"
echo "-----------------------------"
git status -unormal
exit 1
fi
# Report-only
buf breaking . --against "./.git#ref=HEAD~1" || true
''