Skip to content
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

:bazel-diff -- generate-hashes is not giving correct targets when changed something in build attribute .bzl file which imported in many BUILD files #227

Open
ananta-code opened this issue Sep 23, 2024 · 2 comments

Comments

@ananta-code
Copy link

ananta-code commented Sep 23, 2024

Hi,

I am using bazel run :bazel-diff -- generate-hashes --workspacePath="/home/jenkins/workspace/PROJECT" /home/jenkins/starting_hashes1.json against a commit id to find out list of files and similarly running the same command to find the final_hashes.json file against a final commit after checking out the code git checkout "c41b43xxxxxxxxxx"

But i observed this is not returning correct targets when i run

bazel run :bazel-diff -- get-impacted-targets --startingHashes=/home/jenkins/starting_hashes.json --finalHashes=/home/jenkins/final_hashes.json --output=/home/jenkins/bazel_diff_impacted_targets.json

However i tried using --useCquery="true" while generating hashes hope it might give me correct file list but it is damn slow .

I am using bazel 7.3 .

Please suggest if anything can be done or missing?

Regards,
abcuser

@ananta-code ananta-code changed the title :bazel-diff -- generate-hashes is not giving correct hash of all files :bazel-diff -- generate-hashes is not giving correct targets Sep 23, 2024
@ananta-code ananta-code changed the title :bazel-diff -- generate-hashes is not giving correct targets :bazel-diff -- generate-hashes is not giving correct targets when changed something in bazel attribute .bzl file which imported in many BUILD files Sep 23, 2024
@ananta-code ananta-code changed the title :bazel-diff -- generate-hashes is not giving correct targets when changed something in bazel attribute .bzl file which imported in many BUILD files :bazel-diff -- generate-hashes is not giving correct targets when changed something in build attribute .bzl file which imported in many BUILD files Sep 23, 2024
@tinder-maxwellelliott
Copy link
Collaborator

Can you get me an explanation of what you mean by not the correct targets, what targets are missing from your impacted list?

Also a minor repro story can help in debugging this since this should likely be a CI check in the repo to make sure we don't regress on whatever the issue is here

@ananta-code
Copy link
Author

ananta-code commented Sep 24, 2024

Let's say i have defined service metadata to something called all_gke_service.bzl

`def all_gke_service(
name,
acceptance_test_tags = ["acceptance"],
technology_type = "java",
upload_to_nexus_targets = [],
unit_test_tags = ["unit"],
**kwargs):
"""Generates GKE deployment configs for each service

Args:
  name: service name (without tenant suffix)
  acceptance_test_tags: tag(s) for acceptance tests for the main service
  technology_type: the type of technology in which the service was written
  upload_to_nexus_targets: list of Nexus upload targets, if any
  unit_test_tags: tag(s) for unit tests for the main service
  **kwargs: any other service attributes that apply to all tenants (pass-through)
"""

arguments = struct(
    name = name,
    acceptance_test_tags = acceptance_test_tags,
    technology_type = technology_type,
    upload_to_nexus_targets = upload_to_nexus_targets,
    unit_test_tags = unit_test_tags,
    subdir_prefix = subdir_prefix,
)

# Validate required attributes
validate_common_arguments(arguments)`

Then i am using all_gke_service.bzl file in some application BUILD.bazel file.
like

`load("//bazel:mvn_rules.bzl", "mvn_install")
load("//bazel:all_gke_service.bzl", "all_gke_service")

package(default_visibility = ["//visibility:public"])

test_suite(
name = "all_tests",
)

mvn_install(
name = "service",
srcs = [":main_srcs"],
finalName = "app-service.jar",
java_version = "java-17-openjdk",
project = "service",
deps = [
],
)

all_gke_service(
name = "test-service",
acceptance_test_tags = [], # disabled until acceptance test functionality is fixed
....
....
)
`

SO when i change anything in all_gke_service.bzl , i am expecting bazel-diff get-impacted-targets should return all service targets which uses all_gke_service.bzl in their BUILD.bazel file but bazel-diff get-impacted-targets command wont return any thing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants