bdecfae3efb974b15ed2b08a787f2b04716aa4ab
[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="-ggdb3 --coverage -O0"
14     # Collect coverage on all optimizations
15     export MONO_ENV_OPTIONS="$MONO_ENV_OPTIONS -O=all"
16 elif [[ ${CI_TAGS} == *'clang-sanitizer'* ]]; then
17         export CC="clang"
18         export CXX="clang++"
19         export 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 elif [[ ${label} == w* ]]; then
26     # Passing -ggdb3 on Cygwin breaks linking against libmonosgen-x.y.dll
27     export CFLAGS="-g -O2"
28 else
29     export CFLAGS="-ggdb3 -O2"
30 fi
31
32 if [[ $CI_TAGS == *'retry-flaky-tests'* ]]; then
33     export MONO_FLAKY_TEST_RETRIES=5
34 fi
35
36 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
37 if [[ ${label} == 'osx-amd64' ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-libgdiplus=/Library/Frameworks/Mono.framework/Versions/Current/lib/libgdiplus.dylib "; fi
38 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
39 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
40
41 if [[ ${CI_TAGS} == *'coop-gc'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-cooperative-gc=yes"; fi
42
43 if [[ ${CI_TAGS} == *'checked-coop'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-checked-build=gc,thread"; fi
44 if [[ ${CI_TAGS} == *'checked-all'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-checked-build=all"; fi
45
46 if [[ ${CI_TAGS} == *'mcs-compiler'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-csc=mcs"; fi
47 if [[ ${CI_TAGS} == *'disable-mcs-build'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --disable-mcs-build"; fi
48
49 if   [[ ${CI_TAGS} == *'fullaot_llvm'* ]];       then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-llvm=yes --with-runtime_preset=fullaot ";
50 elif [[ ${CI_TAGS} == *'hybridaot_llvm'* ]];     then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-llvm=yes --with-runtime_preset=hybridaot";
51 elif [[ ${CI_TAGS} == *'aot_llvm'* ]];           then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-llvm=yes --with-runtime_preset=aot ";
52 elif [[ ${CI_TAGS} == *'fullaot'* ]];            then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime_preset=fullaot";
53 elif [[ ${CI_TAGS} == *'hybridaot'* ]];          then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime_preset=hybridaot";
54 elif [[ ${CI_TAGS} == *'winaot'* ]];             then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime_preset=winaot";
55 elif [[ ${CI_TAGS} == *'aot'* ]];                then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime_preset=aot";
56 elif [[ ${CI_TAGS} == *'bitcode'* ]];            then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime_preset=bitcode";
57 elif [[ ${CI_TAGS} == *'interpreter'* ]];        then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-interpreter";
58 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";
59 elif [[ ${label} != w* ]] && [[ ${label} != 'debian-8-ppc64el' ]] && [[ ${label} != 'centos-s390x' ]] && [[ ${CI_TAGS} != *'monolite'* ]];
60     then
61     # only enable the concurrent collector by default on main unix archs
62     EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-sgen-default-concurrent=yes"
63
64     if [[ ${label} == 'ubuntu-1404-amd64' ]]; then
65         # only enable build of the additional profiles on one architecture to save time
66         EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime_preset=all"
67         # when building profiles like monotouch/monodroid which don't build System.Drawing.dll in the Mono repo we need
68         # to build the facades against _something_ to satisfy the typeforwards. In CI we can cheat a little and pass
69         # them System.Drawing.dll from the 'build' profile since we don't test those profiles here (we just ensure they compile).
70         export EXTERNAL_FACADE_DRAWING_REFERENCE=${MONO_REPO_ROOT}/mcs/class/lib/build/System.Drawing.dll
71     fi
72 fi
73
74 if [ -x "/usr/bin/dpkg-architecture" ];
75         then
76         EXTRA_CONF_FLAGS="$EXTRA_CONF_FLAGS --host=`/usr/bin/dpkg-architecture -qDEB_HOST_GNU_TYPE`"
77         #force build arch = dpkg arch, sometimes misdetected
78         mkdir -p ~/.config/.mono/
79         wget -qO- https://download.mono-project.com/test/new-certs.tgz| tar zx -C ~/.config/.mono/
80 fi
81
82 ${TESTCMD} --label=configure --timeout=60m --fatal ./autogen.sh $EXTRA_CONF_FLAGS
83 if [[ ${label} == 'w32' ]];
84     then
85         # only build boehm on w32 (only windows platform supporting boehm).
86     ${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
87 fi
88 if [[ ${label} == w* ]];
89     then
90     ${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
91 fi
92
93 if [[ ${CI_TAGS} == *'winaot'* ]];
94     then
95     # The AOT compiler on Windows requires Visual Studio's clang.exe and link.exe in $PATH
96     # and we must make sure Visual Studio's link.exe comes before Cygwin's link.exe
97     VC_ROOT="/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC"
98     export PATH="$VC_ROOT/ClangC2/bin/amd64:$VC_ROOT/bin/amd64":$PATH
99 fi
100
101 if [[ ${CI_TAGS} == *'monolite'* ]]; then make get-monolite-latest; fi
102
103 make_parallelism=-j4
104 if [[ ${label} == 'debian-8-ppc64el' ]]; then make_parallelism=-j1; fi
105
106 ${TESTCMD} --label=make --timeout=${make_timeout} --fatal make ${make_parallelism} -w V=1
107
108 if [[ ${CI_TAGS} == *'checked-coop'* ]]; then export MONO_CHECK_MODE=gc,thread; fi
109 if [[ ${CI_TAGS} == *'checked-all'* ]]; then export MONO_CHECK_MODE=all; fi
110
111 if [[ ${CI_TAGS} == *'acceptance-tests'* ]];
112     then
113         $(dirname "${BASH_SOURCE[0]}")/run-test-acceptance-tests.sh
114 elif [[ ${CI_TAGS} == *'profiler-stress-tests'* ]];
115     then
116     $(dirname "${BASH_SOURCE[0]}")/run-test-profiler-stress-tests.sh
117 elif [[ ${CI_TAGS} == *'stress-tests'* ]];
118     then
119     $(dirname "${BASH_SOURCE[0]}")/run-test-stress-tests.sh
120 elif [[ ${CI_TAGS} == *'interpreter'* ]];
121     then
122     $(dirname "${BASH_SOURCE[0]}")/run-test-interpreter.sh
123 elif [[ ${CI_TAGS} == *'mcs-compiler'* ]];
124     then
125     $(dirname "${BASH_SOURCE[0]}")/run-test-mcs.sh
126 elif [[ ${CI_TAGS} == *'no-tests'* ]];
127     then
128         exit 0
129 else
130         make check-ci
131 fi