Skip to content

Fix CI documentation diff #39622

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
Mar 22, 2025
Merged

Conversation

user202729
Copy link
Contributor

@user202729 user202729 commented Mar 3, 2025

As discussed in #39542 . Without this, the "Changes is ready!" feature will be broken.

Also remove some outdated documentation (the requirement list in update-conda was wrong (toml missing), I just refer to README.md which contains the correct list)

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

-e 's;#L[0-9]*";";' \
-e 's;tab-set--[0-9]*-;tab-set-;' \
-e 's;"tab-set--[0-9]*";"tab-set";' \
"$@"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if this is more suitable to be put in .ci instead. On the other hand it seems like something that is not that specific to CI?

Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest to put it in .github/workflows. tools is for developers (I have a hard time seeing why someone would like to run this script locally) and .ci is mostly outdated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, I misreads.

On the other hand

.ci is mostly outdated.

the problem is the substitute aren't good enough yet. For example test-new takes only ≈ 15 minutes while meson test takes an hour. Meson doesn't have incremental build or documentation build or documentation diff either.

Copy link
Contributor Author

@user202729 user202729 Mar 4, 2025

Choose a reason for hiding this comment

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

I suggest to put it in .github/workflows.

Actually… this feels wrong somehow.

Argument to support it: there are already two scripts there.

Arguments against it: we're only using GitHub actions for CI, so GitHub workflows and CI should be synonymous. It is not a good idea to have two locations for the same purpose. (if we do this we might consider moving the scripts back as well, but I guess that's out of scope here)

What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

In #39642, I propose to remove the .ci directory. What do you think?

@user202729 user202729 mentioned this pull request Mar 3, 2025
5 tasks
@user202729 user202729 force-pushed the docdiff-ci-refactor branch from 2b1815d to 8c2fff5 Compare March 3, 2025 03:56
-e 's;#L[0-9]*";";' \
-e 's;tab-set--[0-9]*-;tab-set-;' \
&& true)
find . -name "*.html" | xargs ../tools/clean-doc-html && true)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The true seems useless, but I keep it just in case.

Copy link

github-actions bot commented Mar 3, 2025

