Skip to content

Commit

Permalink
chore: deleted deprecated proto top-level folder
Browse files Browse the repository at this point in the history
- Migrated hipcheck-common/proto to the top-level proto folder
- Enabled running "buf lint" in CI

Signed-off-by: Patrick Casey <[email protected]>
  • Loading branch information
patrickjcasey committed Dec 17, 2024
1 parent a02ceea commit d89f9b0
Show file tree
Hide file tree
Showing 20 changed files with 26 additions and 258 deletions.
3 changes: 3 additions & 0 deletions .buf.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
version: v2
# tell buf to look in proto for .proto files
modules:
- path: proto
lint:
use:
- STANDARD
Expand Down
2 changes: 1 addition & 1 deletion hipcheck-common/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use tonic_build::compile_protos;
fn main() -> Result<()> {
// Compile the Hipcheck gRPC protocol spec to an .rs file
let root = env!("CARGO_MANIFEST_DIR");
let path = pathbuf![root, "proto", "hipcheck", "v1", "hipcheck.proto"];
let path = pathbuf![root, "..", "proto", "hipcheck", "v1", "hipcheck.proto"];
compile_protos(path)?;

// Make the target available as a compile-time env var for plugin arch
Expand Down
File renamed without changes.
12 changes: 0 additions & 12 deletions proto/hipcheck/v1/messages/default_policy_expr_request.proto

This file was deleted.

15 changes: 0 additions & 15 deletions proto/hipcheck/v1/messages/default_policy_expr_response.proto

This file was deleted.

7 changes: 0 additions & 7 deletions proto/hipcheck/v1/messages/empty.proto

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions proto/hipcheck/v1/messages/explain_default_query_response.proto

This file was deleted.

46 changes: 0 additions & 46 deletions proto/hipcheck/v1/messages/query.proto

This file was deleted.

8 changes: 0 additions & 8 deletions proto/hipcheck/v1/messages/query_request.proto

This file was deleted.

8 changes: 0 additions & 8 deletions proto/hipcheck/v1/messages/query_response.proto

This file was deleted.

8 changes: 0 additions & 8 deletions proto/hipcheck/v1/messages/query_schemas_request.proto

This file was deleted.

18 changes: 0 additions & 18 deletions proto/hipcheck/v1/messages/query_schemas_response.proto

This file was deleted.

19 changes: 0 additions & 19 deletions proto/hipcheck/v1/messages/query_state.proto

This file was deleted.

8 changes: 0 additions & 8 deletions proto/hipcheck/v1/messages/set_config_request.proto

This file was deleted.

9 changes: 0 additions & 9 deletions proto/hipcheck/v1/messages/set_config_response.proto

This file was deleted.

67 changes: 0 additions & 67 deletions proto/hipcheck/v1/plugin_service.proto

This file was deleted.

14 changes: 4 additions & 10 deletions xtask/src/task/buf.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
// SPDX-License-Identifier: Apache-2.0

use crate::workspace;
use anyhow::{Context, Result};
use pathbuf::pathbuf;
use which::which;
use xshell::{cmd, Shell};
use xshell::Shell;

use super::ci::run_buf_lint;

/// Run the `buf lint` command
pub fn run() -> Result<()> {
let sh = Shell::new().context("could not init shell")?;
which("buf").context("could not find 'buf'")?;

let root = workspace::root()?;
let config = pathbuf![&root, ".buf.yaml"];
let target = pathbuf![&root, "hipcheck", "proto"];

cmd!(sh, "buf lint --config {config} {target}").run()?;

run_buf_lint(&sh)?;
Ok(())
}
18 changes: 17 additions & 1 deletion xtask/src/task/ci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub fn run() -> Result<()> {
task!(check_target_matches_ci),
task!(print_versions),
task!(run_fmt),
task!(run_buf_lint),
task!(run_check),
task!(run_build),
task!(run_test),
Expand Down Expand Up @@ -123,7 +124,7 @@ fn print_versions(sh: &Shell) -> Result<()> {
print_fmt_version(sh)?;
print_clippy_version(sh)?;
print_xtask_version(sh)?;

print_buf_version(sh)?;
Ok(())
}

Expand Down Expand Up @@ -169,6 +170,13 @@ fn print_xtask_version(sh: &Shell) -> Result<()> {
.map_err(reason("call to cargo xtask failed. Make sure rust is installed and path to home-dir-here/.cargo/bin is on your path."))
}

// Print the version of `buf`
fn print_buf_version(sh: &Shell) -> Result<()> {
cmd!(sh, "buf --version").run().map(drop).map_err(reason(
"call to buf failed. Make sure buf is installed and on your path.",
))
}

/// Run `cargo fmt`.
fn run_fmt(sh: &Shell) -> Result<()> {
cmd!(sh, "cargo fmt --all -- --color=always --check")
Expand Down Expand Up @@ -228,6 +236,14 @@ fn run_xtask_check(sh: &Shell) -> Result<()> {
.map_err(reason("call to cargo xtask failed"))
}

/// Run `buf lint`
pub fn run_buf_lint(sh: &Shell) -> Result<()> {
cmd!(sh, "buf lint --config .buf.yaml")
.run()
.map(drop)
.map_err(reason("call to cargo xtask failed"))
}

/// Tell the user we're done.
fn done(_sh: &Shell) -> Result<()> {
log::info!(
Expand Down
2 changes: 1 addition & 1 deletion xtask/src/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ pub mod buf;
pub mod changelog;
pub mod check;
pub mod ci;
pub mod manifest;
pub mod rfd;
pub mod site;
pub mod manifest;

0 comments on commit d89f9b0

Please sign in to comment.