Gitea: User manual Git migration and online editing #51

Open
opened 2023-02-27 18:50:38 +01:00 by Brecht Van Lommel · 15 comments

Contributing to the user manual is currently quite technical, and requires using subversion. The first step will be moving the manual to a Git repository with LFS. This already will allow some level of online editing.

Git migration:

  • LFS enabled on Gitea (#26)
  • Buildbot integration
    • Nightly builds
    • Incremental builds
    • Commit status reporting
    • Patch builder
    • blender-bot integration
    • Linting, dead link checks
  • Main repo Git migration
    • Basic import
    • Map authors
    • Tags and branches
  • Translation repo Git migration
  • Update contribution docs
  • Document pull request workflow
  • Ensure git-lfs is installed on all buildbot workers
  • Remove old svn folders on buildbot workers

Online editing:

  • RST preview through external renderer
    • External renderer implementation
    • Put Gitea changes in blender-merged
    • Deploy with dedicated sphinx user for isolation on uatest
    • Deploy on projects.blender.org
  • Gitea workflow improvements
    • Default to creating pull request for main repo instead of fork
    • When editing files in main repo, auto create branch in fork
    • Online sync changes from main repo to fork
  • Document online editing workflow
Contributing to the user manual is currently quite technical, and requires using subversion. The first step will be moving the manual to a Git repository with LFS. This already will allow some level of online editing. Git migration: * [x] LFS enabled on Gitea (#26) * [ ] Buildbot integration * [x] Nightly builds * [x] Incremental builds * [x] Commit status reporting * [ ] Patch builder * [ ] blender-bot integration * [ ] Linting, dead link checks * [x] Main repo Git migration * [x] Basic import * [x] Map authors * [x] Tags and branches * [x] Translation repo Git migration * [x] Update contribution docs * [x] Document pull request workflow * [x] Ensure git-lfs is installed on all buildbot workers * [x] Remove old svn folders on buildbot workers Online editing: * [x] RST preview through [external renderer](https://docs.gitea.io/en-us/external-renderers/) * [x] External renderer implementation * [x] Put Gitea changes in `blender-merged` * [x] Deploy with dedicated sphinx user for isolation on uatest * [x] Deploy on projects.blender.org * [ ] Gitea workflow improvements * [x] Default to creating pull request for main repo instead of fork * [ ] When editing files in main repo, auto create branch in fork * [ ] Online sync changes from main repo to fork * [ ] Document online editing workflow
Author
Owner
CC @blendify
Brecht Van Lommel added the
Service
Buildbot
label 2023-02-27 18:53:31 +01:00

It's an open question what we should do to improve on that. Is there a good platform that can be used for online editing, or do we keep everything on Gitea?

I think keeping everything on Gitea would be sufficient. Adding more would just complicate the process in my opinion.

Adding the rst preview would be a nice to have though.

> It's an open question what we should do to improve on that. Is there a good platform that can be used for online editing, or do we keep everything on Gitea? I think keeping everything on Gitea would be sufficient. Adding more would just complicate the process in my opinion. Adding the rst preview would be a nice to have though.
Author
Owner

I also didn't find a good candidate for an alternative online editor, so perhaps it's the best we can do for now.

For rst preview, Gitea needs a command to convert rst to html. The basic pandoc command from the docs generates would have wrong URLs for images, :doc: links are not generated, and probably various other sphinx features are not supported. Pandoc has various customization options so perhaps there is a way to improve this.

But perhaps better, a script could be written that uses sphinx to generate html from a single rst file? Not sure if there is a convenient way to do it. But basic working links and images would be nice even if they can't be verified to be correct.

I also didn't find a good candidate for an alternative online editor, so perhaps it's the best we can do for now. For rst preview, Gitea needs a command to convert rst to html. The basic pandoc command from the docs generates would have wrong URLs for images, `:doc:` links are not generated, and probably various other sphinx features are not supported. Pandoc has various customization options so perhaps there is a way to improve this. But perhaps better, a script could be written that uses sphinx to generate html from a single rst file? Not sure if there is a convenient way to do it. But basic working links and images would be nice even if they can't be verified to be correct.
Author
Owner

The other approach of course would be to convert the manual to markdown or support both rst and md pages. That would likely help attract contributors and developers, but it's also a complicated change that involves a lot work and trade-offs.

The other approach of course would be to convert the manual to markdown or support both rst and md pages. That would likely help attract contributors and developers, but it's also a complicated change that involves a lot work and trade-offs.

For rst preview, Gitea needs a command to convert rst to html.
But perhaps better, a script could be written that uses sphinx to generate html from a single rst file?

This is possible with the command:

sphinx-build -b html -j auto manual build/html <path_to_rst_file>


The other approach of course would be to convert the manual to markdown or support both rst and md pages. That would likely help attract contributors and developers, but it's also a complicated change that involves a lot work and trade-offs.

I would avoid this, like you said there are many trade offs and rst is much more powerful than markdown and leaves a lot to be desired.

> For rst preview, Gitea needs a command to convert rst to html. >But perhaps better, a script could be written that uses sphinx to generate html from a single rst file? This is possible with the command: `sphinx-build -b html -j auto manual build/html <path_to_rst_file>` ----- > The other approach of course would be to convert the manual to markdown or support both rst and md pages. That would likely help attract contributors and developers, but it's also a complicated change that involves a lot work and trade-offs. > I would avoid this, like you said there are many trade offs and rst is much more powerful than markdown and leaves a lot to be desired.
Author
Owner

This is possible with the command:

sphinx-build -b html -j auto manual build/html <path_to_rst_file>

The issue is that it gets the contents of a single rst file and nothing else from the repository. That command assumes it has the whole repository available.

Making a checkout of the full repository would be too slow for to do for every preview. Unless perhaps some clever caching mechanism is implemented, but that seems complicated.

For security we'd also need to ensure we're not executing custom Python code written by users in the conf.py in their fork of the repository.

Links and images can still work even without the full repository as long as we set them to the right URL. However sphinx wants to validate that the files exist, which is not helpful in this case and maybe we need some way to generate the links without validation.

> This is possible with the command: > > `sphinx-build -b html -j auto manual build/html <path_to_rst_file>` The issue is that it gets the contents of a single rst file and nothing else from the repository. That command assumes it has the whole repository available. Making a checkout of the full repository would be too slow for to do for every preview. Unless perhaps some clever caching mechanism is implemented, but that seems complicated. For security we'd also need to ensure we're not executing custom Python code written by users in the conf.py in their fork of the repository. Links and images can still work even without the full repository as long as we set them to the right URL. However sphinx wants to validate that the files exist, which is not helpful in this case and maybe we need some way to generate the links without validation.
Author
Owner

I managed to hack together something to render a single page:
https://projects.blender.org/brecht/gitea-custom/src/branch/sphinx/sphinx
https://github.com/go-gitea/gitea/pull/23333

But this will need changes to ensure security before this can be deployed. Probably running as an isolated user or a web service.

editor_preview_external_renderers.png

And links are missing due to other pages not being available.

I managed to hack together something to render a single page: https://projects.blender.org/brecht/gitea-custom/src/branch/sphinx/sphinx https://github.com/go-gitea/gitea/pull/23333 But this will need changes to ensure security before this can be deployed. Probably running as an isolated user or a web service. ![editor_preview_external_renderers.png](/attachments/6b75dab2-1fea-48b3-a89b-97e5563851bd) And links are missing due to other pages not being available.
Author
Owner

I made :doc: links work.:ref: and :term: can't work based on just a single RST files so those links don't lead anywhere for now.

Security should also be much better now though there are some specifics to be figured out for deployment.

I made `:doc:` links work.`:ref:` and `:term:` can't work based on just a single RST files so those links don't lead anywhere for now. Security should also be much better now though there are some specifics to be figured out for deployment.
Brecht Van Lommel added the
Type
Deployment
label 2023-03-10 01:00:50 +01:00
Author
Owner

I did a few more fixes to improve the preview, based on testing with the actual manual.

For reference this is how I generated the Git repo.

sudo apt install git-lfs svn2git
pip3 install git-filter-repo

mkdir blender-manual
cd blender-manual
svn2git https://svn.blender.org/svnroot/bf-manual

# Rename default branch
git branch -m master main

# Remove unnecessary top level directory
git filter-repo --force --subdirectory-filter blender_docs/

# LFS filter for image, video, archive, 3D files.
git lfs migrate import --everything --include="*.exr,*.psd,*.pdd,*.psb,*.jp2,*.j2c,*.tx,*.gif,*.jpg,*.jpeg,*.tga,*.tif,*.tiff,*.bmp,*.png,*.dds,*.cin,*.dpx,*.hdr,*.webp,*.ttf,*.TTF,*.otf,*.aif,*.ogg,*.wav,*.aac,*.flac,*.oga,*.wma,*.rns,*.mp3,*.flv,*.mov,*.wmv,*.mpg,*.mpeg,*.avi,*.mp4,*.mkv,*.webm,*.FBX,*.fbx,*.blend,*.rar,*.zip,*.gz,*.7z,*.obj,*.3ds,*.gltf,*.glb,*.ply,*.vdb,*.nvdb,*.usd,*.usdz,*.usdc,*.pdf"
I did a few more fixes to improve the preview, based on testing with the actual manual. For reference this is how I generated the Git repo. ``` sudo apt install git-lfs svn2git pip3 install git-filter-repo mkdir blender-manual cd blender-manual svn2git https://svn.blender.org/svnroot/bf-manual # Rename default branch git branch -m master main # Remove unnecessary top level directory git filter-repo --force --subdirectory-filter blender_docs/ # LFS filter for image, video, archive, 3D files. git lfs migrate import --everything --include="*.exr,*.psd,*.pdd,*.psb,*.jp2,*.j2c,*.tx,*.gif,*.jpg,*.jpeg,*.tga,*.tif,*.tiff,*.bmp,*.png,*.dds,*.cin,*.dpx,*.hdr,*.webp,*.ttf,*.TTF,*.otf,*.aif,*.ogg,*.wav,*.aac,*.flac,*.oga,*.wma,*.rns,*.mp3,*.flv,*.mov,*.wmv,*.mpg,*.mpeg,*.avi,*.mp4,*.mkv,*.webm,*.FBX,*.fbx,*.blend,*.rar,*.zip,*.gz,*.7z,*.obj,*.3ds,*.gltf,*.glb,*.ply,*.vdb,*.nvdb,*.usd,*.usdz,*.usdc,*.pdf" ```

I had to also install git-filter-repo.

I had to also install `git-filter-repo`.
Brecht Van Lommel changed title from User manual online editing to User manual Git migration and online editing 2023-05-08 20:20:22 +02:00
Author
Owner

@Blendify @Arnd. I've created a test repo here, which also includes branches, tags and commit authors that match user accounts. See the attached scripts and mailmap for how it was done.
https://projects.blender.org/brecht/blender-manual

What I could not get working is nice merge commits, not sure it is even supported by svn2git. It just shows Merge branch 'blender-3.5-release' without any relation to the commits in the branch. I guess this is ok.

The branches have been renamed from e.g. blender-3.5-release to blender-v3.5-release for consistency with the Blender repo.

@Blendify @Arnd. I've created a test repo here, which also includes branches, tags and commit authors that match user accounts. See the attached scripts and mailmap for how it was done. https://projects.blender.org/brecht/blender-manual What I could not get working is nice merge commits, not sure it is even supported by `svn2git`. It just shows `Merge branch 'blender-3.5-release'` without any relation to the commits in the branch. I guess this is ok. The branches have been renamed from e.g. `blender-3.5-release` to `blender-v3.5-release` for consistency with the Blender repo.
Author
Owner

I've put a translation repo here.
https://projects.blender.org/brecht/blender-manual-translations

This repository is also quite big, but we can't use LFS for it since the translation files are text and treating them as binary files would not give good delta compression.

The author mapping is not as good for this one, since I don't have easy access to the developer.blender.org username to full name mapping. I've attached the mailmap in case anyone wants to try improving it.

There's also just one branch. We could add per release branches and get them used on the buildbot if desired. I'm not sure what is better, translations of unchanged text may be added later, but changed text may also delete translations.

I've put a translation repo here. https://projects.blender.org/brecht/blender-manual-translations This repository is also quite big, but we can't use LFS for it since the translation files are text and treating them as binary files would not give good delta compression. The author mapping is not as good for this one, since I don't have easy access to the developer.blender.org username to full name mapping. I've attached the mailmap in case anyone wants to try improving it. There's also just one branch. We could add per release branches and get them used on the buildbot if desired. I'm not sure what is better, translations of unchanged text may be added later, but changed text may also delete translations.
Author
Owner

The uatest buildbot is now building from Git. This includes nightly builds, incremental builds (without delivery), and build status reporting of commits. Pull request builds and @blender-bot build are not there yet, that will be for after the initial deployment.

This one was built from Git:
https://docs.blender.org/UATEST/manual/en/dev/

@Blendify what I need from you before we can deploy this:

  • Check if the repositories are ok.
  • Prepare updated manual contribution instructions
  • A devtalk announcement that you can post when this goes live

@Arnd, I need some help from you to deploy the RST preview, particularly regarding user isolation. This is not a blocker but would be great to have available alongside this.
https://projects.blender.org/infrastructure/gitea-custom/src/branch/main/sphinx/

The uatest buildbot is now building from Git. This includes nightly builds, incremental builds (without delivery), and build status reporting of commits. Pull request builds and `@blender-bot build` are not there yet, that will be for after the initial deployment. This one was built from Git: https://docs.blender.org/UATEST/manual/en/dev/ @Blendify what I need from you before we can deploy this: * Check if the repositories are ok. * Prepare updated manual contribution instructions * A devtalk announcement that you can post when this goes live @Arnd, I need some help from you to deploy the RST preview, particularly regarding user isolation. This is not a blocker but would be great to have available alongside this. https://projects.blender.org/infrastructure/gitea-custom/src/branch/main/sphinx/
Author
Owner

Git repositories are now online and buildbot was updated.
https://code.blender.org/2023/05/sunsetting-subversion/

I'll keep this issue open for the remaining tasks.

Git repositories are now online and buildbot was updated. https://code.blender.org/2023/05/sunsetting-subversion/ I'll keep this issue open for the remaining tasks.
Bart van der Braak added this to the DevOps Progress Board project 2024-07-16 12:59:01 +02:00
Bart van der Braak changed title from User manual Git migration and online editing to Gitea: User manual Git migration and online editing 2024-07-17 15:18:12 +02:00
Bart van der Braak removed the
Service
Buildbot
label 2024-08-01 11:01:41 +02:00
Bart van der Braak added the
Service
Gitea
label 2024-08-01 11:15:39 +02:00

For reference:

When editing files in main repo, auto create branch in fork

There is a bug report in Gitea about this: go-gitea/gitea#9017

For reference: > When editing files in main repo, auto create branch in fork There is a bug report in Gitea about this: [go-gitea/gitea#9017](https://github.com/go-gitea/gitea/issues/9017)
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: infrastructure/blender-projects-platform#51
No description provided.