diff --git a/.github/workflows/build-engines.yml b/.github/workflows/build-engines.yml index 6147eda68d11..6e931fedd224 100644 --- a/.github/workflows/build-engines.yml +++ b/.github/workflows/build-engines.yml @@ -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: | diff --git a/.github/workflows/utils/constructDockerBuildCommand.sh b/.github/workflows/utils/constructDockerBuildCommand.sh index 1d7adf80577a..6ec9e3072665 100644 --- a/.github/workflows/utils/constructDockerBuildCommand.sh +++ b/.github/workflows/utils/constructDockerBuildCommand.sh @@ -1,13 +1,18 @@ #!/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 \ @@ -15,7 +20,8 @@ command="docker run \ $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 \ diff --git a/query-engine/query-engine-node-api/build.rs b/query-engine/query-engine-node-api/build.rs index 2ed42a66137c..235ecb73a375 100644 --- a/query-engine/query-engine-node-api/build.rs +++ b/query-engine/query-engine-node-api/build.rs @@ -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}"); } diff --git a/query-engine/query-engine/build.rs b/query-engine/query-engine/build.rs index 2e8fe20c0503..c5a7eb3ed547 100644 --- a/query-engine/query-engine/build.rs +++ b/query-engine/query-engine/build.rs @@ -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}"); } diff --git a/schema-engine/cli/build.rs b/schema-engine/cli/build.rs index 2e8fe20c0503..c5a7eb3ed547 100644 --- a/schema-engine/cli/build.rs +++ b/schema-engine/cli/build.rs @@ -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}"); }