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

tonic_build: option to check for changes #2045

Open
emilk opened this issue Nov 11, 2024 · 0 comments
Open

tonic_build: option to check for changes #2045

emilk opened this issue Nov 11, 2024 · 0 comments

Comments

@emilk
Copy link

emilk commented Nov 11, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant