run_bazel_test_with_sharding.sh 732 B

123456789101112131415161718192021222324252627
  1. #!/bin/bash
  2. # shellcheck disable=SC2046
  3. # Shard bazel tests and then run bazel test
  4. # Passes arguments through
  5. set -x
  6. test_tag_filters=""
  7. optional_args=()
  8. targets=()
  9. for arg in "$@"; do
  10. shift
  11. if [[ "${arg:0:19}" == "--test_tag_filters=" ]]
  12. then
  13. test_tag_filters="${arg:19}"
  14. elif [[ "${arg:0:1}" == "-" ]]
  15. then
  16. optional_args+=("$arg")
  17. else
  18. targets+=("$arg")
  19. fi
  20. done
  21. SHARD=$(python ./ci/run/bazel_sharding/bazel_sharding.py --exclude_manual --index "${BUILDKITE_PARALLEL_JOB}" --count "${BUILDKITE_PARALLEL_JOB_COUNT}" --tag_filters="$test_tag_filters" "${targets[@]}")
  22. echo "$SHARD"
  23. echo "$SHARD" | xargs bazel test --test_tag_filters="$test_tag_filters" "${optional_args[@]}"