Skip to content

Commit 51c420e

Browse files
Update ci example run script (#162)
* Update ci example run script updates the bazel path to these actions * update config * more updates * set workspace * add set flags * update args * safer parsing of impacted targets
1 parent 97afefb commit 51c420e

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
with:
5656
fetch-depth: 0
5757
- name: Run bazel-diff example script
58-
run: USE_BAZEL_VERSION=latest ./bazel-diff-example.sh $(pwd) bazel $(git rev-parse HEAD~1) $(git rev-parse HEAD)
58+
run: USE_BAZEL_VERSION=latest ./bazel-diff-example.sh "$GITHUB_WORKSPACE" ~/go/bin/bazelisk $(git rev-parse HEAD~1) $(git rev-parse HEAD)
5959
test-jre11:
6060
runs-on: ubuntu-latest
6161
steps:
@@ -103,7 +103,7 @@ jobs:
103103
with:
104104
fetch-depth: 0
105105
- name: Run bazel-diff example script
106-
run: USE_BAZEL_VERSION=latest ./bazel-diff-example.sh $(pwd) bazel $(git rev-parse HEAD~1) $(git rev-parse HEAD)
106+
run: USE_BAZEL_VERSION=latest ./bazel-diff-example.sh "$GITHUB_WORKSPACE" ~/go/bin/bazelisk $(git rev-parse HEAD~1) $(git rev-parse HEAD)
107107
deploy:
108108
needs: [test-jre8, test-jre11]
109109
runs-on: ubuntu-latest

bazel-diff-example.sh

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
set -ex
4+
35
# Path to your Bazel WORKSPACE directory
46
workspace_path=$1
57
# Path to your Bazel executable
@@ -14,27 +16,23 @@ final_hashes_json="/tmp/final_hashes.json"
1416
impacted_targets_path="/tmp/impacted_targets.txt"
1517
bazel_diff="/tmp/bazel_diff"
1618

17-
shared_flags=""
18-
19-
# Uncomment the line below to see debug information
20-
# shared_flags="--config=verbose"
21-
22-
"$bazel_path" run :bazel-diff "$shared_flags" --script_path="$bazel_diff"
19+
"$bazel_path" run :bazel-diff --script_path="$bazel_diff"
2320

2421
git -C "$workspace_path" checkout "$previous_revision" --quiet
2522

2623
echo "Generating Hashes for Revision '$previous_revision'"
2724
$bazel_diff generate-hashes -w "$workspace_path" -b "$bazel_path" $starting_hashes_json
2825

29-
git -C "$workspace_path" checkout $final_revision --quiet
26+
git -C "$workspace_path" checkout "$final_revision" --quiet
3027

3128
echo "Generating Hashes for Revision '$final_revision'"
3229
$bazel_diff generate-hashes -w "$workspace_path" -b "$bazel_path" $final_hashes_json
3330

3431
echo "Determining Impacted Targets"
3532
$bazel_diff get-impacted-targets -sh $starting_hashes_json -fh $final_hashes_json -o $impacted_targets_path
3633

37-
IFS=$'\n' read -d '' -r -a impacted_targets < $impacted_targets_path
34+
impacted_targets=()
35+
IFS=$'\n' read -d '' -r -a impacted_targets < $impacted_targets_path || true
3836
formatted_impacted_targets=$(IFS=$'\n'; echo "${impacted_targets[*]}")
3937
echo "Impacted Targets between $previous_revision and $final_revision:"
4038
echo "$formatted_impacted_targets"

0 commit comments

Comments
 (0)