[ci] Small improvements for run-jenkins and collect-coverage. (#5669)
[mono.git] / scripts / ci / run-jenkins.sh
1 #!/bin/bash -e
2
3 export MONO_REPO_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../../" && pwd )"
4 export TESTCMD=${MONO_REPO_ROOT}/scripts/ci/run-step.sh
5
6 export TEST_HARNESS_VERBOSE=1
7
8 make_timeout=300m
9
10 if [[ $CI_TAGS == *'collect-coverage'* ]]; then
11     # Collect coverage for further use by lcov and similar tools.
12     # Coverage must be collected with -O0 and debug information.
13     export CFLAGS="$CFLAGS -ggdb3 --coverage -O0"
14 fi
15
16 if [[ ${CI_TAGS} == *'clang-sanitizer'* ]]; then
17         export CC="clang"
18         export CXX="clang++"
19         export CFLAGS="$CFLAGS -g -O1 -fsanitize=thread -fsanitize-blacklist=${MONO_REPO_ROOT}/scripts/ci/clang-thread-sanitizer-blacklist -mllvm -tsan-instrument-atomics=false"
20         export LDFLAGS="-fsanitize=thread"
21         # TSAN_OPTIONS are used by programs that were compiled with Clang's ThreadSanitizer
22         # see https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags for more details
23         export TSAN_OPTIONS="history_size=7:exitcode=0:force_seq_cst_atomics=1"
24         make_timeout=30m
25 fi
26
27 if [[ ${label} == w* ]]; then
28     # Passing -ggdb3 on Cygwin breaks linking against libmonosgen-x.y.dll
29     export CFLAGS="$CFLAGS -g -O2"
30 else
31     export CFLAGS="$CFLAGS -ggdb3 -O2"
32 fi
33
34 if [[ $CI_TAGS == *'retry-flaky-tests'* ]]; then
35     export MONO_FLAKY_TEST_RETRIES=5
36 fi
37
38 if [[ ${label} == 'osx-i386' ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-libgdiplus=/Library/Frameworks/Mono.framework/Versions/Current/lib/libgdiplus.dylib --build=i386-apple-darwin11.2.0"; fi
39 if [[ ${label} == 'osx-amd64' ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-libgdiplus=/Library/Frameworks/Mono.framework/Versions/Current/lib/libgdiplus.dylib "; fi
40 if [[ ${label} == 'w32' ]]; then PLATFORM=Win32; EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --host=i686-w64-mingw32"; export MONO_EXECUTABLE="${MONO_REPO_ROOT}/msvc/build/sgen/Win32/bin/Release/mono-sgen.exe"; fi
41 if [[ ${label} == 'w64' ]]; then PLATFORM=x64; EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --host=x86_64-w64-mingw32 --disable-boehm"; export MONO_EXECUTABLE="${MONO_REPO_ROOT}/msvc/build/sgen/x64/bin/Release/mono-sgen.exe"; fi
42
43 if [[ ${CI_TAGS} == *'coop-gc'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-cooperative-gc=yes"; fi
44
45 if [[ ${CI_TAGS} == *'checked-coop'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-checked-build=gc,thread"; fi
46 if [[ ${CI_TAGS} == *'checked-all'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-checked-build=all"; fi
47
48 if [[ ${CI_TAGS} == *'mcs-compiler'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-csc=mcs"; fi
49 if [[ ${CI_TAGS} == *'disable-mcs-build'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --disable-mcs-build"; fi
50
51 if   [[ ${CI_TAGS} == *'fullaot_llvm'* ]];       then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-llvm=yes --with-runtime_preset=fullaot ";
52 elif [[ ${CI_TAGS} == *'hybridaot_llvm'* ]];     then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-llvm=yes --with-runtime_preset=hybridaot";
53 elif [[ ${CI_TAGS} == *'aot_llvm'* ]];           then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-llvm=yes --with-runtime_preset=aot ";
54 elif [[ ${CI_TAGS} == *'fullaot'* ]];            then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime_preset=fullaot";
55 elif [[ ${CI_TAGS} == *'hybridaot'* ]];          then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime_preset=hybridaot";
56 elif [[ ${CI_TAGS} == *'winaot'* ]];             then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime_preset=winaot";
57 elif [[ ${CI_TAGS} == *'aot'* ]];                then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime_preset=aot";
58 elif [[ ${CI_TAGS} == *'bitcode'* ]];            then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime_preset=bitcode";
59 elif [[ ${CI_TAGS} == *'interpreter'* ]];        then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-interpreter";
60 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";
61 elif [[ ${label} != w* ]] && [[ ${label} != 'debian-8-ppc64el' ]] && [[ ${label} != 'centos-s390x' ]] && [[ ${CI_TAGS} != *'monolite'* ]];
62     then
63     # only enable the concurrent collector by default on main unix archs
64     EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-sgen-default-concurrent=yes"
65
66     if [[ ${label} == 'ubuntu-1404-amd64' ]]; then
67         # only enable build of the additional profiles on one architecture to save time
68         EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime_preset=all"
69         # when building profiles like monotouch/monodroid which don't build System.Drawing.dll in the Mono repo we need
70         # to build the facades against _something_ to satisfy the typeforwards. In CI we can cheat a little and pass
71         # them System.Drawing.dll from the 'build' profile since we don't test those profiles here (we just ensure they compile).
72         export EXTERNAL_FACADE_DRAWING_REFERENCE=${MONO_REPO_ROOT}/mcs/class/lib/build/System.Drawing.dll
73     fi
74 fi
75
76 if [ -x "/usr/bin/dpkg-architecture" ];
77         then
78         EXTRA_CONF_FLAGS="$EXTRA_CONF_FLAGS --host=`/usr/bin/dpkg-architecture -qDEB_HOST_GNU_TYPE`"
79         #force build arch = dpkg arch, sometimes misdetected
80         mkdir -p ~/.config/.mono/
81         wget -qO- https://download.mono-project.com/test/new-certs.tgz| tar zx -C ~/.config/.mono/
82 fi
83
84 ${TESTCMD} --label=configure --timeout=60m --fatal ./autogen.sh $EXTRA_CONF_FLAGS
85 if [[ ${label} == 'w32' ]];
86     then
87         # only build boehm on w32 (only windows platform supporting boehm).
88     ${TESTCMD} --label=make-msvc --timeout=60m --fatal /cygdrive/c/Program\ Files\ \(x86\)/MSBuild/14.0/Bin/MSBuild.exe /p:PlatformToolset=v140 /p:Platform=${PLATFORM} /p:Configuration=Release /p:MONO_TARGET_GC=boehm msvc/mono.sln
89 fi
90 if [[ ${label} == w* ]];
91     then
92     ${TESTCMD} --label=make-msvc-sgen --timeout=60m --fatal /cygdrive/c/Program\ Files\ \(x86\)/MSBuild/14.0/Bin/MSBuild.exe /p:PlatformToolset=v140 /p:Platform=${PLATFORM} /p:Configuration=Release /p:MONO_TARGET_GC=sgen msvc/mono.sln
93 fi
94
95 if [[ ${CI_TAGS} == *'winaot'* ]];
96     then
97     # The AOT compiler on Windows requires Visual Studio's clang.exe and link.exe in $PATH
98     # and we must make sure Visual Studio's link.exe comes before Cygwin's link.exe
99     VC_ROOT="/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC"
100     export PATH="$VC_ROOT/ClangC2/bin/amd64:$VC_ROOT/bin/amd64":$PATH
101 fi
102
103 if [[ ${CI_TAGS} == *'monolite'* ]]; then make get-monolite-latest; fi
104
105 make_parallelism=-j4
106 if [[ ${label} == 'debian-8-ppc64el' ]]; then make_parallelism=-j1; fi
107
108 ${TESTCMD} --label=make --timeout=${make_timeout} --fatal make ${make_parallelism} -w V=1
109
110 if [[ ${CI_TAGS} == *'checked-coop'* ]]; then export MONO_CHECK_MODE=gc,thread; fi
111 if [[ ${CI_TAGS} == *'checked-all'* ]]; then export MONO_CHECK_MODE=all; fi
112
113 export MONO_ENV_OPTIONS="$MONO_ENV_OPTIONS $MONO_TEST_ENV_OPTIONS"
114
115 if [[ ${CI_TAGS} == *'acceptance-tests'* ]];
116     then
117         $(dirname "${BASH_SOURCE[0]}")/run-test-acceptance-tests.sh
118 elif [[ ${CI_TAGS} == *'profiler-stress-tests'* ]];
119     then
120     $(dirname "${BASH_SOURCE[0]}")/run-test-profiler-stress-tests.sh
121 elif [[ ${CI_TAGS} == *'stress-tests'* ]];
122     then
123     $(dirname "${BASH_SOURCE[0]}")/run-test-stress-tests.sh
124 elif [[ ${CI_TAGS} == *'interpreter'* ]];
125     then
126     $(dirname "${BASH_SOURCE[0]}")/run-test-interpreter.sh
127 elif [[ ${CI_TAGS} == *'mcs-compiler'* ]];
128     then
129     $(dirname "${BASH_SOURCE[0]}")/run-test-mcs.sh
130 elif [[ ${CI_TAGS} == *'no-tests'* ]];
131     then
132         exit 0
133 else
134         make check-ci
135 fi