Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/scripts/github-actions/check-bazel-targets.sh
2867 views
1
#!/usr/bin/env bash
2
# Print commands
3
# set -x
4
# Extracted from https://github.com/bazelbuild/bazel/blob/master/scripts/ci/ci.sh
5
6
COMMIT_RANGE=${COMMIT_RANGE:-"HEAD^..HEAD"}
7
8
echo "${COMMIT_RANGE}"
9
10
# Go to the root of the repo
11
cd "$(git rev-parse --show-toplevel)" || true
12
13
# Get list of affected files by the diff
14
affected_files=$(git diff --name-only "${COMMIT_RANGE}")
15
16
# Get a list of the current targets in package form by querying Bazel.
17
bazel_targets=()
18
for bazel_target in $affected_files ; do
19
bazel_targets+=($(bazel query "$bazel_target"))
20
done
21
22
if (( ${#bazel_targets[@]} == 0 )); then
23
echo "No bazel targets found after checking the diff."
24
exit 0
25
fi
26
27
# Now check if we need to run some tests based on this change
28
# E.g. A change in Grid needs to trigger remote tests in other bindings
29
echo "Checking test targets..."
30
bazel_targets+=($(bazel query \
31
--keep_going \
32
--noshow_progress \
33
"kind(test, rdeps(//..., set(${bazel_targets[*]})))"))
34
35
echo "bazel-targets='${bazel_targets[*]}'" | tee -a "$GITHUB_OUTPUT"
36
37