Documentation preview for this PR (built with commit 3b83e4b; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@user202729 user202729 added the p: CI Fix merged before running CI tests label Mar 3, 2025
@user202729
Copy link
Contributor Author

user202729 commented Mar 3, 2025

I wonder if marking it as CI Fix will work… problem is GitHub reads the yml files before applying the changes (otherwise how can it know what to run to apply the changes in the first place), right.

On the slightly-less-negative side we only waste 13 additional seconds of CPU time per pull request.

image

@tobiasdiez
Copy link
Contributor

Also move some documentation closer to the source.

Not sure if I like this change or not. The rendering of code in markdown (eg here on github) is usually way better than in the docstrings in python files.

@user202729
Copy link
Contributor Author

The rendering of code in markdown (eg here on github) is usually way better than in the docstrings in python files.

That's true, but in principle that's only a technical issue rather than a practical one (e.g. normally there is Sphinx to render RST to HTML) In practice… either way is fine for me.

@user202729 user202729 changed the title Refactor some tools and fix CI documentation diff Fix CI documentation diff Mar 4, 2025
Copy link
Contributor

@tobiasdiez tobiasdiez left a comment

Choose a reason for hiding this comment

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

From my side this looks good. @kwankyu can you please have a look as well given your expertise in the doc-changeset business.

@user202729 user202729 removed the p: CI Fix merged before running CI tests label Mar 12, 2025
@user202729
Copy link
Contributor Author

@kwankyu Do you have any comment? (I think we show not leave "view changes" broken for too long, yes it's my fault)

For what it's worth the changes link for this PR (https://doc-pr-39622--sagemath.netlify.app/CHANGES.html) is working. (the page is empty though.)

@kwankyu
Copy link
Collaborator

kwankyu commented Mar 16, 2025

Bash scripts like ".github/workflows/clean-doc-html.sh" used for CI go into the .ci directory.

General remark: The sed command has been carefully improved and battle-tested. Please test your changes to check for regressions.

@user202729
Copy link
Contributor Author

Bash scripts like ".github/workflows/clean-doc-html.sh" used for CI go into the .ci directory.

Uh, it's because of #39642 . I guess I can move it back (then maybe the other pull request if merged after this one can move it to .github/workflows again or something)

General remark: The sed command has been carefully improved and battle-tested. Please test your changes (on your fork) to check for regressions.

The command is not changed, just moved from one file to another to remove code duplication.

@kwankyu
Copy link
Collaborator

kwankyu commented Mar 17, 2025

The command is not changed, just moved from one file to another to remove code duplication.

The two sed commands are not identical.

@user202729
Copy link
Contributor Author

The command is not changed, just moved from one file to another to remove code duplication.

The two sed commands are not identical.

That's the point of this pull request, because of the code duplication I accidentally change one without change the other in #39542 (it was previously identical) which breaks the feature, so I decide to remove the code duplication to avoid possible issues in the future. (and in the meanwhile make the two commands identical again, obviously)

@kwankyu
Copy link
Collaborator

kwankyu commented Mar 17, 2025

... in #39542 (it was previously identical)

They were different in #39542.

@user202729
Copy link
Contributor Author

Before #39542 :

            # mathjax path in old doc (regex)
            mathjax_path_from="[-./A-Za-z_]*/tex-chtml[.]js?v=[0-9a-f]*"
            # mathjax path in new doc
            mathjax_path_to=$(docker exec -e SAGE_USE_CDNS=yes BUILD /sage/sage -python -c "from sage_docbuild.conf import mathjax_path; print(mathjax_path)")
            new_version=$(docker exec BUILD cat src/VERSION.txt)
            # Wipe out chronic diffs between old doc and new doc
            (cd doc && \
             find . -name "*.html" | xargs sed -i -e '/class="sidebar-brand-text"/ s/Sage [0-9a-z.]* /Sage '"$new_version"' /' \
                                                  -e 's;?v=[0-9a-f]*";";' \
                                                  -e 's;'"$mathjax_path_from"';'"$mathjax_path_to"';' \
                                                  -e '\;<script type="application/vnd\.jupyter\.widget-state+json">;,\;</script>; d' \
                                                  -e 's;#L[0-9]*";";' \
                                                  -e 's;tab-set--[0-9]*-;tab-set-;' \

versus

            (cd doc && git add -A && git commit --quiet -m 'new')
            # Wipe out chronic diffs of new doc against old doc before creating CHANGES.html
            (cd doc && \
             find . -name "*.html" | xargs sed -i -e '/This is documentation/ s/ built with GitHub PR .* for development/ for development/' \
                                                  -e 's;?v=[0-9a-f]*";";' \
                                                  -e '\;<script type="application/vnd\.jupyter\.widget-state+json">;,\;</script>; d' \
                                                  -e 's;#L[0-9]*";";' \
                                                  -e 's;tab-set--[0-9]*-;tab-set-;' \
             && git commit -a -m 'wipe-out')

… okay yes they're different. I can't say I fully understand what they do so I'll just try my best to preserve the old behavior while removing code duplication.

@user202729 user202729 marked this pull request as draft March 17, 2025 01:48
@kwankyu
Copy link
Collaborator

kwankyu commented Mar 17, 2025

Before making diffs, the first sed command removes things specific to the doc for the last sage release, and the second sed command removes things specific to the doc for the PR branch. They cannot be the same.

@user202729 user202729 force-pushed the docdiff-ci-refactor branch from 749f874 to f93e1ef Compare March 17, 2025 09:17
@user202729 user202729 marked this pull request as ready for review March 17, 2025 09:17
@user202729 user202729 force-pushed the docdiff-ci-refactor branch from f93e1ef to 3b83e4b Compare March 17, 2025 09:19
@user202729
Copy link
Contributor Author

user202729 commented Mar 17, 2025

I decide to just keep the old situation and fix both occurrences. Refactor etc. can be left for some day in the future.

Seems like it's working now — I previously tried adding a code block and there isn't several spurious tab-set diffs shown up.

Copy link
Collaborator

@kwankyu kwankyu left a comment

Choose a reason for hiding this comment

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

LGTM.

vbraun pushed a commit to vbraun/sage that referenced this pull request Mar 19, 2025
sagemathgh-39622: Fix CI documentation diff
    
As discussed in sagemath#39542 . Without
this, the "Changes is ready!" feature will be broken.

Also remove some outdated documentation (the requirement list in update-
conda was wrong (toml missing), I just refer to README.md which contains
the correct list)

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39622
Reported by: user202729
Reviewer(s): Kwankyu Lee, Tobias Diez, user202729
@vbraun vbraun merged commit 185fd5f into sagemath:develop Mar 22, 2025
23 of 24 checks passed
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.

4 participants