diff --git a/.github/workflows/velox_be.yml b/.github/workflows/velox_be.yml index 934c36ebb7cb..7d4ac141133f 100644 --- a/.github/workflows/velox_be.yml +++ b/.github/workflows/velox_be.yml @@ -393,7 +393,7 @@ jobs: MOUNT_MAVEN_CACHE=OFF \ OS_IMAGE=centos:7 \ OS_VERSION=7 \ - tools/gluten-te/centos/cbash.sh sleep 14400 + tools/gluten-te/centos/cbash-mount.sh sleep 14400 - name: Build Gluten velox third party run: | docker exec centos7-test-$GITHUB_RUN_ID bash -c ' diff --git a/tools/gluten-te/.fixme b/tools/gluten-te/.fixme new file mode 100644 index 000000000000..97143f47ffad --- /dev/null +++ b/tools/gluten-te/.fixme @@ -0,0 +1 @@ +FIXME: Consolidate /opt/gluten/tools/gluten-te/centos/gha/gha-checkout with /opt/gluten/tools/gluten-te/ubuntu/gha/gha-checkout diff --git a/tools/gluten-te/centos/build.sh b/tools/gluten-te/centos/build.sh index 573120dca7da..c4d1cc5eb464 100755 --- a/tools/gluten-te/centos/build.sh +++ b/tools/gluten-te/centos/build.sh @@ -44,10 +44,6 @@ else GLUTEN_DEBUG_BUILD=OFF fi -# The target branches -TARGET_GLUTEN_REPO=${TARGET_GLUTEN_REPO:-$DEFAULT_GLUTEN_REPO} -TARGET_GLUTEN_BRANCH=${TARGET_GLUTEN_BRANCH:-$DEFAULT_GLUTEN_BRANCH} - # The branches used to prepare dependencies CACHE_GLUTEN_REPO=${CACHE_GLUTEN_REPO:-$DEFAULT_GLUTEN_REPO} CACHE_GLUTEN_BRANCH=${CACHE_GLUTEN_BRANCH:-$DEFAULT_GLUTEN_BRANCH} @@ -60,16 +56,6 @@ DOCKER_TARGET_IMAGE_BUILD=${DOCKER_TARGET_IMAGE_BUILD:-$DEFAULT_DOCKER_TARGET_IM DOCKER_TARGET_IMAGE_BUILD_WITH_OS_IMAGE="$DOCKER_TARGET_IMAGE_BUILD-$OS_IMAGE" -## Fetch target commit - -TARGET_GLUTEN_COMMIT="$(git ls-remote $TARGET_GLUTEN_REPO $TARGET_GLUTEN_BRANCH | awk '{print $1;}')" - -if [ -z "$TARGET_GLUTEN_COMMIT" ] -then - echo "Unable to parse TARGET_GLUTEN_COMMIT." - exit 1 -fi - ## BUILD_DOCKER_BUILD_ARGS= @@ -79,8 +65,6 @@ BUILD_DOCKER_BUILD_ARGS="$BUILD_DOCKER_BUILD_ARGS --build-arg BUILDKIT_INLINE_CA BUILD_DOCKER_BUILD_ARGS="$BUILD_DOCKER_BUILD_ARGS --build-arg DOCKER_TARGET_IMAGE_BUILDENV_WITH_OS_IMAGE=$DOCKER_TARGET_IMAGE_BUILDENV_WITH_OS_IMAGE" BUILD_DOCKER_BUILD_ARGS="$BUILD_DOCKER_BUILD_ARGS --build-arg JDK_DEBUG_BUILD=$JDK_DEBUG_BUILD" BUILD_DOCKER_BUILD_ARGS="$BUILD_DOCKER_BUILD_ARGS --build-arg GLUTEN_DEBUG_BUILD=$GLUTEN_DEBUG_BUILD" -BUILD_DOCKER_BUILD_ARGS="$BUILD_DOCKER_BUILD_ARGS --build-arg TARGET_GLUTEN_REPO=$TARGET_GLUTEN_REPO" -BUILD_DOCKER_BUILD_ARGS="$BUILD_DOCKER_BUILD_ARGS --build-arg TARGET_GLUTEN_COMMIT=$TARGET_GLUTEN_COMMIT" BUILD_DOCKER_BUILD_ARGS="$BUILD_DOCKER_BUILD_ARGS --build-arg CACHE_GLUTEN_REPO=$CACHE_GLUTEN_REPO" BUILD_DOCKER_BUILD_ARGS="$BUILD_DOCKER_BUILD_ARGS --build-arg CACHE_GLUTEN_BRANCH=$CACHE_GLUTEN_BRANCH" BUILD_DOCKER_BUILD_ARGS="$BUILD_DOCKER_BUILD_ARGS --build-arg BUILD_BACKEND_TYPE=$BUILD_BACKEND_TYPE" diff --git a/tools/gluten-te/centos/cbash-build.sh b/tools/gluten-te/centos/cbash-build.sh new file mode 100755 index 000000000000..b47f6635c839 --- /dev/null +++ b/tools/gluten-te/centos/cbash-build.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -ex + +BASEDIR=$(dirname $0) + +source "$BASEDIR/build.sh" + +# Non-interactive during docker run +NON_INTERACTIVE=${NON_INTERACTIVE:-$DEFAULT_NON_INTERACTIVE} + +# Do not remove stopped docker container +PRESERVE_CONTAINER=${PRESERVE_CONTAINER:-$DEFAULT_PRESERVE_CONTAINER} + +# Docker options +EXTRA_DOCKER_OPTIONS=${EXTRA_DOCKER_OPTIONS:-$DEFAULT_EXTRA_DOCKER_OPTIONS} + +# Whether to mount Maven cache +MOUNT_MAVEN_CACHE=${MOUNT_MAVEN_CACHE:-$DEFAULT_MOUNT_MAVEN_CACHE} + +CBASH_DOCKER_RUN_ARGS= +if [ "$NON_INTERACTIVE" != "ON" ] +then + CBASH_DOCKER_RUN_ARGS="$CBASH_DOCKER_RUN_ARGS -it" +fi +if [ "$PRESERVE_CONTAINER" != "ON" ] +then + CBASH_DOCKER_RUN_ARGS="$CBASH_DOCKER_RUN_ARGS --rm" +fi +CBASH_DOCKER_RUN_ARGS="$CBASH_DOCKER_RUN_ARGS --init" +CBASH_DOCKER_RUN_ARGS="$CBASH_DOCKER_RUN_ARGS --privileged" +CBASH_DOCKER_RUN_ARGS="$CBASH_DOCKER_RUN_ARGS --ulimit nofile=65536:65536" +CBASH_DOCKER_RUN_ARGS="$CBASH_DOCKER_RUN_ARGS --ulimit core=-1" +CBASH_DOCKER_RUN_ARGS="$CBASH_DOCKER_RUN_ARGS --security-opt seccomp=unconfined" +if [ "$MOUNT_MAVEN_CACHE" == "ON" ] +then + CBASH_DOCKER_RUN_ARGS="$CBASH_DOCKER_RUN_ARGS -v $HOME/.m2/repository:/root/.m2/repository" +fi +CBASH_DOCKER_RUN_ARGS="$CBASH_DOCKER_RUN_ARGS -v $HOME/.ccache:/root/.ccache" +CBASH_DOCKER_RUN_ARGS="$CBASH_DOCKER_RUN_ARGS $EXTRA_DOCKER_OPTIONS" + +CBASH_BASH_ARGS="$*" +BASH_ARGS="$CBASH_BASH_ARGS" + +docker run $CBASH_DOCKER_RUN_ARGS $DOCKER_TARGET_IMAGE_BUILD_WITH_OS_IMAGE bash -c "cd /opt/gluten && $BASH_ARGS" diff --git a/tools/gluten-te/centos/cbash.sh b/tools/gluten-te/centos/cbash-mount.sh similarity index 98% rename from tools/gluten-te/centos/cbash.sh rename to tools/gluten-te/centos/cbash-mount.sh index ecb69a3592cd..d82d5c78d515 100755 --- a/tools/gluten-te/centos/cbash.sh +++ b/tools/gluten-te/centos/cbash-mount.sh @@ -29,7 +29,7 @@ PRESERVE_CONTAINER=${PRESERVE_CONTAINER:-$DEFAULT_PRESERVE_CONTAINER} # Docker options EXTRA_DOCKER_OPTIONS=${EXTRA_DOCKER_OPTIONS:-$DEFAULT_EXTRA_DOCKER_OPTIONS} -# Docker options +# Whether to mount Maven cache MOUNT_MAVEN_CACHE=${MOUNT_MAVEN_CACHE:-$DEFAULT_MOUNT_MAVEN_CACHE} CBASH_DOCKER_RUN_ARGS= diff --git a/tools/gluten-te/centos/defaults.conf b/tools/gluten-te/centos/defaults.conf index 095d7afb0a58..1cdc10f5ebe6 100755 --- a/tools/gluten-te/centos/defaults.conf +++ b/tools/gluten-te/centos/defaults.conf @@ -51,6 +51,6 @@ DEFAULT_DOCKER_PUSH_REGISTRY= ## For cbash.sh # Whether to mount Maven cache -DEFAULT_MOUNT_MAVEN_CACHE=ON +DEFAULT_MOUNT_MAVEN_CACHE=OFF # EOF diff --git a/tools/gluten-te/centos/dockerfile-build b/tools/gluten-te/centos/dockerfile-build index 6b48677766ee..4bcfbb90f656 100644 --- a/tools/gluten-te/centos/dockerfile-build +++ b/tools/gluten-te/centos/dockerfile-build @@ -80,22 +80,4 @@ RUN EXTRA_MAVEN_OPTIONS=$(cat ~/.gluten-mvn-options) \ && bash -c "$DEPS_INSTALL_SCRIPT" \ && bash -c "mvn clean install $GLUTEN_MAVEN_OPTIONS $EXTRA_MAVEN_OPTIONS" -# Build Gluten -ARG TARGET_GLUTEN_REPO -ARG TARGET_GLUTEN_COMMIT - -RUN test -n "$TARGET_GLUTEN_REPO" || (echo "TARGET_GLUTEN_REPO not set" && false) -RUN test -n "$TARGET_GLUTEN_COMMIT" || (echo "TARGET_GLUTEN_COMMIT not set" && false) - -RUN cd /opt/gluten \ - && git fetch $TARGET_GLUTEN_REPO $TARGET_GLUTEN_COMMIT:build_$TARGET_GLUTEN_COMMIT \ - && git checkout build_$TARGET_GLUTEN_COMMIT - -RUN EXTRA_MAVEN_OPTIONS=$(cat ~/.gluten-mvn-options) \ - DEPS_INSTALL_SCRIPT=$(cat ~/.gluten-deps-install-script) \ - && cd /opt/gluten \ - && bash -c "$DEPS_INSTALL_SCRIPT" \ - && bash -c "mvn clean install $GLUTEN_MAVEN_OPTIONS $EXTRA_MAVEN_OPTIONS" \ - && bash -c "ln -sf ep/build-velox/build/velox_ep /opt/velox" - # EOF diff --git a/tools/gluten-te/centos/dockerfile-buildenv b/tools/gluten-te/centos/dockerfile-buildenv index 3f36f8c91933..b0428dbf13ce 100755 --- a/tools/gluten-te/centos/dockerfile-buildenv +++ b/tools/gluten-te/centos/dockerfile-buildenv @@ -72,4 +72,4 @@ RUN yum -y install sudo \ && yum clean all RUN echo '%wheel ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers -COPY env.sh /env.sh +COPY scripts/env.sh /env.sh diff --git a/tools/gluten-te/centos/gha/gha-checkout/checkout.sh b/tools/gluten-te/centos/gha/gha-checkout/checkout.sh new file mode 100755 index 000000000000..15c28f5849d0 --- /dev/null +++ b/tools/gluten-te/centos/gha/gha-checkout/checkout.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -ex + +BASEDIR=$(readlink -f $(dirname $0)) + +source "$BASEDIR/../../defaults.conf" + +if [ -z "$GITHUB_RUN_ID" ] +then + echo "Unable to parse GITHUB_RUN_ID." + exit 1 +fi + +export EXTRA_DOCKER_OPTIONS="$EXTRA_DOCKER_OPTIONS --name gha-checkout-$GITHUB_RUN_ID --detach -v $BASEDIR/scripts:/opt/scripts" +export NON_INTERACTIVE=ON + +$BASEDIR/../../cbash-build.sh 'sleep 14400' + +# The target branches +TARGET_GLUTEN_REPO=${TARGET_GLUTEN_REPO:-$DEFAULT_GLUTEN_REPO} +FALLBACK_GLUTEN_BRANCH=${FALLBACK_GLUTEN_BRANCH:-$DEFAULT_GLUTEN_BRANCH} +FALLBACK_GLUTEN_COMMIT="$(git ls-remote $TARGET_GLUTEN_REPO $FALLBACK_GLUTEN_BRANCH | awk '{print $1;}')" + +TARGET_GLUTEN_COMMIT="${GITHUB_SHA:-$FALLBACK_GLUTEN_COMMIT}" + +$BASEDIR/exec.sh "/opt/scripts/init.sh $TARGET_GLUTEN_REPO $TARGET_GLUTEN_COMMIT" diff --git a/tools/gluten-te/centos/gha/gha-checkout/clean.sh b/tools/gluten-te/centos/gha/gha-checkout/clean.sh new file mode 100755 index 000000000000..f67f6bf0058b --- /dev/null +++ b/tools/gluten-te/centos/gha/gha-checkout/clean.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -ex + +if [ -z "$GITHUB_RUN_ID" ] +then + echo "Unable to parse GITHUB_RUN_ID." + exit 1 +fi + +docker stop gha-checkout-$GITHUB_RUN_ID || true diff --git a/tools/gluten-te/centos/gha/gha-checkout/exec.sh b/tools/gluten-te/centos/gha/gha-checkout/exec.sh new file mode 100755 index 000000000000..1497ab6f2edf --- /dev/null +++ b/tools/gluten-te/centos/gha/gha-checkout/exec.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -ex + +CBASH_BASH_ARGS="$*" +BASH_ARGS="$CBASH_BASH_ARGS" + +if [ -z "$GITHUB_RUN_ID" ] +then + echo "Unable to parse GITHUB_RUN_ID." + exit 1 +fi + +docker exec gha-checkout-$GITHUB_RUN_ID bash -c "cd /opt/gluten && $BASH_ARGS" diff --git a/tools/gluten-te/centos/gha/gha-checkout/scripts/init.sh b/tools/gluten-te/centos/gha/gha-checkout/scripts/init.sh new file mode 100755 index 000000000000..7c70ccf0d406 --- /dev/null +++ b/tools/gluten-te/centos/gha/gha-checkout/scripts/init.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -ex + +TARGET_GLUTEN_REPO=$1 +TARGET_GLUTEN_COMMIT=$2 + +cd /opt/gluten + +git fetch $TARGET_GLUTEN_REPO $TARGET_GLUTEN_COMMIT:build_$TARGET_GLUTEN_COMMIT +git checkout build_$TARGET_GLUTEN_COMMIT diff --git a/tools/gluten-te/centos/env.sh b/tools/gluten-te/centos/scripts/env.sh similarity index 100% rename from tools/gluten-te/centos/env.sh rename to tools/gluten-te/centos/scripts/env.sh diff --git a/tools/gluten-te/ubuntu/README.md b/tools/gluten-te/ubuntu/README.md index 05c024be9321..328b5108e73d 100644 --- a/tools/gluten-te/ubuntu/README.md +++ b/tools/gluten-te/ubuntu/README.md @@ -57,7 +57,7 @@ cd gluten/ ```sh cd gluten/ -{PATH_TO_GLUTEN_TE}/cbash.sh mvn clean dependency:tree +{PATH_TO_GLUTEN_TE}/cbash-mount.sh mvn clean dependency:tree ``` ## Example: Run GUI-based IDEs diff --git a/tools/gluten-te/ubuntu/build.sh b/tools/gluten-te/ubuntu/build.sh index 573120dca7da..c4d1cc5eb464 100755 --- a/tools/gluten-te/ubuntu/build.sh +++ b/tools/gluten-te/ubuntu/build.sh @@ -44,10 +44,6 @@ else GLUTEN_DEBUG_BUILD=OFF fi -# The target branches -TARGET_GLUTEN_REPO=${TARGET_GLUTEN_REPO:-$DEFAULT_GLUTEN_REPO} -TARGET_GLUTEN_BRANCH=${TARGET_GLUTEN_BRANCH:-$DEFAULT_GLUTEN_BRANCH} - # The branches used to prepare dependencies CACHE_GLUTEN_REPO=${CACHE_GLUTEN_REPO:-$DEFAULT_GLUTEN_REPO} CACHE_GLUTEN_BRANCH=${CACHE_GLUTEN_BRANCH:-$DEFAULT_GLUTEN_BRANCH} @@ -60,16 +56,6 @@ DOCKER_TARGET_IMAGE_BUILD=${DOCKER_TARGET_IMAGE_BUILD:-$DEFAULT_DOCKER_TARGET_IM DOCKER_TARGET_IMAGE_BUILD_WITH_OS_IMAGE="$DOCKER_TARGET_IMAGE_BUILD-$OS_IMAGE" -## Fetch target commit - -TARGET_GLUTEN_COMMIT="$(git ls-remote $TARGET_GLUTEN_REPO $TARGET_GLUTEN_BRANCH | awk '{print $1;}')" - -if [ -z "$TARGET_GLUTEN_COMMIT" ] -then - echo "Unable to parse TARGET_GLUTEN_COMMIT." - exit 1 -fi - ## BUILD_DOCKER_BUILD_ARGS= @@ -79,8 +65,6 @@ BUILD_DOCKER_BUILD_ARGS="$BUILD_DOCKER_BUILD_ARGS --build-arg BUILDKIT_INLINE_CA BUILD_DOCKER_BUILD_ARGS="$BUILD_DOCKER_BUILD_ARGS --build-arg DOCKER_TARGET_IMAGE_BUILDENV_WITH_OS_IMAGE=$DOCKER_TARGET_IMAGE_BUILDENV_WITH_OS_IMAGE" BUILD_DOCKER_BUILD_ARGS="$BUILD_DOCKER_BUILD_ARGS --build-arg JDK_DEBUG_BUILD=$JDK_DEBUG_BUILD" BUILD_DOCKER_BUILD_ARGS="$BUILD_DOCKER_BUILD_ARGS --build-arg GLUTEN_DEBUG_BUILD=$GLUTEN_DEBUG_BUILD" -BUILD_DOCKER_BUILD_ARGS="$BUILD_DOCKER_BUILD_ARGS --build-arg TARGET_GLUTEN_REPO=$TARGET_GLUTEN_REPO" -BUILD_DOCKER_BUILD_ARGS="$BUILD_DOCKER_BUILD_ARGS --build-arg TARGET_GLUTEN_COMMIT=$TARGET_GLUTEN_COMMIT" BUILD_DOCKER_BUILD_ARGS="$BUILD_DOCKER_BUILD_ARGS --build-arg CACHE_GLUTEN_REPO=$CACHE_GLUTEN_REPO" BUILD_DOCKER_BUILD_ARGS="$BUILD_DOCKER_BUILD_ARGS --build-arg CACHE_GLUTEN_BRANCH=$CACHE_GLUTEN_BRANCH" BUILD_DOCKER_BUILD_ARGS="$BUILD_DOCKER_BUILD_ARGS --build-arg BUILD_BACKEND_TYPE=$BUILD_BACKEND_TYPE" diff --git a/tools/gluten-te/ubuntu/cbash-build.sh b/tools/gluten-te/ubuntu/cbash-build.sh new file mode 100755 index 000000000000..2cc57ff71631 --- /dev/null +++ b/tools/gluten-te/ubuntu/cbash-build.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -ex + +BASEDIR=$(dirname $0) + +source "$BASEDIR/build.sh" + +# Non-interactive during docker run +NON_INTERACTIVE=${NON_INTERACTIVE:-$DEFAULT_NON_INTERACTIVE} + +# Do not remove stopped docker container +PRESERVE_CONTAINER=${PRESERVE_CONTAINER:-$DEFAULT_PRESERVE_CONTAINER} + +# Docker options +EXTRA_DOCKER_OPTIONS=${EXTRA_DOCKER_OPTIONS:-$DEFAULT_EXTRA_DOCKER_OPTIONS} + +# Whether to mount Maven cache +MOUNT_MAVEN_CACHE=${MOUNT_MAVEN_CACHE:-$DEFAULT_MOUNT_MAVEN_CACHE} + +CBASH_DOCKER_RUN_ARGS= +if [ "$NON_INTERACTIVE" != "ON" ] +then + CBASH_DOCKER_RUN_ARGS="$CBASH_DOCKER_RUN_ARGS -it" +fi +if [ "$PRESERVE_CONTAINER" != "ON" ] +then + CBASH_DOCKER_RUN_ARGS="$CBASH_DOCKER_RUN_ARGS --rm" +fi +CBASH_DOCKER_RUN_ARGS="$CBASH_DOCKER_RUN_ARGS --init" +CBASH_DOCKER_RUN_ARGS="$CBASH_DOCKER_RUN_ARGS --privileged" +CBASH_DOCKER_RUN_ARGS="$CBASH_DOCKER_RUN_ARGS --ulimit nofile=65536:65536" +CBASH_DOCKER_RUN_ARGS="$CBASH_DOCKER_RUN_ARGS --ulimit core=-1" +CBASH_DOCKER_RUN_ARGS="$CBASH_DOCKER_RUN_ARGS --security-opt seccomp=unconfined" +if [ "$MOUNT_MAVEN_CACHE" == "ON" ] +then + CBASH_DOCKER_RUN_ARGS="$CBASH_DOCKER_RUN_ARGS -v $HOME/.m2/repository:/root/.m2/repository" +fi +CBASH_DOCKER_RUN_ARGS="$CBASH_DOCKER_RUN_ARGS -v $HOME/.ccache:/root/.ccache" +CBASH_DOCKER_RUN_ARGS="$CBASH_DOCKER_RUN_ARGS $EXTRA_DOCKER_OPTIONS" + +CBASH_BASH_ARGS="$*" +BASH_ARGS="$CBASH_BASH_ARGS" + +docker run $CBASH_DOCKER_RUN_ARGS $DOCKER_TARGET_IMAGE_BUILD_WITH_OS_IMAGE "cd /opt/gluten && $BASH_ARGS" diff --git a/tools/gluten-te/ubuntu/cbash.sh b/tools/gluten-te/ubuntu/cbash-mount.sh similarity index 98% rename from tools/gluten-te/ubuntu/cbash.sh rename to tools/gluten-te/ubuntu/cbash-mount.sh index 89092c44cde6..fed4f4c6196a 100755 --- a/tools/gluten-te/ubuntu/cbash.sh +++ b/tools/gluten-te/ubuntu/cbash-mount.sh @@ -29,7 +29,7 @@ PRESERVE_CONTAINER=${PRESERVE_CONTAINER:-$DEFAULT_PRESERVE_CONTAINER} # Docker options EXTRA_DOCKER_OPTIONS=${EXTRA_DOCKER_OPTIONS:-$DEFAULT_EXTRA_DOCKER_OPTIONS} -# Docker options +# Whether to mount Maven cache MOUNT_MAVEN_CACHE=${MOUNT_MAVEN_CACHE:-$DEFAULT_MOUNT_MAVEN_CACHE} CBASH_DOCKER_RUN_ARGS= diff --git a/tools/gluten-te/ubuntu/defaults.conf b/tools/gluten-te/ubuntu/defaults.conf index 2778f05e85f8..1971c1af0dd0 100644 --- a/tools/gluten-te/ubuntu/defaults.conf +++ b/tools/gluten-te/ubuntu/defaults.conf @@ -76,6 +76,6 @@ DEFAULT_DOCKER_TARGET_IMAGE_TPC_GDB_SERVER=gluten-te/gluten-tpc-gdb-server ## For cbash.sh # Whether to mount Maven cache -DEFAULT_MOUNT_MAVEN_CACHE=ON +DEFAULT_MOUNT_MAVEN_CACHE=OFF # EOF diff --git a/tools/gluten-te/ubuntu/dockerfile-build b/tools/gluten-te/ubuntu/dockerfile-build index 0d5fb963a0e2..fd3e9891a444 100644 --- a/tools/gluten-te/ubuntu/dockerfile-build +++ b/tools/gluten-te/ubuntu/dockerfile-build @@ -80,22 +80,4 @@ RUN EXTRA_MAVEN_OPTIONS=$(cat ~/.gluten-mvn-options) \ && bash -c "$DEPS_INSTALL_SCRIPT" \ && bash -c "mvn clean install $GLUTEN_MAVEN_OPTIONS $EXTRA_MAVEN_OPTIONS" -# Build Gluten -ARG TARGET_GLUTEN_REPO -ARG TARGET_GLUTEN_COMMIT - -RUN test -n "$TARGET_GLUTEN_REPO" || (echo "TARGET_GLUTEN_REPO not set" && false) -RUN test -n "$TARGET_GLUTEN_COMMIT" || (echo "TARGET_GLUTEN_COMMIT not set" && false) - -RUN cd /opt/gluten \ - && git fetch $TARGET_GLUTEN_REPO $TARGET_GLUTEN_COMMIT:build_$TARGET_GLUTEN_COMMIT \ - && git checkout build_$TARGET_GLUTEN_COMMIT - -RUN EXTRA_MAVEN_OPTIONS=$(cat ~/.gluten-mvn-options) \ - DEPS_INSTALL_SCRIPT=$(cat ~/.gluten-deps-install-script) \ - && cd /opt/gluten \ - && bash -c "$DEPS_INSTALL_SCRIPT" \ - && bash -c "mvn clean install $GLUTEN_MAVEN_OPTIONS $EXTRA_MAVEN_OPTIONS" \ - && bash -c "ln -sf ep/build-velox/build/velox_ep /opt/velox" - # EOF diff --git a/tools/gluten-te/ubuntu/dockerfile-tpc b/tools/gluten-te/ubuntu/dockerfile-tpc index 4222d6aea51f..d3f9ecde1966 100644 --- a/tools/gluten-te/ubuntu/dockerfile-tpc +++ b/tools/gluten-te/ubuntu/dockerfile-tpc @@ -3,6 +3,24 @@ ARG DOCKER_TARGET_IMAGE_BUILD_WITH_OS_IMAGE FROM $DOCKER_TARGET_IMAGE_BUILD_WITH_OS_IMAGE AS gluten-tpc MAINTAINER Hongze Zhang +# Incrementally build Gluten against target commit based on previous build +ARG TARGET_GLUTEN_REPO +ARG TARGET_GLUTEN_COMMIT + +RUN test -n "$TARGET_GLUTEN_REPO" || (echo "TARGET_GLUTEN_REPO not set" && false) +RUN test -n "$TARGET_GLUTEN_COMMIT" || (echo "TARGET_GLUTEN_COMMIT not set" && false) + +RUN cd /opt/gluten \ + && git fetch $TARGET_GLUTEN_REPO $TARGET_GLUTEN_COMMIT:build_$TARGET_GLUTEN_COMMIT \ + && git checkout build_$TARGET_GLUTEN_COMMIT + +RUN EXTRA_MAVEN_OPTIONS=$(cat ~/.gluten-mvn-options) \ + DEPS_INSTALL_SCRIPT=$(cat ~/.gluten-deps-install-script) \ + && cd /opt/gluten \ + && bash -c "$DEPS_INSTALL_SCRIPT" \ + && bash -c "mvn clean install $GLUTEN_MAVEN_OPTIONS $EXTRA_MAVEN_OPTIONS" \ + && bash -c "ln -sf /opt/gluten/ep/build-velox/build/velox_ep /opt/velox" + RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ssh net-tools vim unzip libjemalloc-dev ARG BUILD_BACKEND_TYPE diff --git a/tools/gluten-te/ubuntu/examples/buildhere-veloxbe-dev/run.sh b/tools/gluten-te/ubuntu/examples/buildhere-veloxbe-dev/run.sh index 76b97231ba95..f2c5a1c6dba1 100755 --- a/tools/gluten-te/ubuntu/examples/buildhere-veloxbe-dev/run.sh +++ b/tools/gluten-te/ubuntu/examples/buildhere-veloxbe-dev/run.sh @@ -23,5 +23,5 @@ TIMESTAMP=$(date +%s) export EXTRA_DOCKER_OPTIONS="--name buildhere-veloxbe-dev-$TIMESTAMP --detach -v $BASEDIR/scripts:/opt/scripts" export PRESERVE_CONTAINER=ON -$BASEDIR/../../cbash.sh 'bash /root/.cmd.sh' +$BASEDIR/../../cbash-mount.sh 'bash /root/.cmd.sh' docker exec buildhere-veloxbe-dev-$TIMESTAMP '/opt/scripts/all.sh' diff --git a/tools/gluten-te/ubuntu/examples/buildhere-veloxbe/run.sh b/tools/gluten-te/ubuntu/examples/buildhere-veloxbe/run.sh index 64a449593ae2..ec4a1d628b07 100755 --- a/tools/gluten-te/ubuntu/examples/buildhere-veloxbe/run.sh +++ b/tools/gluten-te/ubuntu/examples/buildhere-veloxbe/run.sh @@ -25,4 +25,4 @@ EXTRA_MAVEN_OPTIONS="-Pspark-3.2 \ -Dscalastyle.skip=true \ -Dcheckstyle.skip=true" -$BASEDIR/../../cbash.sh "cd /opt/gluten && dev/builddeps-veloxbe.sh && mvn clean install $EXTRA_MAVEN_OPTIONS" +$BASEDIR/../../cbash-mount.sh "cd /opt/gluten && dev/builddeps-veloxbe.sh && mvn clean install $EXTRA_MAVEN_OPTIONS" diff --git a/tools/gluten-te/ubuntu/gha/gha-checkout/checkout.sh b/tools/gluten-te/ubuntu/gha/gha-checkout/checkout.sh new file mode 100755 index 000000000000..15c28f5849d0 --- /dev/null +++ b/tools/gluten-te/ubuntu/gha/gha-checkout/checkout.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -ex + +BASEDIR=$(readlink -f $(dirname $0)) + +source "$BASEDIR/../../defaults.conf" + +if [ -z "$GITHUB_RUN_ID" ] +then + echo "Unable to parse GITHUB_RUN_ID." + exit 1 +fi + +export EXTRA_DOCKER_OPTIONS="$EXTRA_DOCKER_OPTIONS --name gha-checkout-$GITHUB_RUN_ID --detach -v $BASEDIR/scripts:/opt/scripts" +export NON_INTERACTIVE=ON + +$BASEDIR/../../cbash-build.sh 'sleep 14400' + +# The target branches +TARGET_GLUTEN_REPO=${TARGET_GLUTEN_REPO:-$DEFAULT_GLUTEN_REPO} +FALLBACK_GLUTEN_BRANCH=${FALLBACK_GLUTEN_BRANCH:-$DEFAULT_GLUTEN_BRANCH} +FALLBACK_GLUTEN_COMMIT="$(git ls-remote $TARGET_GLUTEN_REPO $FALLBACK_GLUTEN_BRANCH | awk '{print $1;}')" + +TARGET_GLUTEN_COMMIT="${GITHUB_SHA:-$FALLBACK_GLUTEN_COMMIT}" + +$BASEDIR/exec.sh "/opt/scripts/init.sh $TARGET_GLUTEN_REPO $TARGET_GLUTEN_COMMIT" diff --git a/tools/gluten-te/ubuntu/gha/gha-checkout/clean.sh b/tools/gluten-te/ubuntu/gha/gha-checkout/clean.sh new file mode 100755 index 000000000000..f67f6bf0058b --- /dev/null +++ b/tools/gluten-te/ubuntu/gha/gha-checkout/clean.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -ex + +if [ -z "$GITHUB_RUN_ID" ] +then + echo "Unable to parse GITHUB_RUN_ID." + exit 1 +fi + +docker stop gha-checkout-$GITHUB_RUN_ID || true diff --git a/tools/gluten-te/ubuntu/gha/gha-checkout/exec.sh b/tools/gluten-te/ubuntu/gha/gha-checkout/exec.sh new file mode 100755 index 000000000000..1497ab6f2edf --- /dev/null +++ b/tools/gluten-te/ubuntu/gha/gha-checkout/exec.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -ex + +CBASH_BASH_ARGS="$*" +BASH_ARGS="$CBASH_BASH_ARGS" + +if [ -z "$GITHUB_RUN_ID" ] +then + echo "Unable to parse GITHUB_RUN_ID." + exit 1 +fi + +docker exec gha-checkout-$GITHUB_RUN_ID bash -c "cd /opt/gluten && $BASH_ARGS" diff --git a/tools/gluten-te/ubuntu/gha/gha-checkout/scripts/init.sh b/tools/gluten-te/ubuntu/gha/gha-checkout/scripts/init.sh new file mode 100755 index 000000000000..7c70ccf0d406 --- /dev/null +++ b/tools/gluten-te/ubuntu/gha/gha-checkout/scripts/init.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -ex + +TARGET_GLUTEN_REPO=$1 +TARGET_GLUTEN_COMMIT=$2 + +cd /opt/gluten + +git fetch $TARGET_GLUTEN_REPO $TARGET_GLUTEN_COMMIT:build_$TARGET_GLUTEN_COMMIT +git checkout build_$TARGET_GLUTEN_COMMIT diff --git a/tools/gluten-te/ubuntu/tpc.sh b/tools/gluten-te/ubuntu/tpc.sh index 740a823a96b3..ff4eb9c7089f 100755 --- a/tools/gluten-te/ubuntu/tpc.sh +++ b/tools/gluten-te/ubuntu/tpc.sh @@ -61,23 +61,39 @@ else DOCKER_BUILD_TARGET_NAME=gluten-tpc fi -DOCKER_SELECTED_TARGET_IMAGE_TPC_WITH_OS_IMAGE="$DOCKER_SELECTED_TARGET_IMAGE_TPC-$OS_IMAGE" +# The target branches +TARGET_GLUTEN_REPO=${TARGET_GLUTEN_REPO:-$DEFAULT_GLUTEN_REPO} +TARGET_GLUTEN_BRANCH=${TARGET_GLUTEN_BRANCH:-$DEFAULT_GLUTEN_BRANCH} -# GDB server bind port -GDB_SERVER_PORT=${GDB_SERVER_PORT:-$DEFAULT_GDB_SERVER_PORT} +## Fetch target commit -# JVM jdwp bind port -JDWP_SERVER_PORT=${JDWP_SERVER_PORT:-$DEFAULT_JDWP_SERVER_PORT} +TARGET_GLUTEN_COMMIT="$(git ls-remote $TARGET_GLUTEN_REPO $TARGET_GLUTEN_BRANCH | awk '{print $1;}')" + +if [ -z "$TARGET_GLUTEN_COMMIT" ] +then + echo "Unable to parse TARGET_GLUTEN_COMMIT." + exit 1 +fi + +DOCKER_SELECTED_TARGET_IMAGE_TPC_WITH_OS_IMAGE="$DOCKER_SELECTED_TARGET_IMAGE_TPC-$OS_IMAGE" TPC_DOCKER_BUILD_ARGS= TPC_DOCKER_BUILD_ARGS="$TPC_DOCKER_BUILD_ARGS --ulimit nofile=8192:8192" TPC_DOCKER_BUILD_ARGS="$TPC_DOCKER_BUILD_ARGS --build-arg BUILDKIT_INLINE_CACHE=1" TPC_DOCKER_BUILD_ARGS="$TPC_DOCKER_BUILD_ARGS --build-arg DOCKER_TARGET_IMAGE_BUILD_WITH_OS_IMAGE=$DOCKER_TARGET_IMAGE_BUILD_WITH_OS_IMAGE" +TPC_DOCKER_BUILD_ARGS="$TPC_DOCKER_BUILD_ARGS --build-arg TARGET_GLUTEN_REPO=$TARGET_GLUTEN_REPO" +TPC_DOCKER_BUILD_ARGS="$TPC_DOCKER_BUILD_ARGS --build-arg TARGET_GLUTEN_COMMIT=$TARGET_GLUTEN_COMMIT" TPC_DOCKER_BUILD_ARGS="$TPC_DOCKER_BUILD_ARGS --build-arg BUILD_BACKEND_TYPE=$BUILD_BACKEND_TYPE" TPC_DOCKER_BUILD_ARGS="$TPC_DOCKER_BUILD_ARGS -f $BASEDIR/dockerfile-tpc" TPC_DOCKER_BUILD_ARGS="$TPC_DOCKER_BUILD_ARGS --target $DOCKER_BUILD_TARGET_NAME" TPC_DOCKER_BUILD_ARGS="$TPC_DOCKER_BUILD_ARGS -t $DOCKER_SELECTED_TARGET_IMAGE_TPC_WITH_OS_IMAGE" +# GDB server bind port +GDB_SERVER_PORT=${GDB_SERVER_PORT:-$DEFAULT_GDB_SERVER_PORT} + +# JVM jdwp bind port +JDWP_SERVER_PORT=${JDWP_SERVER_PORT:-$DEFAULT_JDWP_SERVER_PORT} + if [ -n "$DOCKER_CACHE_REGISTRY" ] then TPC_DOCKER_BUILD_ARGS="$TPC_DOCKER_BUILD_ARGS --cache-from $DOCKER_CACHE_REGISTRY/$DOCKER_SELECTED_TARGET_IMAGE_TPC_WITH_OS_IMAGE"