|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | 3 | # Common setup for all Jenkins scripts |
4 | | - |
5 | | -# NB: define this function before set -x, so that we don't |
6 | | -# pollute the log with a premature EXITED_USER_LAND ;) |
7 | | -function cleanup { |
8 | | - # Note that if you've exited user land, then CI will conclude that |
9 | | - # any failure is the CI's fault. So we MUST only output this |
10 | | - # string |
11 | | - retcode=$? |
12 | | - set +x |
13 | | - if [ $retcode -eq 0 ]; then |
14 | | - echo "EXITED_USER_LAND" |
15 | | - fi |
16 | | -} |
17 | | - |
| 4 | +source "$(dirname "${BASH_SOURCE[0]}")/common_utils.sh" |
18 | 5 | set -ex |
19 | 6 |
|
20 | 7 | # Save the SCRIPT_DIR absolute path in case later we chdir (as occurs in the gpu perf test) |
@@ -77,20 +64,6 @@ declare -f -t trap_add |
77 | 64 |
|
78 | 65 | trap_add cleanup EXIT |
79 | 66 |
|
80 | | -function assert_git_not_dirty() { |
81 | | - # TODO: we should add an option to `build_amd.py` that reverts the repo to |
82 | | - # an unmodified state. |
83 | | - if ([[ "$BUILD_ENVIRONMENT" != *rocm* ]] && [[ "$BUILD_ENVIRONMENT" != *xla* ]]) ; then |
84 | | - git_status=$(git status --porcelain) |
85 | | - if [[ $git_status ]]; then |
86 | | - echo "Build left local git repository checkout dirty" |
87 | | - echo "git status --porcelain:" |
88 | | - echo "${git_status}" |
89 | | - exit 1 |
90 | | - fi |
91 | | - fi |
92 | | -} |
93 | | -
|
94 | 67 | if [[ "$BUILD_ENVIRONMENT" != *pytorch-win-* ]]; then |
95 | 68 | if which sccache > /dev/null; then |
96 | 69 | # Save sccache logs to file |
@@ -158,43 +131,7 @@ if [[ "$BUILD_ENVIRONMENT" == *pytorch-xla-linux-bionic* ]] || \ |
158 | 131 | fi |
159 | 132 | fi |
160 | 133 |
|
161 | | -function pip_install() { |
162 | | - # retry 3 times |
163 | | - # old versions of pip don't have the "--progress-bar" flag |
164 | | - pip install --progress-bar off "$@" || pip install --progress-bar off "$@" || pip install --progress-bar off "$@" ||\ |
165 | | - pip install "$@" || pip install "$@" || pip install "$@" |
166 | | -} |
167 | | -
|
168 | | -function pip_uninstall() { |
169 | | - # uninstall 2 times |
170 | | - pip uninstall -y "$@" || pip uninstall -y "$@" |
171 | | -} |
172 | | -
|
173 | 134 | retry () { |
174 | 135 | $* || (sleep 1 && $*) || (sleep 2 && $*) |
175 | 136 | } |
176 | 137 |
|
177 | | -function get_exit_code() { |
178 | | - set +e |
179 | | - "$@" |
180 | | - retcode=$? |
181 | | - set -e |
182 | | - return $retcode |
183 | | -} |
184 | | -
|
185 | | -function file_diff_from_base() { |
186 | | - # The fetch may fail on Docker hosts, but it's not always necessary. |
187 | | - set +e |
188 | | - git fetch origin master --quiet |
189 | | - set -e |
190 | | - git diff --name-only "$(git merge-base origin/master HEAD)" > "$1" |
191 | | -} |
192 | | -
|
193 | | -function get_bazel() { |
194 | | - # download bazel version |
195 | | - wget https://github.com/bazelbuild/bazel/releases/download/3.1.0/bazel-3.1.0-linux-x86_64 -O tools/bazel |
196 | | - # verify content |
197 | | - echo '753434f4fa730266cf5ce21d1fdd425e1e167dd9347ad3e8adc19e8c0d54edca tools/bazel' | sha256sum --quiet -c |
198 | | -
|
199 | | - chmod +x tools/bazel |
200 | | -} |
0 commit comments