-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathsubmodule-sync.sh
executable file
·124 lines (107 loc) · 4.34 KB
/
submodule-sync.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
#
# Copyright (c) 2022-2024, NVIDIA CORPORATION. All rights reserved.
#
# Licensed 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.
#
# NOTE:
# this script is for jenkins only, and should not be used for local development
# run with ci/Dockerfile in jenkins:
# scl enable gcc-toolset-11 ci/submodule-sync.sh
set -ex
OWNER=${OWNER:-"NVIDIA"}
REPO=${REPO:-"spark-rapids-jni"}
PARALLEL_LEVEL=${PARALLEL_LEVEL:-4}
REPO_LOC="github.com/${OWNER}/${REPO}.git"
GIT_AUTHOR_NAME="spark-rapids automation"
GIT_COMMITTER_NAME="spark-rapids automation"
GIT_AUTHOR_EMAIL="[email protected]"
GIT_COMMITTER_EMAIL="[email protected]"
git submodule update --init --recursive
cudf_prev_sha=$(git -C thirdparty/cudf rev-parse HEAD)
INTERMEDIATE_HEAD=bot-submodule-sync-${REF}
# try cleanup remote first if no open PR for HEAD targeting BASE
$WORKSPACE/.github/workflows/action-helper/python/cleanup-bot-branch \
--owner=${OWNER} --repo=${REPO} --head=${INTERMEDIATE_HEAD} --base=${REF} --token=${GIT_TOKEN} || true
remote_head=$(git ls-remote --heads origin ${INTERMEDIATE_HEAD})
if [[ -z $remote_head ]]; then
git checkout -b ${INTERMEDIATE_HEAD} origin/${REF}
else
git fetch origin ${INTERMEDIATE_HEAD} ${REF}
git checkout -b ${INTERMEDIATE_HEAD} origin/${INTERMEDIATE_HEAD}
git merge origin/${REF}
fi
# sync up cudf from remote, checkout to cudf release tag if CUDF_TAG is set
if [ -n "$CUDF_TAG" ]; then
pushd thirdparty/cudf
git checkout tags/$CUDF_TAG
popd
else
git submodule update --remote --merge
fi
cudf_sha=$(git -C thirdparty/cudf rev-parse HEAD)
if [[ "${cudf_sha}" == "${cudf_prev_sha}" ]]; then
echo "Submodule is up to date."
exit 0
fi
echo "Try update cudf submodule to ${cudf_sha}..."
git add .
echo "Test against ${cudf_sha}..."
MVN="mvn -Dmaven.wagon.http.retryHandler.count=3 -B"
set +e
${MVN} verify ${MVN_MIRROR} \
-DCPP_PARALLEL_LEVEL=${PARALLEL_LEVEL} \
-Dlibcudf.build.configure=true \
-Dlibcudf.dependency.mode=latest \
-DUSE_GDS=ON -Dtest=*,!CuFileTest,!CudaFatalTest,!ColumnViewNonEmptyNullsTest \
-DBUILD_TESTS=ON \
-DUSE_SANITIZER=ON
verify_status=$?
set -e
test_pass="False"
if [[ "${verify_status}" == "0" ]]; then
echo "Test passed, will try merge the change"
test_pass="True"
else
echo "Test failed, will update the result"
fi
build_name=$(${MVN} help:evaluate -Dexpression=project.build.finalName -q -DforceStdout)
cuda_version=$(${MVN} help:evaluate -Dexpression=cuda.version -q -DforceStdout)
. ci/check-cuda-dependencies.sh "target/${build_name}-${cuda_version}.jar"
LIBCUDF_BUILD_PATH=$(${MVN} help:evaluate -Dexpression=libcudf.build.path -q -DforceStdout)
# Extract the rapids-cmake sha1 that we need to pin too
rapids_cmake_sha=$(git -C ${LIBCUDF_BUILD_PATH}/_deps/rapids-cmake-src/ rev-parse HEAD)
echo "Update rapids-cmake pinned SHA1 to ${rapids_cmake_sha}"
echo "${rapids_cmake_sha}" > thirdparty/cudf-pins/rapids-cmake.sha
# Do the git add after the build so that we get
# the updated versions.json generated by the build
echo "Update cudf submodule to ${cudf_sha} with updated pinned versions"
git add .
git diff-index --quiet HEAD || git commit -s -m "Update submodule cudf to ${cudf_sha}"
sha=$(git rev-parse HEAD)
# push the intermediate branch and create PR against REF
# if test passed, it will try auto-merge the PR
# if test failed, it will only comment the test result in the PR
git push https://${GIT_USER}:${GIT_TOKEN}@${REPO_LOC} ${INTERMEDIATE_HEAD}
sleep 30 # sleep for a while to avoid inconsistent sha between HEAD branch and GitHub REST API
$WORKSPACE/.github/workflows/action-helper/python/submodule-sync \
--owner=${OWNER} \
--repo=${REPO} \
--head=${INTERMEDIATE_HEAD} \
--base=${REF} \
--sha=${sha} \
--cudf_sha=${cudf_sha} \
--token=${GIT_TOKEN} \
--passed=${test_pass} \
--delete_head=True
exit $verify_status # always exit return code of mvn verify at the end