-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Additional Verbose Logging (#21)
Additional verbose logging when computing impacted targets. - bazel version - bazel-diff version - verbose bazel-diff logging
- Loading branch information
1 parent
db398cb
commit 42a6391
Showing
1 changed file
with
13 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,14 @@ logIfVerbose() { | |
ifVerbose echo "$(date -u)" "$@" | ||
} | ||
|
||
bazelDiff() { | ||
if [[ -n ${VERBOSE} ]]; then | ||
java -jar bazel-diff.jar "$@" --verbose | ||
else | ||
java -jar bazel-diff.jar "$@" | ||
fi | ||
} | ||
|
||
# NOTE: We cannot assume that the checked out Git repo (e.g. via actions-checkout) | ||
# was a shallow vs a complete clone. The `--depth` options deepens the commit history | ||
# in both clone modes: https://git-scm.com/docs/fetch-options#Documentation/fetch-options.txt---depthltdepthgt | ||
|
@@ -37,6 +45,8 @@ fetchRemoteGitHistory "${PR_BRANCH}" | |
|
||
# Install the bazel-diff JAR. Avoid cloning the repo, as there will be conflicting WORKSPACES. | ||
curl --retry 5 -Lo bazel-diff.jar https://github.com/Tinder/bazel-diff/releases/latest/download/bazel-diff_deploy.jar | ||
java -jar bazel-diff.jar -V | ||
bazel --version | ||
|
||
git switch "${MERGE_INSTANCE_BRANCH}" | ||
merge_instance_branch_head_sha=$(git rev-parse "${MERGE_INSTANCE_BRANCH}") | ||
|
@@ -71,14 +81,14 @@ impacted_targets_out=./impacted_targets_${pr_branch_head_sha} | |
|
||
# Generate Hashes for the Merge Instance Branch | ||
git switch "${MERGE_INSTANCE_BRANCH}" | ||
java -jar bazel-diff.jar generate-hashes --workspacePath="${WORKSPACE_PATH}" "${merge_instance_branch_out}" | ||
bazelDiff generate-hashes --workspacePath="${WORKSPACE_PATH}" "${merge_instance_branch_out}" | ||
|
||
# Generate Hashes for the Merge Instance Branch + PR Branch | ||
git -c "user.name=Trunk Actions" -c "[email protected]" merge --squash "${PR_BRANCH}" | ||
java -jar bazel-diff.jar generate-hashes --workspacePath="${WORKSPACE_PATH}" "${merge_instance_with_pr_branch_out}" | ||
bazelDiff generate-hashes --workspacePath="${WORKSPACE_PATH}" "${merge_instance_with_pr_branch_out}" | ||
|
||
# Compute impacted targets | ||
java -jar bazel-diff.jar get-impacted-targets --startingHashes="${merge_instance_branch_out}" --finalHashes="${merge_instance_with_pr_branch_out}" --output="${impacted_targets_out}" | ||
bazelDiff get-impacted-targets --startingHashes="${merge_instance_branch_out}" --finalHashes="${merge_instance_with_pr_branch_out}" --output="${impacted_targets_out}" | ||
|
||
num_impacted_targets=$(wc -l <"${impacted_targets_out}") | ||
echo "Computed ${num_impacted_targets} targets for sha ${pr_branch_head_sha}" | ||
|