Skip to content

Do not hardcode CSS/JS checksums #226

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

Merged
merged 1 commit into from
Oct 30, 2023

Conversation

mitya57
Copy link
Contributor

@mitya57 mitya57 commented Oct 30, 2023

These checksums are tied to a particular version of Sphinx, Alabaster or Pygments, and the tests may fail when a different version is used.

Instead, calculate the checksum dynamically during the test.

@mitya57 mitya57 requested a review from a team as a code owner October 30, 2023 08:01
@mitya57 mitya57 requested a review from humitos October 30, 2023 08:01
Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@humitos
Copy link
Member

humitos commented Oct 30, 2023

Can you check why Python 3.8 tests are failing?

@mitya57
Copy link
Contributor Author

mitya57 commented Oct 30, 2023

Oh, it's because the _file_checksum function is in different places in Sphinx 7.1 and Sphinx 7.2.

Maybe I should just inline the checksum calculation code instead of using the private API. Or ask Sphinx developers to make it public.

@mitya57 mitya57 force-pushed the dont-hardcode-checksums branch from 80e220e to f1f8175 Compare October 30, 2023 09:53
@mitya57
Copy link
Contributor Author

mitya57 commented Oct 30, 2023

After removing the sanity checks that we don't need for tests, that function has only 6 lines. So I inlined it.

@humitos
Copy link
Member

humitos commented Oct 30, 2023

Oh, it's because the _file_checksum function is in different places in Sphinx 7.1 and Sphinx 7.2.

We have other places in the code where we check the Sphinx version and import different things, like:

if sphinx.version_info < (7, 1):
  from ... import ...
else:
  from ... import ...

I'd prefer if we import the correct function instead of in-lining it because if they change the logic, we will have the same problem that this PR is trying to solve: don't hardcode the hashes. If we hardcode the logic, we will have the same problem in the future.

These checksums are tied to a particular version of Sphinx, Alabaster
or Pygments, and the tests may fail when a different version is used.

Instead, calculate the checksum dynamically during the test.
@mitya57
Copy link
Contributor Author

mitya57 commented Oct 30, 2023

Updated the PR. And I have opened issue sphinx-doc/sphinx#11743 asking to make that function public API.

@humitos
Copy link
Member

humitos commented Oct 30, 2023

Excellent! Thanks 👍🏼

@humitos humitos merged commit 00ed1a1 into readthedocs:main Oct 30, 2023
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.

2 participants