|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +workspace_path="$PWD/integration" |
| 4 | +bazel_path=$(which bazelisk) |
| 5 | + |
| 6 | +previous_revision="HEAD^" |
| 7 | +final_revision="HEAD" |
| 8 | +modified_filepaths_output="$PWD/integration/modified_filepaths.txt" |
| 9 | +starting_hashes_json="/tmp/starting_hashes.json" |
| 10 | +final_hashes_json="/tmp/final_hashes_json.json" |
| 11 | +impacted_targets_path="/tmp/impacted_targets.txt" |
| 12 | +impacted_test_targets_path="/tmp/impacted_test_targets.txt" |
| 13 | + |
| 14 | +export USE_BAZEL_VERSION=last_rc |
| 15 | + |
| 16 | +containsElement () { |
| 17 | + local e match="$1" |
| 18 | + shift |
| 19 | + for e; do [[ "$e" == "$match" ]] && return 0; done |
| 20 | + return 1 |
| 21 | +} |
| 22 | + |
| 23 | +$bazel_path run :bazel-diff -- generate-hashes -w $workspace_path -b $bazel_path $starting_hashes_json |
| 24 | + |
| 25 | +$bazel_path run :bazel-diff -- generate-hashes -w $workspace_path -b $bazel_path -m $modified_filepaths_output $final_hashes_json |
| 26 | + |
| 27 | +ruby ./integration/update_final_hashes.rb |
| 28 | + |
| 29 | +$bazel_path run :bazel-diff -- -sh $starting_hashes_json -fh $final_hashes_json -w $workspace_path -b $bazel_path -o $impacted_targets_path |
| 30 | + |
| 31 | +$bazel_path run :bazel-diff -- impacted-tests -w $workspace_path -b $bazel_path $impacted_targets_path $impacted_test_targets_path |
| 32 | + |
| 33 | +IFS=$'\n' read -d '' -r -a impacted_targets < $impacted_targets_path |
| 34 | +target="//src/main/java/com/integration:StringGenerator.java" |
| 35 | +if containsElement $target "${impacted_targets[@]}"; |
| 36 | +then |
| 37 | + echo "Correct first impacted target" |
| 38 | +else |
| 39 | + echo "Impacted Targets: ${impacted_targets[@]}" |
| 40 | + echo "Incorrect first impacted target: ${target}" |
| 41 | + exit 1 |
| 42 | +fi |
| 43 | + |
| 44 | +IFS=$'\n' read -d '' -r -a impacted_test_targets < $impacted_test_targets_path |
| 45 | +target="//test/java/com/integration:bazel-diff-integration-tests" |
| 46 | +if containsElement $target "${impacted_test_targets[@]}"; |
| 47 | +then |
| 48 | + echo "Correct first impacted test target" |
| 49 | +else |
| 50 | + echo "Impacted test targets: ${impacted_test_targets[@]}" |
| 51 | + echo "Incorrect first impacted test target: ${target}" |
| 52 | + exit 1 |
| 53 | +fi |
0 commit comments