-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Support an Impacts All PATH Filter #39
Changes from 24 commits
1ccdac1
a027a45
3ba1034
2114b7f
8f6c7b9
276bc80
46ab842
f94cd89
67ca3bb
b36729e
36e6493
67a3255
7c18ac4
ea693da
428d546
fcdbf81
7e28975
123edc2
26865cb
6e765fe
f868d84
22badd3
1a24a1c
f3a3f2c
d2c20cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ jobs: | |
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Bazel | ||
# trunk-ignore(semgrep): Trust third-party `bazelbuild` GH Action | ||
|
@@ -20,8 +22,10 @@ jobs: | |
run: ./src/scripts/compute_impacted_targets.sh | ||
shell: bash | ||
env: | ||
MERGE_INSTANCE_BRANCH: main | ||
MERGE_INSTANCE_BRANCH: do_not_delete/stable_test_branch | ||
MERGE_INSTANCE_BRANCH_HEAD_SHA: 097c8259c2e18da92f6189849ebc0f7f6dc624e5 | ||
PR_BRANCH: do_not_delete/stable_test_branch | ||
PR_BRANCH_HEAD_SHA: 097c8259c2e18da92f6189849ebc0f7f6dc624e5 | ||
VERBOSE: 1 | ||
WORKSPACE_PATH: ./tests/simple_bazel_workspace | ||
BAZEL_STARTUP_OPTIONS: --host_jvm_args=-Xmx12G,--block_for_lock,--client_debug | ||
|
@@ -31,6 +35,6 @@ jobs: | |
shell: bash | ||
run: | | ||
target_count=`cat ${{ steps.compute.outputs.impacted_targets_out }} | wc -l` | ||
if [[ $target_count -ne 2 ]]; then | ||
if [[ $target_count -ne 0 ]]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We moved sha computation outside of the compute_impacted_targets script, and expect it as an input into the script. As opposed to running tests with a stable test branch and a moving main, we now run tests with a stable test branch and a stable main, such that we can pin the shas. In that case, we would expect no impacted targets to be computed. |
||
exit 1 | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,36 +29,59 @@ inputs: | |
description: A path to the Bazel executable. Defaults to PATH. | ||
required: false | ||
default: bazel | ||
impact-all-filters-path: | ||
description: | ||
A path to a list of filters to identify whether `ALL` impacted targets should be considered. | ||
See https://github.com/dorny/paths-filter/blob/master/.github/filters.yml for an example. | ||
required: false | ||
default: "" | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Detect changed paths | ||
id: detect-changed-paths | ||
if: ${{ inputs.impact-all-filters-path != '' }} | ||
# trunk-ignore(semgrep/yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha.third-party-action-not-pinned-to-commit-sha) | ||
uses: dorny/paths-filter@v2 | ||
with: | ||
filters: ${{ inputs.impact-all-filters-path }} | ||
|
||
- name: Prerequisites | ||
id: prerequisites | ||
run: ${GITHUB_ACTION_PATH}/src/scripts/prerequisites.sh | ||
shell: bash | ||
env: | ||
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} | ||
TARGET_BRANCH: ${{ inputs.target-branch }} | ||
PR_BRANCH: ${{ github.head_ref }} | ||
WORKSPACE_PATH: ${{ inputs.bazel-workspace-path }} | ||
BAZEL_PATH: ${{ inputs.bazel-path }} | ||
IMPACTS_FILTERS_CHANGES: ${{ steps.detect-changed-paths.outputs.changes }} | ||
|
||
- name: Install Bazel in PATH | ||
if: ${{ steps.prerequisites.outputs.requires_default_bazel_installation == 'true' }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like everything with
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I pushed a few changes to cleanup the workflow: I think this cleans up the workflow, PTAL. |
||
if: | ||
${{ steps.prerequisites.outputs.requires_default_bazel_installation == 'true' }} && ${{ | ||
steps.prerequisites.outputs.impacts_all_detected == 'false' }} | ||
# trunk-ignore(semgrep): Trust third-party `bazelbuild` GH Action | ||
uses: bazelbuild/setup-bazelisk@v2 | ||
|
||
- name: Setup jq | ||
if: ${{ steps.prerequisites.outputs.impacts_all_detected == 'false' }} | ||
# trunk-ignore(semgrep): Trust third-party action to install JQ. Source code: https://github.com/dcarbone/install-jq-action/ | ||
uses: dcarbone/install-jq-action@v1.0.1 | ||
|
||
- name: Compute Impacted Targets | ||
id: compute-impacted-targets | ||
run: ${GITHUB_ACTION_PATH}/src/scripts/compute_impacted_targets.sh | ||
if: ${{ steps.prerequisites.outputs.impacts_all_detected == 'false' }} | ||
shell: bash | ||
env: | ||
MERGE_INSTANCE_BRANCH: ${{ steps.prerequisites.outputs.merge_instance_branch }} | ||
PR_BRANCH: ${{ github.head_ref }} | ||
MERGE_INSTANCE_BRANCH_HEAD_SHA: | ||
${{ steps.prerequisites.outputs.merge_instance_branch_head_sha }} | ||
PR_BRANCH: ${{ steps.prerequisites.outputs.pr_branch }} | ||
PR_BRANCH_HEAD_SHA: ${{ steps.prerequisites.outputs.pr_branch_head_sha }} | ||
VERBOSE: ${{ inputs.verbose }} | ||
WORKSPACE_PATH: ${{ steps.prerequisites.outputs.workspace_path }} | ||
BAZEL_PATH: ${{ inputs.bazel-path }} | ||
|
@@ -73,5 +96,6 @@ runs: | |
REPOSITORY: ${{ github.repository }} | ||
TARGET_BRANCH: ${{ steps.prerequisites.outputs.merge_instance_branch }} | ||
PR_NUMBER: ${{ github.event.pull_request.number }} | ||
PR_SHA: ${{ steps.compute-impacted-targets.outputs.git_commit }} | ||
PR_SHA: ${{ steps.prerequisites.outputs.pr_branch_head_sha }} | ||
IMPACTED_TARGETS_FILE: ${{ steps.compute-impacted-targets.outputs.impacted_targets_out }} | ||
IMPACTS_ALL_DETECTED: ${{ steps.prerequisites.outputs.impacts_all_detected }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clone all. git cloning has been moved to the prerequisites step.