- job: name: tcwg-buildfarm-startcontainer project-type: matrix defaults: global properties: - authorization: anonymous: - job-read - job-extended-read linaro: - job-build - job-cancel - build-discarder: days-to-keep: 30 num-to-keep: 100 parameters: - string: name: override default: '' description: 'Versions of components to build; e.g. binutils=binutils-gdb.git/linaro_binutils-2_25-branch gcc=gcc.git~linaro/gcc-5-branch glibc=glibc.git~release/2.21/master' - string: name: host_x86_64_languages default: 'default' description: 'Languages to build for x86_64-hosted toolchains, e.g., "c,c++" or "all" or "default"' - string: name: host_aarchXX_languages default: 'c,c++' description: 'Languages to build for AArchXX-hosted toolchains, e.g., "c,c++" or "all" or "default"' - string: name: runtests default: 'x86_64-host' description: 'Run toolchain testsuites: "yes", "no", "x86_64-host"' - bool: name: try_bootstrap default: 'true' description: 'Attempt to bootstrap GCC for compatible host and target combinations' - string: name: host_x86_64_excludecheck default: 'gdb' description: 'Do not run "make check" on these components on x86_64' - string: name: host_aarchXX_excludecheck default: 'gcc' description: 'Do not run "make check" on these components on AArchXX' - string: name: extraconfig default: '' description: 'Extra configuration files, syntax tool=path' - bool: name: rebuild default: true description: 'Rebuild the toolchain even if results are already on logserver' - string: name: log_name default: '${JOB_NAME}-${BUILD_NUMBER}/${builder_type}.$target' description: 'Logname directory on logserver' - bool: name: dont_fail default: false description: 'Do not fail the build' - string: name: log_server default: dev-01.tcwglab:/home/tcwg-buildslave/logs description: 'Log_Server' - string: name: targets default: 'cross_main cross_aux native_x86' description: 'Which target toolchains to build: cross_main cross_aux native_x86 native_aarch32 native_aarch64' - string: name: abe_branch default: refs/remotes/origin/stable description: 'ABE revision to test' - string: name: scripts_branch default: master description: 'Scripts branch to use' - string: name: build_container_type default: 'default' description: 'Type of container to use on the builder: docker, schroot, none, default. "default" means the script choose depending on the builder type' - string: name: build_container_distro default: 'trusty' description: 'Distro to use on the builder with non-default container type: trusty, xenial.' disabled: false node: tcwg-x86_64-build child-workspace: $target concurrent: true display-name: 'TCWG ZZZ BuildFarm Start container' scm: - git: url: https://git-us.linaro.org/toolchain/abe.git refspec: +refs/changes/*:refs/remotes/changes/* branches: - $abe_branch skip-tag: true shallow-clone: true wipe-workspace: true axes: - axis: type: slave name: label values: - tcwg-x86_64-build - tcwg-x86_32-build - tcwg-tx1_64-build - tcwg-tx1_32-build - tcwg-tk1_32-build - tcwg-apm_64-build - tcwg-apm_32-build - axis: type: user-defined name: target values: - aarch64-linux-gnu - armv8l-linux-gnueabihf - arm-linux-gnueabi - arm-linux-gnueabihf - armeb-linux-gnueabihf - aarch64-none-elf - aarch64_be-none-elf - native execution-strategy: combination-filter: | label=="tcwg-x86_64-build" || target=="native" sequential: false wrappers: - timeout: timeout: 600 - timestamps - build-name: name: '#${BUILD_NUMBER}' builders: - shell: | #!/bin/bash set -ex mkdir -p artifacts/ git clone -b $scripts_branch --depth 1 https://git-us.linaro.org/toolchain/jenkins-scripts case ${label} in tcwg-x86_64-build) builder_arch=amd64 builder_type=x86_64 ;; tcwg-x86_32-build) builder_arch=i386 builder_type=i686 ;; tcwg-tx1_64-build) builder_arch=arm64 builder_type=aarch64 ;; tcwg-tx1_32-build) builder_arch=armhf builder_type=armv8 ;; tcwg-tk1_32-build) builder_arch=armhf builder_type=armv7 ;; tcwg-apm_64-build) builder_arch=arm64 builder_type=aarch64-apm ;; tcwg-apm_32-build) builder_arch=armhf builder_type=armv8-apm ;; *) echo "ERROR: Unsupported slave: $slave"; exit 1 ;; esac case "$target--${builder_arch}" in native--arm64) target_kind=native_aarch64 ;; native--armhf) target_kind=native_aarch32 ;; native--amd64|native--i386) target_kind=native_x86 ;; armeb-linux-gnueabihf--*|*-none-elf--*) target_kind=cross_aux ;; *-linux-gnu*--*) target_kind=cross_main ;; *) echo "ERROR: Cannot handle target: $target"; exit 1 ;; esac if ! echo "$targets" | grep -q "$target_kind"; then echo "NOTE: Skipping target $target because $target_kind is not in list: $targets" # Create at least an (empty) artifact so that Jenkins does not complain echo > artifacts/target-skipped.txt exit 0 fi # Select container type. If the user chose a non-default # value, then use it whatever the builder type if [ "x${build_container_type}" = "xdefault" ]; then case ${builder_arch} in amd64|i386|arm64|armhf) build_container_type=docker build_container_distro=trusty ;; *) echo "ERROR: Unsupported builder_arch: ${builder_arch}"; exit 1 ;; esac fi # Start build container builder=$(./jenkins-scripts/nodename2hostname.sh $NODE_NAME) bash -x ./jenkins-scripts/start-container-${build_container_type}.sh --arch ${builder_arch} --distro ${build_container_distro} --session-host ${builder} > build-container.sh # Define CONTAINER, CONTAINER_CLEANUP, session_host and session_port . ./build-container.sh BUILD_CONTAINER="${CONTAINER}" BUILD_CONTAINER_CLEANUP="${CONTAINER_CLEANUP}" # Make sure to cleanup build container if something goes # wrong when preparing the test environment if [ x"${BUILD_CONTAINER_CLEANUP}" != x ]; then CONTAINERS_CLEANUP="${BUILD_CONTAINER_CLEANUP}" if [ x"${SSH_AGENT_CLEANUP}" = x ]; then trap "${CONTAINERS_CLEANUP}" EXIT else trap "${CONTAINERS_CLEANUP} ; eval \`${SSH_AGENT_CLEANUP}\`" EXIT fi fi case "${target_kind}-$runtests-${builder_arch}" in "cross_main"-"yes"-*|"cross_main"-"x86_64-host"-"amd64"|"cross_main"-"x86_64-host"-"i386") case "$target" in aarch64*) test_container_arch=arm64 ;; armv8*) test_container_arch=armv8hf ;; arm*) test_container_arch=armhf ;; *) echo "ERROR: Wrong target $target"; exit 1 ;; esac if echo "$override" | grep -q -e "--extraconfigdir ../config/gcc5" \ || true \ && [ x"$target" = x"aarch64-linux-gnu" ]; then # Sanitizers in GCC-5 and GCC-6 toolchains for # aarch64-linux-gnu don't support 48-bit VA. # Therefore don't run them on Xenial tester: do # not start a docker container here, and use abe's # legacy schroot support on older tester boards # (tcwg-aarch64-test-0[12]) : else # AArch32 and AArch64 test boards are currently: # tcwg-tk1-0[34]: AArch32 (armv7) # tcwg-tx1-0[34]: AArch32 (armv8) and AArch64 case ${test_container_arch} in armhf) tester_labels="tcwg-tk1_32-test" ;; armv8hf) tester_labels="tcwg-tx1_32-test" test_container_arch=armhf ;; arm64) tester_labels="tcwg-tx1_64-test" ;; esac testers=$( for label in $tester_labels; do wget -O - https://ci.linaro.org/label/$label/api/json?pretty=true 2>/dev/null | grep nodeName | cut -d: -f 2 | sed -e 's/"//g' -e "s/\$/.tcwglab/" done) tester_min_load_name="" tester_min_load_value="999" for tester in $testers; do load_value=$(docker -H $tester:2375 ps | wc -l) if [ $load_value -lt $tester_min_load_value ]; then tester_min_load_name=$tester tester_min_load_value=$load_value fi done if [ x"$tester_min_load_name" = x"" ]; then echo "ERROR: Cannot find tester for $test_container_arch" exit 1 fi tester=$tester_min_load_name # For the moment, support only docker containers on the tester machine bash -x ./jenkins-scripts/start-container-docker.sh --arch ${test_container_arch} --distro trusty --session-host ${tester} --task test > test-container.sh fi ;; esac TEST_CONTAINER= TEST_CONTAINER_CLEANUP= test_session_host= test_session_port= # If we use a remote tester machine, tell jenkins.sh how # to override abe's default if [ -f test-container.sh ]; then . ./test-container.sh TEST_CONTAINER="${CONTAINER}" TEST_CONTAINER_CLEANUP="${CONTAINER_CLEANUP}" test_session_host=${session_host} test_session_port=${session_port} echo "${test_session_host}:${test_session_port}" | tee $WORKSPACE/test-container.data if [ x"${CONTAINERS_CLEANUP}" != x ]; then CONTAINERS_CLEANUP="${CONTAINERS_CLEANUP} ; ${TEST_CONTAINER_CLEANUP}" else CONTAINERS_CLEANUP="${TEST_CONTAINER_CLEANUP}" fi if [ x"${SSH_AGENT_CLEANUP}" = x ]; then trap "${CONTAINERS_CLEANUP}" EXIT else trap "${CONTAINERS_CLEANUP} ; eval \`${SSH_AGENT_CLEANUP}\`" EXIT fi runtests_opt="--runtests --testcontainerfile $WORKSPACE/test-container.data" else case "$target_kind-$runtests-${builder_arch}" in *-"yes"-*|*-"x86_64-host"-"amd64"|*-"x86_64-host"-"i386") runtests_opt="--runtests" ;; *) runtests_opt="" ;; esac fi ${BUILD_CONTAINER} 'echo "Build session is up; ulimit config:"; ulimit -a' case ${builder_arch} in amd64|i386) languages="$host_x86_64_languages" ;; *) languages="$host_aarchXX_languages" ;; esac if $try_bootstrap; then bootstrap="--bootstrap" else bootstrap="" fi if [ x"$log_name" != x"" ]; then eval "logname_opt=\"--logname $log_name\"" fi if $rebuild; then norebuild="" else norebuild="--norebuild" fi case ${builder_arch} in amd64|i386) excludecheck="$host_x86_64_excludecheck" ;; *) excludecheck="$host_aarchXX_excludecheck" ;; esac excludecheck_opt="" for testsuite in $excludecheck; do excludecheck_opt="$excludecheck_opt --excludecheck $testsuite" done # If there were extraconfig options, extract the # corresponding repo if test -n "$extraconfig" ; then git clone http://git.linaro.org/toolchain/abe-extraconfigs.git fi extraconfig_opt="" for config in $extraconfig; do case ${extraconfig} in *=*) tool=${extraconfig%=*} value=${extraconfig#*=} ;; *) echo ERROR: wrong extraconfig: $extraconfig exit 1 ;; esac extraconfig_opt="${extraconfig_opt} --extraconfig $tool=$PWD/abe-extraconfigs/$value" done result="0" ${BUILD_CONTAINER} "cd ${WORKSPACE} && bash -x ${WORKSPACE}/jenkins-scripts/jenkins.sh --workspace ${WORKSPACE} --abedir ${WORKSPACE} --target ${target} --override \"$override\" --languages ${languages} $bootstrap $runtests_opt $excludecheck_opt ${extraconfig_opt} --logserver $log_server $logname_opt $norebuild" || result=$? # If we actually built a toolchain, save its manifest. # If the build was a no-op (results already present on log_server), # copy the existing ones. if [ -d _build/builds ]; then manifest="`find _build/builds/ -name destdir -prune -o -name \*manifest.txt -print`" else manifest="" fi if [ x"${manifest}" != x ]; then cp ${manifest} artifacts/ else # We need to do the same name expansion as jenkins.sh eval dir="$log_name" scp "$log_server/$dir/*manifest.txt" artifacts/ fi # Save logs and their directory structure rsync -a --exclude="/logs/" --include="*/" --include="*.log" --include="*.err" --include="*.out" --include="*.txt" --exclude="*" --prune-empty-dirs ./ ./logs/ if ! tar -I pxz -cf ./artifacts/logs.tar.xz ./logs/ >/dev/null 2>&1; then # PXZ can [rarely] fail due to high RAM usage, so fallback to normal XZ. rm -f ./artifacts/logs.tar.xz tar -cJf ./artifacts/logs.tar.xz ./logs/ fi echo "Result of jenkins.sh: $result" if $dont_fail; then result="0" fi exit $result publishers: - archive: artifacts: 'artifacts/*' latest-only: false