always run agent tests alone on their own runner (#20199)

* always run agent tests alone on their own runner

* deal with runner count = 1

* prevent runners less than 2
This commit is contained in:
John Murret 2024-01-12 13:40:31 -07:00 committed by GitHub
parent 80ed31acac
commit d4b67677c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -5,13 +5,15 @@
set -euo pipefail
export RUNNER_COUNT=$1
if ((RUNNER_COUNT < 1 ))
if ((RUNNER_COUNT < 2 ))
then
echo ERROR: RUNNER_COUNT must be greater than zero.
echo ERROR: RUNNER_COUNT must be greater than 1. Otherwise use the non-split unit test cod in .github/workflows/reusable-unit.yml.
exit 1 # terminate and indicate error
else
EFFECTIVE_RUNNER_COUNT=$((RUNNER_COUNT-1))
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 | ceil)]'))"
matrix="$(go list -json="ImportPath,TestGoFiles" ./... | jq --compact-output '. | select(.TestGoFiles != null) | select(.ImportPath != "github.com/hashicorp/consul/agent") | .ImportPath' | shuf | jq --slurp --compact-output '.' | jq --argjson runnercount $EFFECTIVE_RUNNER_COUNT -cM '[_nwise(length / $runnercount | ceil)]' | jq --compact-output '. += [["github.com/hashicorp/consul/agent"]]'))"
echo "matrix=${matrix}" >> "${GITHUB_OUTPUT}"