Skip to content

Commit

Permalink
fix runner count logic in set_test_package_matrix.sh from adding an a…
Browse files Browse the repository at this point in the history
…dditional runner (#19620)

* fix runner count logic in set_test_package_matrix.sh from adding an additional runner

* use ceil instead of floor
  • Loading branch information
jmurret authored Nov 14, 2023
1 parent bcf6f62 commit 2ff6ab1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion .github/scripts/set_test_package_matrix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
set -euo pipefail
export RUNNER_COUNT=$1

if ((RUNNER_COUNT < 1 ))
then
echo ERROR: RUNNER_COUNT must be greater than zero.
exit 1 # terminate and indicate error
fi

# set matrix var to list of unique packages containing tests
matrix="$(go list -json="ImportPath,TestGoFiles" ./... | jq --compact-output '. | select(.TestGoFiles != null) | .ImportPath' | shuf | jq --slurp --compact-output '.' | jq --argjson runnercount $RUNNER_COUNT -cM '[_nwise(length / $runnercount | floor)]'))"
matrix="$(go list -json="ImportPath,TestGoFiles" ./... | jq --compact-output '. | select(.TestGoFiles != null) | .ImportPath' | shuf | jq --slurp --compact-output '.' | jq --argjson runnercount $RUNNER_COUNT -cM '[_nwise(length / $runnercount | ceil)]'))"

echo "matrix=${matrix}" >> "${GITHUB_OUTPUT}"

0 comments on commit 2ff6ab1

Please sign in to comment.