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

Support reproducible builds by forcing window.search to use stable key ordering. #692

Merged
merged 1 commit into from
May 14, 2018

Conversation

tcr
Copy link
Contributor

@tcr tcr commented May 13, 2018

In CI, I run mdbook build to check that my repo's book is still well-formed. Each time I run this though, git notices that searchindex.js has been modified, even when I haven't made any changes to the book.

Running a diff on the old and new output shows that the only difference is in key ordering. Rust's HashMaps are randomly ordered, elasticlunr-rs uses HashMaps internally and when using serde_json::to_string that random order is directly written out.

We can force reproducible output by using serde_json::Value as an intermediary output, which uses BTreeMap internally, and will order the output keys consistently when written to a JSON string.

I can confirm that rerunning mdbook build repeatedly in my repo does not cause searchindex.js to be marked as modified.

@azerupi
Copy link
Contributor

azerupi commented May 13, 2018

The argument for adding this is sound.
Looks good to me!

@Michael-F-Bryan
Copy link
Contributor

Sounds good to me 👍

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

Successfully merging this pull request may close these issues.

3 participants