fix runner count logic in set_test_package_matrix.sh from adding an additional runner (#19620)

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

* use ceil instead of floor
This commit is contained in:
John Murret 2023-11-14 09:21:02 -07:00 committed by GitHub
parent bcf6f627b9
commit 2ff6ab19ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -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}"