run-jenkins.sh 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. #!/bin/bash -e
  2. # -*- mode: shell-script; indent-tabs-mode: nil; -*-
  3. export MONO_REPO_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../../" && pwd )"
  4. export TESTCMD=${MONO_REPO_ROOT}/scripts/ci/run-step.sh
  5. export CI=1
  6. export CI_PR=$([[ ${CI_TAGS} == *'pull-request'* ]] && echo 1 || true)
  7. export CI_CPU_COUNT=$(getconf _NPROCESSORS_ONLN || getconf NPROCESSORS_ONLN || echo 4)
  8. export TEST_HARNESS_VERBOSE=1
  9. # workaround for acceptance-tests submodules leaving files behind since Jenkins only does "git clean -xdf" (no second 'f')
  10. # which won't clean untracked .git repos (remove once https://github.com/jenkinsci/git-plugin/pull/449 is available)
  11. for dir in acceptance-tests/external/*; do [ -d "$dir" ] && (cd "$dir" && echo "Cleaning $dir" && git clean -xdff); done
  12. source ${MONO_REPO_ROOT}/scripts/ci/util.sh
  13. # if [[ ${CI_TAGS} == *'pull-request'* ]]; then
  14. # # Skip lanes which are not affected by the PR
  15. # wget -O pr-contents.diff "${ghprbPullLink}.diff"
  16. # grep '^diff' pr-contents.diff > pr-files.txt
  17. # echo "Files affected by the PR:"
  18. # cat pr-files.txt
  19. # # FIXME: Add more
  20. # skip=false
  21. # skip_step=""
  22. # if ! grep -q -v a/mono/mini/mini-ppc pr-files.txt; then
  23. # skip_step="PPC"
  24. # skip=true
  25. # fi
  26. # if ! grep -q -v a/scripts/ci/provisioning pr-files.txt; then
  27. # skip_step="CI provisioning scripts"
  28. # skip=true
  29. # fi
  30. # if [ $skip = true ]; then
  31. # ${TESTCMD} --label="Skipped on ${skip_step}." --timeout=60m --fatal sh -c 'exit 0'
  32. # if [[ $CI_TAGS == *'apidiff'* ]]; then report_github_status "success" "API Diff" "Skipped." || true; fi
  33. # exit 0
  34. # fi
  35. # rm pr-files.txt
  36. # fi
  37. make_timeout=300m
  38. gnumake=$(which gmake || which gnumake || which make)
  39. if [[ ${CI_TAGS} == *'clang-sanitizer'* ]]; then
  40. export CC="clang"
  41. export CXX="clang++"
  42. export CFLAGS="$CFLAGS -g -O1 -fsanitize=thread -fsanitize-blacklist=${MONO_REPO_ROOT}/scripts/ci/clang-thread-sanitizer-blacklist -mllvm -tsan-instrument-atomics=false"
  43. export LDFLAGS="-fsanitize=thread"
  44. # TSAN_OPTIONS are used by programs that were compiled with Clang's ThreadSanitizer
  45. # see https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags for more details
  46. export TSAN_OPTIONS="history_size=7:exitcode=0:force_seq_cst_atomics=1"
  47. make_timeout=30m
  48. fi
  49. if [[ ${CI_TAGS} == *'win-'* ]]; then
  50. # Passing -ggdb3 on Cygwin breaks linking against libmonosgen-x.y.dll
  51. export CFLAGS="$CFLAGS -g -O2"
  52. else
  53. export EXTRA_CFLAGS="$EXTRA_CFLAGS -ggdb3 -O2"
  54. fi
  55. if [[ $CI_TAGS == *'collect-coverage'* ]]; then
  56. # Collect coverage for further use by lcov and similar tools.
  57. # Coverage must be collected with -O0 and debug information.
  58. export CFLAGS="$CFLAGS -ggdb3 --coverage -O0"
  59. fi
  60. if [[ $CI_TAGS == *'retry-flaky-tests'* ]]; then
  61. export MONO_FLAKY_TEST_RETRIES=5
  62. fi
  63. # We don't want to have to maintain symbolification blobs for CI
  64. export EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-crash-privacy=no "
  65. if [[ ${CI_TAGS} == *'osx-i386'* ]]; then EXTRA_CFLAGS="$EXTRA_CFLAGS -m32 -arch i386 -mmacosx-version-min=10.9"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -m32 -arch i386"; EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-libgdiplus=/Library/Frameworks/Mono.framework/Versions/Current/lib/libgdiplus.dylib --host=i386-apple-darwin13.0.0 --build=i386-apple-darwin13.0.0"; fi
  66. if [[ ${CI_TAGS} == *'osx-amd64'* ]]; then EXTRA_CFLAGS="$EXTRA_CFLAGS -m64 -arch x86_64 -mmacosx-version-min=10.9"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -m64 -arch x86_64" EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-libgdiplus=/Library/Frameworks/Mono.framework/Versions/Current/lib/libgdiplus.dylib"; fi
  67. if [[ ${CI_TAGS} == *'win-i386'* ]]; then PLATFORM=Win32; EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --host=i686-w64-mingw32 --enable-btls"; export MONO_EXECUTABLE="${MONO_REPO_ROOT}/msvc/build/sgen/Win32/bin/Release/mono-sgen.exe"; fi
  68. if [[ ${CI_TAGS} == *'win-amd64'* ]]; then PLATFORM=x64; EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --host=x86_64-w64-mingw32 --disable-boehm --enable-btls"; export MONO_EXECUTABLE="${MONO_REPO_ROOT}/msvc/build/sgen/x64/bin/Release/mono-sgen.exe"; fi
  69. if [[ ${CI_TAGS} == *'freebsd-amd64'* ]]; then export CC="clang"; export CXX="clang++"; EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --disable-dtrace --disable-boehm ac_cv_header_sys_inotify_h=no ac_cv_func_inotify_init=no ac_cv_func_inotify_add_watch=no ac_cv_func_inotify_rm_watch=no"; fi
  70. if [[ ${CI_TAGS} == *'make-install'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-llvm --prefix=${MONO_REPO_ROOT}/tmp/monoprefix"; fi
  71. if [[ ${CI_TAGS} == *'coop-suspend'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --disable-hybrid-suspend --enable-cooperative-suspend";
  72. elif [[ ${CI_TAGS} == *'hybrid-suspend'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-hybrid-suspend";
  73. elif [[ ${CI_TAGS} == *'preemptive-suspend'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --disable-hybrid-suspend";
  74. fi
  75. if [[ ${CI_TAGS} == *'checked-coop'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-checked-build=gc,thread"; fi
  76. if [[ ${CI_TAGS} == *'checked-all'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-checked-build=all"; fi
  77. if [[ ${CI_TAGS} == *'mcs-compiler'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-csc=mcs"; fi
  78. if [[ ${CI_TAGS} == *'disable-mcs-build'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --disable-mcs-build"; fi
  79. if [[ ${CI_TAGS} == *'fullaot_llvm'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-llvm=yes --with-runtime-preset=fullaot_llvm ";
  80. elif [[ ${CI_TAGS} == *'hybridaot_llvm'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-llvm=yes --with-runtime-preset=hybridaot_llvm";
  81. elif [[ ${CI_TAGS} == *'winaot_llvm'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-llvm=yes --with-runtime-preset=winaot_llvm";
  82. elif [[ ${CI_TAGS} == *'aot_llvm'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-llvm=yes --with-runtime-preset=aot_llvm ";
  83. elif [[ ${CI_TAGS} == *'jit_llvm'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-llvm=yes"; export MONO_ENV_OPTIONS="$MONO_ENV_OPTIONS --llvm";
  84. elif [[ ${CI_TAGS} == *'fullaotinterp_llvm'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-llvm=yes --with-runtime-preset=fullaotinterp_llvm";
  85. elif [[ ${CI_TAGS} == *'fullaotinterp'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime-preset=fullaotinterp";
  86. elif [[ ${CI_TAGS} == *'winaotinterp'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime-preset=winaotinterp";
  87. elif [[ ${CI_TAGS} == *'winaotinterp_llvm'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-llvm=yes --with-runtime-preset=winaotinterp_llvm";
  88. elif [[ ${CI_TAGS} == *'fullaot'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime-preset=fullaot";
  89. elif [[ ${CI_TAGS} == *'hybridaot'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime-preset=hybridaot";
  90. elif [[ ${CI_TAGS} == *'winaot'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime-preset=winaot";
  91. elif [[ ${CI_TAGS} == *'aot'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime-preset=aot";
  92. elif [[ ${CI_TAGS} == *'bitcodeinterp'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime-preset=bitcodeinterp"; export PATH="$PATH:${MONO_REPO_ROOT}/llvm/usr/bin";
  93. elif [[ ${CI_TAGS} == *'bitcode'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime-preset=bitcode"; export PATH="$PATH:${MONO_REPO_ROOT}/llvm/usr/bin";
  94. elif [[ ${CI_TAGS} == *'acceptance-tests'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --prefix=${MONO_REPO_ROOT}/tmp/mono-acceptance-tests --with-sgen-default-concurrent=yes";
  95. elif [[ ${CI_TAGS} == *'all-profiles'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime-preset=all";
  96. elif [[ ${CI_TAGS} == *'compile-msbuild-source'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --prefix=/tmp/mono-from-source";
  97. fi
  98. if [ -x "/usr/bin/dpkg-architecture" ];
  99. then
  100. EXTRA_CONF_FLAGS="$EXTRA_CONF_FLAGS --host=`/usr/bin/dpkg-architecture -qDEB_HOST_GNU_TYPE`"
  101. #force build arch = dpkg arch, sometimes misdetected
  102. mkdir -p ~/.config/.mono/
  103. wget -O- https://download.mono-project.com/test/new-certs.tgz | tar zx -C ~/.config/.mono/
  104. fi
  105. if [[ ${CI_TAGS} == *'cxx'* ]]; then
  106. EXTRA_CONF_FLAGS="$EXTRA_CONF_FLAGS -enable-cxx"
  107. MSBUILD_CXX="/p:MONO_COMPILE_AS_CPP=true"
  108. fi
  109. if [[ ${CI_TAGS} == *'microbench'* ]]; then
  110. EXTRA_CONF_FLAGS="$EXTRA_CONF_FLAGS --with-profile4_x=yes"
  111. fi
  112. if [[ ${CI_TAGS} == *'win-'* ]];
  113. then
  114. mkdir -p ~/.config/.mono/
  115. wget -qO- https://download.mono-project.com/test/new-certs.tgz| tar zx -C ~/.config/.mono/
  116. fi
  117. if [[ ${CI_TAGS} == *'ccache'* ]];
  118. then
  119. # CCACHE_DIR should be set to a directory outside the chroot which holds the cache
  120. CCACHE=$(which ccache)
  121. if [ "$CCACHE" ]; then
  122. if [[ ${CI_TAGS} == *'osx-'* ]]; then
  123. export CC="ccache clang"
  124. export CXX="ccache clang++"
  125. else
  126. export CC="ccache gcc"
  127. export CXX="ccache g++"
  128. fi
  129. fi
  130. fi
  131. if [[ ${CI_TAGS} != *'mac-sdk'* ]]; # Mac SDK builds Mono itself
  132. then
  133. echo ./autogen.sh CFLAGS="$CFLAGS $EXTRA_CFLAGS" CXXFLAGS="$CXXFLAGS $EXTRA_CXXFLAGS" LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS" $EXTRA_CONF_FLAGS
  134. ${TESTCMD} --label=configure --timeout=60m --fatal ./autogen.sh CFLAGS="$CFLAGS $EXTRA_CFLAGS" CXXFLAGS="$CXXFLAGS $EXTRA_CXXFLAGS" LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS" $EXTRA_CONF_FLAGS
  135. fi
  136. if [[ ${CI_TAGS} == *'msvc142'* ]]; then
  137. export VS_PLATFORMTOOLSETVERSION=v142
  138. else
  139. export VS_PLATFORMTOOLSETVERSION=v140
  140. fi
  141. if [[ ${CI_TAGS} == *'win-i386'* ]];
  142. then
  143. # only build boehm on w32 (only windows platform supporting boehm).
  144. ${TESTCMD} --label=make-msvc --timeout=60m --fatal ./msvc/run-msbuild.sh "build" "${PLATFORM}" "release" "boehm" "/p:PlatformToolset=${VS_PLATFORMTOOLSETVERSION} ${MSBUILD_CXX}"
  145. fi
  146. if [[ ${CI_TAGS} == *'win-'* ]];
  147. then
  148. ${TESTCMD} --label=make-msvc-sgen --timeout=60m --fatal ./msvc/run-msbuild.sh "build" "${PLATFORM}" "release" "sgen" "/p:PlatformToolset=${VS_PLATFORMTOOLSETVERSION} ${MSBUILD_CXX}"
  149. fi
  150. if [[ ${CI_TAGS} == *'win-amd64'* ]];
  151. then
  152. # The AOT compiler on Windows requires Visual Studio's clang.exe and link.exe.
  153. # Depending on codegen (JIT/LLVM) it might also need platform specific libraries.
  154. # Use a wrapper script that will make sure to setup full VS MSVC environment if
  155. # needed when running mono-sgen.exe as AOT compiler.
  156. export MONO_EXECUTABLE_WRAPPER="${MONO_REPO_ROOT}/msvc/build/sgen/x64/bin/Release/mono-sgen-msvc.sh"
  157. fi
  158. if [[ ${CI_TAGS} == *'monolite'* ]]; then make get-monolite-latest; fi
  159. make_parallelism="-j ${CI_CPU_COUNT}"
  160. if [[ ${CI_TAGS} == *'linux-ppc64el'* ]]; then make_parallelism=-j1; fi
  161. make_continue=
  162. if [[ ${CI_TAGS} == *'checked-all'* ]]; then make_continue=-k; fi
  163. if [[ ${CI_TAGS} != *'mac-sdk'* ]]; # Mac SDK builds Mono itself
  164. then
  165. build_error=0
  166. ${TESTCMD} --label=make --timeout=${make_timeout} --fatal make ${make_parallelism} ${make_continue} -w V=1 || build_error=1
  167. if [[ ${build_error} != 0 ]]; then
  168. echo "ERROR: The Mono build failed."
  169. exit ${build_error}
  170. fi
  171. fi
  172. if [[ ${CI_TAGS} == *'checked-coop'* ]]; then export MONO_CHECK_MODE=gc,thread; fi
  173. if [[ ${CI_TAGS} == *'checked-all'* ]]; then export MONO_CHECK_MODE=all; fi
  174. if [[ ${CI_TAGS} == *'hardened-runtime'* ]]; then codesign -s - -fv -o runtime --entitlements ${MONO_REPO_ROOT}/mono/mini/mac-entitlements.plist ${MONO_REPO_ROOT}/mono/mini/mono-sgen; fi
  175. export MONO_ENV_OPTIONS="$MONO_ENV_OPTIONS $MONO_TEST_ENV_OPTIONS"
  176. if [[ ${CI_TAGS} == *'acceptance-tests'* ]]; then ${MONO_REPO_ROOT}/scripts/ci/run-test-acceptance-tests.sh;
  177. elif [[ ${CI_TAGS} == *'microbench'* ]]; then ${MONO_REPO_ROOT}/scripts/ci/run-test-microbench.sh;
  178. elif [[ ${CI_TAGS} == *'profiler-stress-tests'* ]]; then ${MONO_REPO_ROOT}/scripts/ci/run-test-profiler-stress-tests.sh;
  179. elif [[ ${CI_TAGS} == *'stress-tests'* ]]; then ${MONO_REPO_ROOT}/scripts/ci/run-test-stress-tests.sh;
  180. elif [[ ${CI_TAGS} == *'interpreter'* ]]; then ${MONO_REPO_ROOT}/scripts/ci/run-test-interpreter.sh;
  181. elif [[ ${CI_TAGS} == *'mcs-compiler'* ]]; then ${MONO_REPO_ROOT}/scripts/ci/run-test-mcs.sh;
  182. elif [[ ${CI_TAGS} == *'mac-sdk'* ]]; then ${MONO_REPO_ROOT}/scripts/ci/run-test-mac-sdk.sh;
  183. elif [[ ${CI_TAGS} == *'compile-msbuild-source'* ]]; then ${MONO_REPO_ROOT}/scripts/ci/run-test-msbuild.sh;
  184. elif [[ ${CI_TAGS} == *'make-install'* ]]; then ${MONO_REPO_ROOT}/scripts/ci/run-test-make-install.sh;
  185. elif [[ ${CI_TAGS} == *'compiler-server-tests'* ]]; then ${MONO_REPO_ROOT}/scripts/ci/run-test-compiler-server.sh;
  186. elif [[ ${CI_TAGS} == *'no-tests'* ]]; then echo "Skipping tests.";
  187. else make check-ci;
  188. fi
  189. if [[ $CI_TAGS == *'apidiff'* ]]; then ${TESTCMD} --label=apidiff --timeout=15m --fatal make -w -C mcs -j ${CI_CPU_COUNT} mono-api-diff; fi