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

ci: Regenerate Rust code when we update dependencies #8

Merged
merged 3 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ jobs:
- name: Update dependencies
run: cargo update

# Regenerate proto module with new dependencies. Else, they may not work
# if the protobuf library gets updated in the previous step.
- name: Generate Rust code from Protobuf definitions
run: cargo build --features proto-gen

- name: Test
run: cargo test -- --nocapture # Allow printing the output of tests

Expand Down
85 changes: 38 additions & 47 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#[cfg(feature = "proto-gen")]
use protobuf_codegen;
#[cfg(feature = "proto-gen")]
use std::fs;

// NOTE: When this feature is enabled, the build will always run, even if the
// .proto file has not changed. This happens because the .rs file always gets
Expand All @@ -16,7 +18,16 @@ fn proto_gen() {
.out_dir("proto/")
.includes(&["proto/"])
.input("proto/metadata.proto")
.run_from_script()
.run_from_script();

// Allow missing docs for the generated code, since its not under our
// control.
let proto_mod_rs =
fs::read_to_string("proto/mod.rs").expect("Unable to open file");
let header = "// Header added by Tindercrypt's build.rs script\n\
#![allow(missing_docs)]\n\n";
let new_proto_mod_rs = header.to_owned() + &proto_mod_rs;
fs::write("proto/mod.rs", new_proto_mod_rs).expect("Unable to write file");
}

fn main() {
Expand Down
4 changes: 2 additions & 2 deletions proto/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 3.6.0. Do not edit
// This file is generated by rust-protobuf 3.7.1. Do not edit
// .proto file is parsed by pure
// @generated

Expand All @@ -22,7 +22,7 @@

/// Generated files are compatible only with the same version
/// of protobuf runtime.
const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_3_6_0;
const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_3_7_1;

// @@protoc_insertion_point(message:metadata.KeyDerivationMetadata)
#[derive(PartialEq,Clone,Default,Debug)]
Expand Down
5 changes: 3 additions & 2 deletions proto/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @generated

// Header added by Tindercrypt's build.rs script
#![allow(missing_docs)]

// @generated

pub mod metadata;