2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2017 The Linux Foundation and others.
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 echo "---> tox-run.sh"
13 # Ensure we fail the job if any steps fail.
14 # DO NOT set -u as virtualenv's activate script has unbound variables
17 ARCHIVE_TOX_DIR="$WORKSPACE/archives/tox"
18 mkdir -p "$ARCHIVE_TOX_DIR"
20 cd "$WORKSPACE/$TOX_DIR"
22 if [ -z "$TOX_ENVS" ]; then
23 TOX_ENVS=$(crudini --get tox.ini tox envlist)
30 # Sleep a random 10 second interval to workaround tox sdist
31 # conflicts due to building in the same dist directory.
32 sleep $[ ( $RANDOM % 10 ) + 1 ]s
34 echo "-----> Running tox $env"
35 if ! tox -e $env > "$log_dir/tox-$env.log"; then
36 echo "$env" >> "$log_dir/failed-envs.log"
40 TOX_ENVS=(${TOX_ENVS//,/ })
41 if hash parallel 2>/dev/null; then
43 parallel --jobs 200% "run_tox $ARCHIVE_TOX_DIR {}" ::: ${TOX_ENVS[*]}
45 for env in "${TOX_ENVS[@]}"; do
46 run_tox "$ARCHIVE_TOX_DIR" "$env"
50 if [ -f "$ARCHIVE_TOX_DIR/failed-envs.log" ]; then
51 failed_envs=($(cat "$ARCHIVE_TOX_DIR/failed-envs.log"))
52 for e in "${failed_envs[@]}"; do
53 echo "cat $ARCHIVE_TOX_DIR/tox-$e.log"
54 cat "$ARCHIVE_TOX_DIR/tox-$e.log"
56 echo "ERROR: Failed the following builds: ${failed_envs[*]}"
60 echo "Completed tox runs."