forked from Tinder/bazel-diff
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbazel-diff-example.sh
More file actions
executable file
·52 lines (40 loc) · 2.12 KB
/
Copy pathbazel-diff-example.sh
File metadata and controls
executable file
·52 lines (40 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# Path to your Bazel WORKSPACE directory
workspace_path=$1
# Path to your Bazel executable
bazel_path=$2
# Starting Revision SHA
previous_revision=$3
# Final Revision SHA
final_revision=$4
modified_filepaths_output="/tmp/modified_filepaths.txt"
starting_hashes_json="/tmp/starting_hashes.json"
final_hashes_json="/tmp/final_hashes.json"
impacted_targets_path="/tmp/impacted_targets.txt"
impacted_test_targets_path="/tmp/impacted_test_targets.txt"
$bazel_path run :bazel-diff -- modified-filepaths $previous_revision $final_revision -w $workspace_path -b $bazel_path $modified_filepaths_output
IFS=$'\n' read -d '' -r -a modified_filepaths < $modified_filepaths_output
formatted_filepaths=$(IFS=$'\n'; echo "${modified_filepaths[*]}")
echo "Modified Filepaths:"
echo $formatted_filepaths
echo ""
git -C $workspace_path checkout $previous_revision --quiet
echo "Generating Hashes for Revision '$previous_revision'"
$bazel_path run :bazel-diff -- generate-hashes -w $workspace_path -b $bazel_path $starting_hashes_json
git -C $workspace_path checkout - --quiet
echo "Generating Hashes for Revision '$final_revision'"
$bazel_path run :bazel-diff -- generate-hashes -w $workspace_path -b $bazel_path -m $modified_filepaths_output $final_hashes_json
echo "Determining Impacted Targets"
$bazel_path run :bazel-diff -- -sh $starting_hashes_json -fh $final_hashes_json -w $workspace_path -b $bazel_path -o $impacted_targets_path
echo "Determining Impacted Test Targets"
$bazel_path run :bazel-diff -- -sh $starting_hashes_json -fh $final_hashes_json -w $workspace_path -b $bazel_path -o $impacted_test_targets_path -t
IFS=$'\n' read -d '' -r -a impacted_targets < $impacted_targets_path
formatted_impacted_targets=$(IFS=$'\n'; echo "${impacted_targets[*]}")
echo "Impacted Targets between $previous_revision and $final_revision:"
echo $formatted_impacted_targets
echo ""
IFS=$'\n' read -d '' -r -a impacted_test_targets < $impacted_test_targets_path
formatted_impacted_test_targets=$(IFS=$'\n'; echo "${impacted_test_targets[*]}")
echo "Impacted Test Targets between $previous_revision and $final_revision:"
echo $formatted_impacted_test_targets
echo ""