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

Different workspaces produce different hashes #180

Closed
erikkerber opened this issue Jun 1, 2023 · 10 comments
Closed

Different workspaces produce different hashes #180

erikkerber opened this issue Jun 1, 2023 · 10 comments

Comments

@erikkerber
Copy link

Let me know if "feature" or "bug"

Assume a Bazel repo in /a:

cd a
bazel run :bazel-diff --script_path=/tmp/bazel-diff
cd ..

/tmp/bazel-diff generate-hashes --workspacePath=/a /tmp/a-hash
cp -r a b
/tmp/bazel-diff generate-hashes --workspacePath=/b /tmp/b-hash
cmp /tmp/a-hash /tmp/b-hash

As a background — we're caching the hash results to avoid too many Git checkouts/fetches in builds, but finding out that different workspaces result in different results. The workspaces are a boring implementation detail of our CI system which different paths/checkouts for different jobs.

@aarontsharp
Copy link

aarontsharp commented Jun 4, 2023

We are also trying to accomplish similar as our CI system by default does shallow clones and we likewise want to avoid switching branches and calculating hashes for previous builds. I've found unless the hashes are generated on the exact same machine, they're always different. In our case, even different CI runner instances with otherwise identical configuration, OS, file systems, etc always produce different hashes.

tinder-maxwellelliott added a commit that referenced this issue Jun 6, 2023
Related Different workspaces produce different hashes #180
@tinder-maxwellelliott
Copy link
Collaborator

Can you test out #182 and let me know how it works, if it works we can find a way to set the list of ignored attributes when hashing

@erikkerber
Copy link
Author

@tinder-maxwellelliott 100% did the trick. Awesome 🙇🏼

@tinder-maxwellelliott
Copy link
Collaborator

Okay Ill work on making it so the list of ignored attributes can be provided by an end user

@tinder-maxwellelliott
Copy link
Collaborator

@erikkerber Can you do one last test with #182, I added the ability to list attributes you wish to ignore during rule target hashing

@aarontsharp
Copy link

aarontsharp commented Jun 9, 2023

@tinder-maxwellelliott #182 worked for me, thanks! I had to add location and path to the ignore list. In my case, I observed many of the external rules (like bazel_tools) always seemed to have a different path in our different runners. I'm testing this out in our CI environment now, but I think this likely addresses the issues we were seeing. Thanks again!

@tinder-maxwellelliott
Copy link
Collaborator

Awesome, I'll close this then and merge it in. Thanks Y'all

tinder-maxwellelliott added a commit that referenced this issue Jun 9, 2023
#182)

* WIP: Ignore location attribute

Related Different workspaces produce different hashes #180

* properly inject argument

* get tests running
@jieyu
Copy link

jieyu commented May 7, 2024

I was trying to use the --ignoredRuleHashingAttributes flag to ignore certain attributes from a rule. So I have a rule that has a private attribute _go_vendor_modules_txt that is a filegroup. when compute hashes, I set --ignoredRuleHashingAttributes=_go_vendor_modules_txt. However, when trying to get impacted targets, it seems that the change of files in _go_vendor_modules_txt is still not ignored. Anything I did wrong?

@tinder-maxwellelliott
Copy link
Collaborator

I was trying to use the --ignoredRuleHashingAttributes flag to ignore certain attributes from a rule. So I have a rule that has a private attribute _go_vendor_modules_txt that is a filegroup. when compute hashes, I set --ignoredRuleHashingAttributes=_go_vendor_modules_txt. However, when trying to get impacted targets, it seems that the change of files in _go_vendor_modules_txt is still not ignored. Anything I did wrong?

Is this a rule attribute? Last I checked the proto I saw nothing like _go_vendor_modules_txt

@jieyu
Copy link

jieyu commented Sep 4, 2024

@tinder-maxwellelliott it's a custom rule in house.

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

4 participants