grpc / grpc/grpc-rust

tonic_build: option to check for changes

Open
#2,045 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
12.5k
Forks
1.3k
Avg merge
4d 7h
Merged PRs (30d)
24

Description

## Feature Request

### Crates
`tonic_build`

### Motivation
We run `tonic_build` manually and check in our generated code.
We want to have a CI step to check that the generated code is up-to-date.

### Proposal
Add an option to `Builder` that, when set, will cause the `compile_protos` invocation to FAIL if the files on disk differs from the generated ones.
The fail could be returning a special error.

```
let is_on_ci: bool = …;
tonic_build::configure()
.out_dir(output_dir.as_ref())
.build_client(true)
.build_server(true)
.fail_on_diff(is_on_ci) // Turn on "check" mode when we're on CI
.compile_protos(proto_paths, &[definitions_dir])
.unwrap(); // will fail if the files require changes on ci
```

### Alternatives
As a user, I can also just run the code-gen and then check for diffs with `git` - but that is messy.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.