Skip to content
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
1 change: 1 addition & 0 deletions .github/workflows/build-engines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ jobs:
(
github.event.pull_request.author_association == 'OWNER' ||
github.event.pull_request.author_association == 'MEMBER' ||
github.event.pull_request.author_association == 'CONTRIBUTOR' ||
github.event.pull_request.author_association == 'COLLABORATOR'
)
run: |
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/utils/constructDockerBuildCommand.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
#!/bin/bash
set -eux;

# full command
DOCKER_WORKSPACE="/root/build"

# Full command, Docker + Bash.
# In Bash, we use `git config` to avoid "fatal: detected dubious ownership in repository at /root/build" panic messages
# that can occur when Prisma Engines' `build.rs` scripts run `git rev-parse HEAD` to extract the current commit hash.
# See: https://www.kenmuse.com/blog/avoiding-dubious-ownership-in-dev-containers/.
command="docker run \
-e SQLITE_MAX_VARIABLE_NUMBER=250000 \
-e SQLITE_MAX_EXPR_DEPTH=10000 \
-e LIBZ_SYS_STATIC=1 \
-w /root/build \
-v \"$(pwd)\":/root/build \
-w ${DOCKER_WORKSPACE} \
-v \"$(pwd)\":${DOCKER_WORKSPACE} \
-v \"$HOME\"/.cargo/bin:/root/cargo/bin \
-v \"$HOME\"/.cargo/registry/index:/root/cargo/registry/index \
-v \"$HOME\"/.cargo/registry/cache:/root/cargo/registry/cache \
-v \"$HOME\"/.cargo/git/db:/root/cargo/git/db \
$IMAGE \
bash -c \
\" \
cargo clean \
git config --global --add safe.directory ${DOCKER_WORKSPACE} \
&& cargo clean \
&& cargo build --release -p query-engine --manifest-path query-engine/query-engine/Cargo.toml $TARGET_STRING $FEATURES_STRING \
&& cargo build --release -p query-engine-node-api --manifest-path query-engine/query-engine-node-api/Cargo.toml $TARGET_STRING $FEATURES_STRING \
&& cargo build --release -p schema-engine-cli --manifest-path schema-engine/cli/Cargo.toml $TARGET_STRING $FEATURES_STRING \
Expand Down
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