-
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: Allow
WORKSPACE
Path Override (#12)
- Relaxes the assumption that the `path/to/WORKSPACE` is at the root of the git repo. - Add a required E2E test which checks out this repo and runs the `compute_impacted_targets` test. --------- Co-authored-by: Phil Vendola <[email protected]>
- Loading branch information
1 parent
7ceff3f
commit b730783
Showing
4 changed files
with
63 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Pull Request | ||
on: pull_request | ||
|
||
permissions: read-all | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
name: E2E Tests | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Java | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: oracle | ||
java-version: "17" | ||
|
||
- name: Setup Bazel | ||
# trunk-ignore(semgrep): Trust third-party `bazelbuild` GH Action | ||
uses: bazelbuild/setup-bazelisk@v2 | ||
|
||
- name: Compute Impacted Targets | ||
id: compute | ||
run: ./src/scripts/compute_impacted_targets.sh | ||
shell: bash | ||
env: | ||
MERGE_INSTANCE_BRANCH: main | ||
PR_BRANCH: do_not_delete/stable_test_branch | ||
VERBOSE: 1 | ||
WORKSPACE_PATH: ./tests/simple_bazel_workspace | ||
|
||
- name: Validate Impacted Targets Computation | ||
shell: bash | ||
run: | | ||
target_count=`cat ${{ steps.compute.outputs.impacted_targets_out }} | wc -l` | ||
if [[ $target_count -ne 2 ]]; then | ||
exit 1 | ||
fi |
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
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 |
---|---|---|
|
@@ -17,13 +17,17 @@ if [[ (-z ${MERGE_INSTANCE_BRANCH}) || (-z ${PR_BRANCH}) ]]; then | |
exit 2 | ||
fi | ||
|
||
if [[ -z ${WORKSPACE_PATH} ]]; then | ||
echo "Missing workspace path" | ||
exit 2 | ||
fi | ||
|
||
logIfVerbose "Fetching all remotes..." | ||
git fetch --all --quiet | ||
logIfVerbose "...done!" | ||
|
||
# Install the bazel-diff JAR. Avoid cloning the repo, as there will be conflicting WORKSPACES. | ||
curl -Lo bazel-diff.jar https://github.com/Tinder/bazel-diff/releases/latest/download/bazel-diff_deploy.jar | ||
workspace_path=$(pwd) | ||
|
||
git switch "${MERGE_INSTANCE_BRANCH}" | ||
git fetch --unshallow --quiet | ||
|
@@ -59,11 +63,11 @@ 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}" | ||
java -jar bazel-diff.jar 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}" | ||
java -jar bazel-diff.jar 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}" | ||
|
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