Tinder / bazel-diff

Performs Bazel Target Diffing between two revisions in Git, allowing for Test Target Selection and Selective Building
Other
405 stars 60 forks source link

: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 2 months ago

ananta-code commented 2 months ago

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

tinder-maxwellelliott commented 2 months ago

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 commented 2 months ago

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