Path: blob/trunk/scripts/github-actions/check-bazel-targets.sh
2867 views
#!/usr/bin/env bash1# Print commands2# set -x3# Extracted from https://github.com/bazelbuild/bazel/blob/master/scripts/ci/ci.sh45COMMIT_RANGE=${COMMIT_RANGE:-"HEAD^..HEAD"}67echo "${COMMIT_RANGE}"89# Go to the root of the repo10cd "$(git rev-parse --show-toplevel)" || true1112# Get list of affected files by the diff13affected_files=$(git diff --name-only "${COMMIT_RANGE}")1415# Get a list of the current targets in package form by querying Bazel.16bazel_targets=()17for bazel_target in $affected_files ; do18bazel_targets+=($(bazel query "$bazel_target"))19done2021if (( ${#bazel_targets[@]} == 0 )); then22echo "No bazel targets found after checking the diff."23exit 024fi2526# Now check if we need to run some tests based on this change27# E.g. A change in Grid needs to trigger remote tests in other bindings28echo "Checking test targets..."29bazel_targets+=($(bazel query \30--keep_going \31--noshow_progress \32"kind(test, rdeps(//..., set(${bazel_targets[*]})))"))3334echo "bazel-targets='${bazel_targets[*]}'" | tee -a "$GITHUB_OUTPUT"353637