From 8fbb53dae4961316229bf465d3bf07c5725667c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nathan=20Gau=C3=ABr?= Date: Mon, 23 Jan 2023 15:22:40 +0100 Subject: [PATCH] kokoro: fix dubious ownership (#5078) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Kokoro clones repos with a different user used to run the build steps, meaning if some git command must be run at build time, they will fail because of this dubious ownership issue. Running some git commands makes only sense with history, so changing checkout depth so we can run them and get the true result. This is a known Kororo issue. Fixing this is required to generate the version file using git history. Signed-off-by: Nathan Gauër --- .github/workflows/bazel.yml | 1 + .github/workflows/wasm.yml | 3 ++- kokoro/check-format/build.sh | 5 +++++ kokoro/macos-clang-debug/build.sh | 1 - kokoro/macos-clang-release-bazel/build.sh | 5 +++++ kokoro/macos-clang-release/build.sh | 1 - kokoro/scripts/linux/build-docker.sh | 5 +++++ kokoro/scripts/macos/build.sh | 5 +++++ source/wasm/build.sh | 5 +++++ 9 files changed, 28 insertions(+), 3 deletions(-) diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index 03f3bf51..7706c03b 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -17,6 +17,7 @@ jobs: steps: - uses: actions/checkout@v3 + fetch-depth: '0' - name: Download dependencies run: python3 utils/git-sync-deps - name: Mount Bazel cache diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 0fc18062..1439f211 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -7,7 +7,8 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + fetch-depth: '0' - name: Build web run: docker-compose -f source/wasm/docker-compose.yml --project-directory . up - name: Run tests diff --git a/kokoro/check-format/build.sh b/kokoro/check-format/build.sh index 8a5df9a8..96603e44 100644 --- a/kokoro/check-format/build.sh +++ b/kokoro/check-format/build.sh @@ -23,6 +23,11 @@ set -x BUILD_ROOT=$PWD SRC=$PWD/github/SPIRV-Tools +# This is required to run any git command in the docker since owner will +# have changed between the clone environment, and the docker container. +# Marking the root of the repo as safe for ownership changes. +git config --global --add safe.directory $SRC + # Get clang-format-5.0.0. # Once kokoro upgrades the Ubuntu VMs, we can use 'apt-get install clang-format' curl -L http://releases.llvm.org/5.0.0/clang+llvm-5.0.0-linux-x86_64-ubuntu14.04.tar.xz -o clang-llvm.tar.xz diff --git a/kokoro/macos-clang-debug/build.sh b/kokoro/macos-clang-debug/build.sh index 8d9a062f..fca76fc6 100644 --- a/kokoro/macos-clang-debug/build.sh +++ b/kokoro/macos-clang-debug/build.sh @@ -22,4 +22,3 @@ set -x SCRIPT_DIR=`dirname "$BASH_SOURCE"` source $SCRIPT_DIR/../scripts/macos/build.sh Debug - diff --git a/kokoro/macos-clang-release-bazel/build.sh b/kokoro/macos-clang-release-bazel/build.sh index c62611ab..50ad42bc 100644 --- a/kokoro/macos-clang-release-bazel/build.sh +++ b/kokoro/macos-clang-release-bazel/build.sh @@ -24,6 +24,11 @@ CC=clang CXX=clang++ SRC=$PWD/github/SPIRV-Tools +# This is required to run any git command in the docker since owner will +# have changed between the clone environment, and the docker container. +# Marking the root of the repo as safe for ownership changes. +git config --global --add safe.directory $SRC + cd $SRC git clone --depth=1 https://github.com/KhronosGroup/SPIRV-Headers external/spirv-headers git clone https://github.com/google/googletest external/googletest diff --git a/kokoro/macos-clang-release/build.sh b/kokoro/macos-clang-release/build.sh index ccc8b16a..b1460a97 100644 --- a/kokoro/macos-clang-release/build.sh +++ b/kokoro/macos-clang-release/build.sh @@ -22,4 +22,3 @@ set -x SCRIPT_DIR=`dirname "$BASH_SOURCE"` source $SCRIPT_DIR/../scripts/macos/build.sh RelWithDebInfo - diff --git a/kokoro/scripts/linux/build-docker.sh b/kokoro/scripts/linux/build-docker.sh index 7d62ee36..52fbb9e4 100755 --- a/kokoro/scripts/linux/build-docker.sh +++ b/kokoro/scripts/linux/build-docker.sh @@ -20,6 +20,11 @@ set -e # Display commands being run. set -x +# This is required to run any git command in the docker since owner will +# have changed between the clone environment, and the docker container. +# Marking the root of the repo as safe for ownership changes. +git config --global --add safe.directory $ROOT_DIR + . /bin/using.sh # Declare the bash `using` function for configuring toolchains. if [ $COMPILER = "clang" ]; then diff --git a/kokoro/scripts/macos/build.sh b/kokoro/scripts/macos/build.sh index 1d346e76..8381f87d 100644 --- a/kokoro/scripts/macos/build.sh +++ b/kokoro/scripts/macos/build.sh @@ -24,6 +24,11 @@ BUILD_ROOT=$PWD SRC=$PWD/github/SPIRV-Tools BUILD_TYPE=$1 +# This is required to run any git command in the docker since owner will +# have changed between the clone environment, and the docker container. +# Marking the root of the repo as safe for ownership changes. +git config --global --add safe.directory $SRC + # Get NINJA. wget -q https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-mac.zip unzip -q ninja-mac.zip diff --git a/source/wasm/build.sh b/source/wasm/build.sh index f02ae525..4f7b701c 100755 --- a/source/wasm/build.sh +++ b/source/wasm/build.sh @@ -16,6 +16,11 @@ set -e +# This is required to run any git command in the docker since owner will +# have changed between the clone environment, and the docker container. +# Marking the root of the repo as safe for ownership changes. +git config --global --add safe.directory /app + NUM_CORES=$(nproc) echo "Detected $NUM_CORES cores for building"