From 0b9bb84c39a25b0361d8fe30eddf47c8c4c441d4 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 15 Jul 2020 13:05:08 +0200 Subject: [PATCH] Run tests in parallel. --- .circleci/config.yml | 1 + .circleci/soltest_all.sh | 47 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 826c04785..df0eba03d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -139,6 +139,7 @@ defaults: - test_ubuntu2004: &test_ubuntu2004 docker: - image: ethereum/solidity-buildpack-deps:ubuntu2004-<< pipeline.parameters.ubuntu-2004-docker-image-rev >> + parallelism: 6 steps: - checkout - attach_workspace: diff --git a/.circleci/soltest_all.sh b/.circleci/soltest_all.sh index 86f172a04..7b1fb053b 100755 --- a/.circleci/soltest_all.sh +++ b/.circleci/soltest_all.sh @@ -28,10 +28,49 @@ set -e REPODIR="$(realpath $(dirname $0)/..)" -EVM=istanbul OPTIMIZE=1 ABI_ENCODER_V2=1 ${REPODIR}/.circleci/soltest.sh +EVM_VALUES=(homestead byzantium constantinople petersburg istanbul) +OPTIMIZE_VALUES=(0 1) +STEPS=$(( 1 + ${#EVM_VALUES[@]} * ${#OPTIMIZE_VALUES[@]} )) -for OPTIMIZE in 0 1; do - for EVM in homestead byzantium constantinople petersburg istanbul; do - EVM=$EVM OPTIMIZE=$OPTIMIZE BOOST_TEST_ARGS="-t !@nooptions" ${REPODIR}/.circleci/soltest.sh +if (( $CIRCLE_NODE_TOTAL )) && (( $CIRCLE_NODE_TOTAL > 1 )) +then + # Run step 1 as the only step on the first executor + # and evenly distribute the other steps among + # the other executors. + # The first step takes much longer than the other steps. + if (( $CIRCLE_NODE_INDEX == 0 )) + then + RUN_STEPS="1" + else + export CIRCLE_NODE_INDEX=$(($CIRCLE_NODE_INDEX - 1)) + export CIRCLE_NODE_TOTAL=$(($CIRCLE_NODE_TOTAL - 1)) + RUN_STEPS=$(seq 2 "$STEPS" | circleci tests split) + fi +else + RUN_STEPS=$(seq "$STEPS") +fi + +# turn newlines into spaces +RUN_STEPS=$(echo $RUN_STEPS) + +echo "Running steps $RUN_STEPS..." + +STEP=1 + +[[ " $RUN_STEPS " =~ " $STEP " ]] && EVM=istanbul OPTIMIZE=1 ABI_ENCODER_V2=1 "${REPODIR}/.circleci/soltest.sh" +STEP=$(($STEP + 1)) + +for OPTIMIZE in ${OPTIMIZE_VALUES[@]} +do + for EVM in ${EVM_VALUES[@]} + do + [[ " $RUN_STEPS " =~ " $STEP " ]] && EVM="$EVM" OPTIMIZE="$OPTIMIZE" BOOST_TEST_ARGS="-t !@nooptions" "${REPODIR}/.circleci/soltest.sh" + STEP=$(($STEP + 1)) done done + +if (($STEP != $STEPS + 1)) +then + echo "Step counter not properly adjusted!" >2 + exit 1 +fi