Skip to content

Conversation

@jkomyno
Copy link
Contributor

@jkomyno jkomyno commented Aug 23, 2024

This PR checks that git rev-parse HEAD, the CLI command used at compilation time to store the hash in the Query Engine and Schema Engine, exits successfully.

It also complements #4947 by running git config --global --add safe.directory /root/build when cross-building via prismagraphql/build:*. This avoids "fatal: detected dubious ownership in repository at /root/build" errors in Linux Musl ARM64 and Linux Static ARM64 architectures.

This was introduced after third-party clients notified us that ./query-engine --version no longer displayed the version hash in Linux Alpine.

Fixes: prisma/prisma#25020
Fixes: prisma/prisma#24971

@jkomyno jkomyno self-assigned this Aug 23, 2024
@jkomyno jkomyno requested a review from a team as a code owner August 23, 2024 16:47
@jkomyno jkomyno requested review from SevInf and aqrln and removed request for a team and SevInf August 23, 2024 16:47
@jkomyno jkomyno added this to the 5.19.0 milestone Aug 23, 2024
@codspeed-hq
Copy link

codspeed-hq bot commented Aug 23, 2024

CodSpeed Performance Report

Merging #4986 will not alter performance

Comparing integration/build-rs-version (a0cd683) with main (0bc306e)

Summary

✅ 11 untouched benchmarks

@github-actions
Copy link
Contributor

github-actions bot commented Aug 23, 2024

WASM Query Engine file Size

Engine This PR Base branch Diff
Postgres 2.063MiB 2.063MiB 0.000B
Postgres (gzip) 823.735KiB 823.736KiB -1.000B
Mysql 2.033MiB 2.033MiB 0.000B
Mysql (gzip) 811.286KiB 811.287KiB -1.000B
Sqlite 1.924MiB 1.924MiB 0.000B
Sqlite (gzip) 768.293KiB 768.294KiB -1.000B

@jkomyno jkomyno changed the title feat: add sanity check to build.rs scripts on crates compiled natively fix(ci): add sanity check to build.rs scripts, fixed "detected dubious ownership in repository" errors on git Aug 24, 2024
Comment on lines 3 to 17
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}");
}
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.

@jkomyno jkomyno merged commit 5fe2181 into main Aug 26, 2024
@jkomyno jkomyno deleted the integration/build-rs-version branch August 26, 2024 09:30
aqrln added a commit that referenced this pull request Aug 27, 2024
Follow-up to #4986.

* Change the `build.rs` scripts to pass through the `GIT_HASH`
  environment variable if it's already set.

* Set dummmy `GIT_HASH` value in the Nix packages used in the
  engines size dashboard.

* Consistently use the new logic everywhere.

Fixes: #4991
Closes: prisma/team-orm#1261
jkomyno pushed a commit that referenced this pull request Aug 28, 2024
…4992)

Follow-up to #4986.

* Change the `build.rs` scripts to pass through the `GIT_HASH`
  environment variable if it's already set.

* Set dummmy `GIT_HASH` value in the Nix packages used in the
  engines size dashboard.

* Consistently use the new logic everywhere.

Fixes: #4991
Closes: prisma/team-orm#1261
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants