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

fix(ci): add sanity check to build.rs scripts, fixed "detected dubious ownership in repository" errors on git #4986

Merged
merged 4 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 10 additions & 0 deletions query-engine/query-engine-node-api/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ use std::process::Command;

fn store_git_commit_hash() {
let output = Command::new("git").args(["rev-parse", "HEAD"]).output().unwrap();

// Sanity check on the output.
if !output.status.success() {
panic!(
"Failed to get git commit hash.\nstderr: \n{}\nstdout {}\n",
String::from_utf8(output.stderr).unwrap_or_default(),
String::from_utf8(output.stdout).unwrap_or_default(),
);
}

let git_hash = String::from_utf8(output.stdout).unwrap();
println!("cargo:rustc-env=GIT_HASH={git_hash}");
}
Expand Down
10 changes: 10 additions & 0 deletions query-engine/query-engine/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ use std::process::Command;

fn store_git_commit_hash() {
let output = Command::new("git").args(["rev-parse", "HEAD"]).output().unwrap();

// Sanity check on the output.
if !output.status.success() {
panic!(
"Failed to get git commit hash.\nstderr: \n{}\nstdout {}\n",
String::from_utf8(output.stderr).unwrap_or_default(),
String::from_utf8(output.stdout).unwrap_or_default(),
);
}

let git_hash = String::from_utf8(output.stdout).unwrap();
println!("cargo:rustc-env=GIT_HASH={git_hash}");
}
Expand Down
10 changes: 10 additions & 0 deletions schema-engine/cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ use std::process::Command;

fn store_git_commit_hash() {
let output = Command::new("git").args(["rev-parse", "HEAD"]).output().unwrap();

// Sanity check on the output.
if !output.status.success() {
panic!(
"Failed to get git commit hash.\nstderr: \n{}\nstdout {}\n",
String::from_utf8(output.stderr).unwrap_or_default(),
String::from_utf8(output.stdout).unwrap_or_default(),
);
}

let git_hash = String::from_utf8(output.stdout).unwrap();
println!("cargo:rustc-env=GIT_HASH={git_hash}");
}
Comment on lines 3 to 17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: would be nicer to have this defined once in some kind of build utils crate that these three crates will depend on as a build dependency

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the whole store_git_commit_hash could be abstracted

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expand Down
Loading