Skip to content

Commit fbc48e3

Browse files
committed
Extract helpers for managing steps in parallelized CircleCI jobs from soltest_all.sh
1 parent 79af83e commit fbc48e3

File tree

2 files changed

+46
-17
lines changed

2 files changed

+46
-17
lines changed

.circleci/soltest_all.sh

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,31 @@ set -e
2828

2929
REPODIR="$(realpath "$(dirname "$0")"/..)"
3030

31+
# shellcheck source=scripts/common.sh
32+
source "${REPODIR}/scripts/common.sh"
33+
3134
EVM_VALUES=(homestead byzantium constantinople petersburg istanbul berlin london)
3235
DEFAULT_EVM=london
3336
[[ " ${EVM_VALUES[*]} " =~ $DEFAULT_EVM ]]
3437
OPTIMIZE_VALUES=(0 1)
3538
STEPS=$(( 1 + ${#EVM_VALUES[@]} * ${#OPTIMIZE_VALUES[@]} ))
3639

37-
if (( CIRCLE_NODE_TOTAL )) && (( CIRCLE_NODE_TOTAL > 1 ))
38-
then
39-
RUN_STEPS=$(seq "$STEPS" | circleci tests split | xargs)
40-
else
41-
RUN_STEPS=$(seq "$STEPS" | xargs)
42-
fi
43-
44-
echo "Running steps $RUN_STEPS..."
40+
RUN_STEPS=$(circleci_select_steps "$(seq "$STEPS")")
41+
printTask "Running steps $RUN_STEPS..."
4542

4643
STEP=1
4744

4845

4946
# Run for ABI encoder v1, without SMTChecker tests.
50-
[[ " $RUN_STEPS " == *" $STEP "* ]] && EVM="${DEFAULT_EVM}" OPTIMIZE=1 ABI_ENCODER_V1=1 BOOST_TEST_ARGS="-t !smtCheckerTests" "${REPODIR}/.circleci/soltest.sh"
51-
STEP=$((STEP + 1))
47+
if circleci_step_selected "$RUN_STEPS" "$STEP"
48+
then
49+
EVM="${DEFAULT_EVM}" \
50+
OPTIMIZE=1 \
51+
ABI_ENCODER_V1=1 \
52+
BOOST_TEST_ARGS="-t !smtCheckerTests" \
53+
"${REPODIR}/.circleci/soltest.sh"
54+
fi
55+
((++STEP))
5256

5357
for OPTIMIZE in "${OPTIMIZE_VALUES[@]}"
5458
do
@@ -63,13 +67,16 @@ do
6367
DISABLE_SMTCHECKER=""
6468
[ "${OPTIMIZE}" != "0" ] && DISABLE_SMTCHECKER="-t !smtCheckerTests"
6569

66-
[[ " $RUN_STEPS " == *" $STEP "* ]] && EVM="$EVM" OPTIMIZE="$OPTIMIZE" SOLTEST_FLAGS="$SOLTEST_FLAGS $ENFORCE_GAS_ARGS $EWASM_ARGS" BOOST_TEST_ARGS="-t !@nooptions $DISABLE_SMTCHECKER" "${REPODIR}/.circleci/soltest.sh"
67-
STEP=$((STEP + 1))
70+
if circleci_step_selected "$RUN_STEPS" "$STEP"
71+
then
72+
EVM="$EVM" \
73+
OPTIMIZE="$OPTIMIZE" \
74+
SOLTEST_FLAGS="$SOLTEST_FLAGS $ENFORCE_GAS_ARGS $EWASM_ARGS" \
75+
BOOST_TEST_ARGS="-t !@nooptions $DISABLE_SMTCHECKER" \
76+
"${REPODIR}/.circleci/soltest.sh"
77+
fi
78+
((++STEP))
6879
done
6980
done
7081

71-
if ((STEP != STEPS + 1))
72-
then
73-
echo "Step counter not properly adjusted!" >&2
74-
exit 1
75-
fi
82+
((STEP == STEPS + 1)) || assertFail "Step counter not properly adjusted!"

scripts/common.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,25 @@ function safe_kill
196196
kill -9 "$PID"
197197
fi
198198
}
199+
200+
function circleci_select_steps
201+
{
202+
local all_steps="$1"
203+
(( $# == 1 )) || assertFail
204+
205+
if (( CIRCLE_NODE_TOTAL )) && (( CIRCLE_NODE_TOTAL > 1 ))
206+
then
207+
echo "$all_steps" | circleci tests split | xargs
208+
else
209+
echo "$all_steps" | xargs
210+
fi
211+
}
212+
213+
function circleci_step_selected
214+
{
215+
local selected_steps="$1"
216+
local step="$2"
217+
[[ $step != *" "* ]] || assertFail "Step names must not contain spaces."
218+
219+
[[ " $selected_steps " == *" $step "* ]] || return 1
220+
}

0 commit comments

Comments
 (0)