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

Hashes does not match #222

Closed
sajan45 opened this issue Aug 21, 2024 · 2 comments
Closed

Hashes does not match #222

sajan45 opened this issue Aug 21, 2024 · 2 comments

Comments

@sajan45
Copy link

sajan45 commented Aug 21, 2024

My issue is similar to #180. The difference is that it does not happen when the workspace is different, it happens when the host machine is different.

For commit with SHA: abcdef
Hashes generated on a local machine match, even when we try 2 different workspace paths, for example /a and /b, which contain a separate clone of the same repo.

For the same commit, hashes generated on a Jenkins node are different. Jenkins of course has a different workspace path than the local machine.

This should not be an issue if we cache the hashes from the Jenkins pipeline and reuse them inside Jenkins only, but our use case tries to generate these hashes on the developer's machine if there is a cache miss (which is intentional for now).

Like the comment on that issue, if we do --ignoredRuleHashingAttributes=location,path, this solves the problem and hashes match, but my concern is can this have unexpected consequences like false positives or negatives and missing to detect some changed targets?

I am sorry if this is not a bazel-diff issue and more of a question related to the usage. I am new to Bazel and have inherited a code that uses it extensively. I could not find any doc about the impact of ignoring the location & path attributes.

We use bazel-diff 6.1.0 and bazel 6.5.0

@tinder-maxwellelliott
Copy link
Collaborator

There is some additional context here #180

This is not the default since we don't know how every users environment works. There are many users of --ignoredRuleHashingAttributes for this tool.

@sajan45
Copy link
Author

sajan45 commented Aug 22, 2024

@tinder-maxwellelliott
I understand that using --ignoredRuleHashingAttributes isn't an issue by itself. However, I haven't explored how Bazel-diff utilizes attributes when calculating the hash. My question is: if we ignore location and path, could this lead to any false positives or negatives?

Apologies if this is a basic question, especially since you're not familiar with our environment. We do have some genrule like the one below that uses location. If you're unable to provide an answer, please feel free to close this issue.

genrule(
    name = "generate_openapi_spec",
    outs = ["spec.json"],
    cmd = (
        "$(locations //ts/server:openapi_spec_generator) $(location spec.json)"
    ),
    executable = True,
    message = "Generating spec.json",
    tools = [
        "//ts/server:openapi_spec_generator",
    ],
)

@sajan45 sajan45 closed this as completed Aug 26, 2024
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