-
Notifications
You must be signed in to change notification settings - Fork 95
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
feat: generate addons readme in pre-commit #190
Conversation
I agree with this, but I remember that there was a technical dependency for HTML generation. @sbidoul do you remember? |
I've no idea what you are talking about :) |
No, seriously, it's complicated... if we do it in pre-commit we must disable it in the bot because the bot would likely not have the same version of the generator as pre-commit. But old repos don't have pre-commit. So yeah, still not sure how to do that best. Maybe we can enable readme generation in the bot for old versions and use pre-commit for 14+? Or simply abandon readme generation for repos that don't have pre-commit. |
Probably this: OCA/maintainer-tools#423
That might be a good solution. Less tasks for the bot. Another one is to instruct the bot to generate the readme using |
As a functional reviewer at certain times I find it very difficult to obtain information in the Readme and Usage files which are the fundamental files for us. This is increased when we are reviewing [FIX] [IMP] where there is not much information in these files. I wish we could have access to the final file before publication. Thank you contributors |
I have opened OCA/maintainer-tools#564 to discuss the problem and possible solution. At this stage I think this PR is acceptable in this template, but it should be enabled with a copier question and be disabled by default, because it would not work for OCA. |
Ah, this has been proposed before and reverted. See the discussion there: #90 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM and speeds up reviewing. We are using this way of work in custom developments and helps a lot. Specially if you want to be careful about readmes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I still don't think it is a good idea to enable this by default in OCA.
Hello! I've updated the PR to add |
@sbidoul I have noticed also that the current ocabot deployed maintainer-tools seems outdated and it's not generating the links with runboat links and word. |
It's still not clear to me how the bot and a pre-commit hook can/should interact for README generation. And a problem with pre-commit is that you have a red build until you run it locally, which makes it impossible tor functional contributors to work on documentation through the GitHub interface. We need to think all this through, first. In the meantime, if you want this pre-commit hook, it should be behind a copier question and disabled by default. |
Hello @sbidoul. I pushed a fix that should resolve the situation. With the new commit, CI will skip this hook. This is a valid usage IMHO because anyways the bot will generate the README if needed. So, if a functional person pushes a change to Both systems should be configured with |
Devs sometimes just update the `readme/*.rst` portions, relying in our nice bot that will convert that to a real `README.rst` + `index.html` after merge. When functional people go test PRs in runboat, the 1st thing they look at is the README. That's OK because there's where the docs should explain what the module is doing. These 2 situations are good in their own terms, but when you merge both, you get to a problem. You have to either: - Teach functional people to review the PR code, go to the `readme/` folder and understand the `.rst` syntax and the advanced github diff tooling. - Teach devs to remember always using the `oca-gen-addon-readme` before pushing the PR, so functionals can review the README in a more human-friendly fashion. None of these is a good solution. Both add manual and complex steps to the contribution workflow. Quoting from [OCA blog][1]: > The Board are working on these Major Projects for 2023: > Improve Contributor onboarding journey, leverage delegates > - Including Functional Consultants This PR goes along with those goals. By moving the readme generation into a pre-commit hook: 1. The dev just needs to stage -> commit -> re-stage -> re-commit. Just like always. 2. The functionals have a nicely rendered README available right from the Odoo UI. That's the UI a functional needs to know deeply (not Github's). @moduon [1]: https://odoo-community.org/blog/news-updates-1/oca-newsletter-1-2023-136
5aa7529
to
69ffba5
Compare
This should be ready to merge. |
CI ain't happy, though. |
Now that OCA/maintainer-tools#520 is fixed, it is safer to generate readmes in the hook.
This hook is meant to run only on dev machines. On CI we can skip it because the bot will regenerate the README if needed anyway.
I see very unfrequent that two PRs modify manifest or readme at the same time, so it's not a big deal. I prefer to have this automatically generated. |
As said previously, if a single PR modify readme / manifest it will conflict as soon as another PR changing the same module is merged. PR 1 : trivial patch on any file of module A. PR 2 : add a feature / change manifest / change readme of module A. As soon as PR 1 is merged, PR 2 will conflict with HEAD. |
AFAIK, README.rst only changes if there's a change in the contents of the |
The manifest and therefore the version is also part of the files that are hashed. Either we disable it from pre-commit, or we add a generation mode that keeps the existing hash and we use that in pre-commit, leaving only the bot to update the hash. But that's getting complicated... |
Why the manifest/version should be part of the hash if that is not reflected in the README.rst file? I think we should exclude that file from the hash. |
That is possible too but also a brittle hack. The generation mode that keeps the existing hash and we use that in pre-commit would be better I think, but I have not thought about this in details. |
It is part of the hash because the module name and summary are defined there. |
OK, I see. And can this be excluded partially, or is it a whole file hash? |
https://github.com/OCA/maintainer-tools/blob/master/tools/gen_addon_readme.py#L519 |
And maintainers. But doing a partial hash excluding the version would be brittle (say, if someone one days adds the version to the template). |
As seen in OCA#190 (comment), when somebody tried to merge 2 PRs for the same module, chances are that both imply different readme digests and the merge fails. As seen in OCA#220 (comment), this was already happening under some circumstances with `requirements.txt` files. Here I added a `.gitattributes` file which specifies a `merge=union` driver for those files. [Git docs][1] explain that this driver will just keep the changes from all files, marking the merge as succeeded and not including merge markers. This is not ideal, but is OK for our current situation because: 1. Duplicate/conflicting lines in those files should not really harm a lot. 2. The bot will re-render the README upon merge anyways, fixing that conflict automatically. 3. We could define a custom merge driver, but `union` is built into Git, meaning less configurations required downstream. Still, it doesn't seem to work in octopus merges. At least, if you do consecutive merges instead, all will work as expected. At the same time, I moved the hook to be the last. This is because previous hooks can reformat the files used to obtain the digest. [1]: https://git-scm.com/docs/gitattributes.html#Documentation/gitattributes.txt-union
As seen in OCA#190 (comment), when somebody tried to merge 2 PRs for the same module, chances are that both imply different readme digests and the merge fails. As seen in OCA#220 (comment), this was already happening under some circumstances with `requirements.txt` files. Here I added a `.gitattributes` file which specifies a `merge=union` driver for those files. [Git docs][1] explain that this driver will just keep the changes from all files, marking the merge as succeeded and not including merge markers. This is not ideal, but is OK for our current situation because: 1. Duplicate/conflicting lines in those files should not really harm a lot. 2. The bot will re-render the README upon merge anyways, fixing that conflict automatically. 3. We could define a custom merge driver, but `union` is built into Git, meaning less configurations required downstream. Still, it doesn't seem to work in octopus merges. At least, if you do consecutive merges instead, all will work as expected. At the same time, I moved the hook to be the last. This is because previous hooks can reformat the files used to obtain the digest. Closes OCA#220. [1]: https://git-scm.com/docs/gitattributes.html#Documentation/gitattributes.txt-union
As seen in OCA#190 (comment), when somebody tried to merge 2 PRs for the same module, chances are that both imply different readme digests and the merge fails. As seen in OCA#220 (comment), this was already happening under some circumstances with `requirements.txt` files. Here I added a `.gitattributes` file which specifies a `merge=union` driver for those files. [Git docs][1] explain that this driver will just keep the changes from all files, marking the merge as succeeded and not including merge markers. This is not ideal, but is OK for our current situation because: 1. Duplicate/conflicting lines in those files should not really harm a lot. 2. The bot will re-render the README upon merge anyways, fixing that conflict automatically. 3. We could define a custom merge driver, but `union` is built into Git, meaning less configurations required downstream. Still, it doesn't seem to work in octopus merges. At least, if you do consecutive merges instead, all will work as expected. At the same time, I moved the hook to be the last. This is because previous hooks can reformat the files used to obtain the digest. Closes OCA#220. [1]: https://git-scm.com/docs/gitattributes.html#Documentation/gitattributes.txt-union
As seen in OCA#190 (comment), when somebody tried to merge 2 PRs for the same module, chances are that both imply different readme digests and the merge fails. As seen in OCA#220 (comment), this was already happening under some circumstances with `requirements.txt` files. Here I added a `.gitattributes` file which specifies a `merge=union` driver for those files. [Git docs][1] explain that this driver will just keep the changes from all files, marking the merge as succeeded and not including merge markers. This is not ideal, but is OK for our current situation because: 1. Duplicate/conflicting lines in those files should not really harm a lot. 2. The bot will re-render the README upon merge anyways, fixing that conflict automatically. 3. We could define a custom merge driver, but `union` is built into Git, meaning less configurations required downstream. Still, it doesn't seem to work in octopus merges. At least, if you do consecutive merges instead, all will work as expected. At the same time, I moved the hook to be the last. This is because previous hooks can reformat the files used to obtain the digest. Closes OCA#220. [1]: https://git-scm.com/docs/gitattributes.html#Documentation/gitattributes.txt-union
As seen in OCA#190 (comment), when somebody tried to merge 2 PRs for the same module, chances are that both imply different readme digests and the merge fails. As seen in OCA#220 (comment), this was already happening under some circumstances with `requirements.txt` files. Here I added a `.gitattributes` file which specifies a `merge=union` driver for those files. [Git docs][1] explain that this driver will just keep the changes from all files, marking the merge as succeeded and not including merge markers. This is not ideal, but is OK for our current situation because: 1. Duplicate/conflicting lines in those files should not really harm a lot. 2. The bot will re-render the README upon merge anyways, fixing that conflict automatically. 3. We could define a custom merge driver, but `union` is built into Git, meaning less configurations required downstream. Still, it doesn't seem to work in octopus merges. At least, if you do consecutive merges instead, all will work as expected. At the same time, I moved the hook to be the last. This is because previous hooks can reformat the files used to obtain the digest. Closes OCA#220. [1]: https://git-scm.com/docs/gitattributes.html#Documentation/gitattributes.txt-union
As seen in OCA#190 (comment), when somebody tried to merge 2 PRs for the same module, chances are that both imply different readme digests and the merge fails. As seen in OCA#220 (comment), this was already happening under some circumstances with `requirements.txt` files. Here I added a `.gitattributes` file which specifies a `merge=union` driver for those files. [Git docs][1] explain that this driver will just keep the changes from all files, marking the merge as succeeded and not including merge markers. This is not ideal, but is OK for our current situation because: 1. Duplicate/conflicting lines in those files should not really harm a lot. 2. The bot will re-render the README upon merge anyways, fixing that conflict automatically. 3. We could define a custom merge driver, but `union` is built into Git, meaning less configurations required downstream. Still, it doesn't seem to work in octopus merges. At least, if you do consecutive merges instead, all will work as expected. At the same time, I moved the hook to be the last. This is because previous hooks can reformat the files used to obtain the digest. Closes OCA#220. [1]: https://git-scm.com/docs/gitattributes.html#Documentation/gitattributes.txt-union
As seen in OCA#190 (comment), when somebody tried to merge 2 PRs for the same module, chances are that both imply different readme digests and the merge fails. As seen in OCA#220 (comment), this was already happening under some circumstances with `requirements.txt` files. Here I added a `.gitattributes` file which specifies a `merge=union` driver for those files. [Git docs][1] explain that this driver will just keep the changes from all files, marking the merge as succeeded and not including merge markers. This is not ideal, but is OK for our current situation because: 1. Duplicate/conflicting lines in those files should not really harm a lot. 2. The bot will re-render the README upon merge anyways, fixing that conflict automatically. 3. We could define a custom merge driver, but `union` is built into Git, meaning less configurations required downstream. Still, it doesn't seem to work in octopus merges. At least, if you do consecutive merges instead, all will work as expected. At the same time, I moved the hook to be the last. This is because previous hooks can reformat the files used to obtain the digest. Closes OCA#220. [1]: https://git-scm.com/docs/gitattributes.html#Documentation/gitattributes.txt-union
This reverts commit a1551e5. Rational: The call of oca-gen-addon-readme will generate conflicts in the readme.rst file when 2 PRs modify the same module. See OCA#190 (comment)
As seen in OCA#190 (comment), when somebody tried to merge 2 PRs for the same module, chances are that both imply different readme digests and the merge fails. As seen in OCA#220 (comment), this was already happening under some circumstances with `requirements.txt` files. Here I added a `.gitattributes` file which specifies a `merge=union` driver for those files. [Git docs][1] explain that this driver will just keep the changes from all files, marking the merge as succeeded and not including merge markers. This is not ideal, but is OK for our current situation because: 1. Duplicate/conflicting lines in those files should not really harm a lot. 2. The bot will re-render the README upon merge anyways, fixing that conflict automatically. 3. We could define a custom merge driver, but `union` is built into Git, meaning less configurations required downstream. Still, it doesn't seem to work in octopus merges. At least, if you do consecutive merges instead, all will work as expected. At the same time, I moved the hook to be the last. This is because previous hooks can reformat the files used to obtain the digest. Closes OCA#220. [1]: https://git-scm.com/docs/gitattributes.html#Documentation/gitattributes.txt-union
Hi @yajo. I just used this new configuration that generate an up to date readme file on OCA/16.0 PR. First problem
I see that point as more a regression than an improvment :
Second Problem In a git point of view, the history of the README.rst file (and index.html file) will be polluted. I mean :
Do you know how to fix it ? CC : @sbidoul, @pedrobaeza |
Thanks for the investigation 😊 About problem 1, we have the same problem still today when adding a new module whose readme contains images stored in git. The solution would be to host those images away from git. The movements OCA seems to be doing in this regard is to allow functionals to edit those readme fragments with just markdown, and to allow drag and drop of images (and videos?). That uploads images to github CDN, which survives branch changes. About problem 2, I don't think it's important. Besides, if problem 1 is solved, problem 2 will be also as a side effect. |
Thanks for your answer !
yes. But the problem is bigger, with the recent change introduced by this PR. If now, a people make a PR against an existing module, changing the readme, all the url of images will be broken, making the readme less understandable. Before it was not the case.
I don't know how to do it simply... |
You just have to open some github issue and drag and drop the image into the comment box. Github will upload it and give you a URL. Then, remove the image from the git repo and change the URL to that one. I agree it's not very backwards-compatible. Maybe the convert-to-markdown tool in maintainer-tools could handle this? |
FTR
However, from now on I will use the workaround that is actually used by many repo: set |
@simahawk looks similar to acsone/setuptools-odoo#55 😇 Anyway given the amount of trouble people have with this feature, I'd be inclined to disable it. |
Only 2 persons have commented to have troubles about this, Sylvain and Simone, so that's not a lot. And the issue functional people have reviewing PRs with an outdated README is real. |
... and Simone's error is not related, BTW. It's just an installation problem. In any case, I agree with @pedrobaeza. For us, this feature has a lot of value. It means more autonomy for the functional members of our team. However, I'm open to other solutions for the same problem. These come to my mind:
|
Devs sometimes just update the
readme/*.rst
portions, relying in our nice bot that will convert that to a realREADME.rst
+index.html
after merge.When functional people go test PRs in runboat, the 1st thing they look at is the README. That's OK because there's where the docs should explain what the module is doing.
These 2 situations are good in their own terms, but when you merge both, you get to a problem. You have to either:
readme/
folder and understand the.rst
syntax and the advanced github diff tooling.oca-gen-addon-readme
before pushing the PR, so functionals can review the README in a more human-friendly fashion.None of these is a good solution. Both add manual and complex steps to the contribution workflow.
Quoting from OCA blog:
This PR goes along with those goals. By moving the readme generation into a pre-commit hook:
@moduon