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

fix(oca-gen-addon-readme): reduce unneeded merge conflicts #222

Closed
wants to merge 5 commits into from

Conversation

yajo
Copy link
Member

@yajo yajo commented Oct 31, 2023

As seen in #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 #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 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 #220.

@@ -235,3 +229,12 @@ repos:
args:
- --rcfile=.pylintrc-mandatory
{%- endif %}
- <<: *maintainer_tools
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure to understand this syntax.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's reusing the anchor defined above. Check this out: https://www.linode.com/docs/guides/yaml-anchors-aliases-overrides-extensions/

@legalsylvain
Copy link
Contributor

Thanks a lot for your investigation and your PR ! I'll try this code in the oca days.

@yajo yajo force-pushed the no-readme-generator-conflicts branch 2 times, most recently from 156fc10 to 2b572e2 Compare October 31, 2023 11:31
@yajo yajo force-pushed the no-readme-generator-conflicts branch 7 times, most recently from 0eded17 to 3c606b2 Compare November 9, 2023 08:23
@yajo yajo marked this pull request as draft November 9, 2023 08:45
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
Just install all required pythons and let pytest-xdist handle parallelization by itself.
@yajo yajo force-pushed the no-readme-generator-conflicts branch from 1cd51e7 to cd3af75 Compare November 9, 2023 09:32
@yajo yajo force-pushed the no-readme-generator-conflicts branch from fb50bab to 453081d Compare November 9, 2023 09:44
@yajo yajo marked this pull request as ready for review November 9, 2023 09:49
@yajo
Copy link
Member Author

yajo commented Nov 9, 2023

Hi there. This one is ready to merge.

I was having problems because the tests were run under python 3.8 but pre-commit needed python 3.6. I had to pin an older virtualenv version because the latest one doesn't support python 3.6 anymore.

Long story short, now we don't issue a matrix of builds. Instead, we install all required python interpreters in a single build and parallelize at pytest level with pytest-xdist. Thus, now there's just one "test" job.

Since there's just that job, the CI checks will stay as "Required statuses must pass before merging" because I changed the way CI is handled here.

If nobody's against this, I'll merge it so we can unblock the situation explained at #220 (comment).

@sbidoul
Copy link
Member

sbidoul commented Nov 9, 2023

@legalsylvain have you tested this?

@sbidoul
Copy link
Member

sbidoul commented Nov 11, 2023

I'm proposing using OCA/maintainer-tools#588 as an alternative.

@yajo
Copy link
Member Author

yajo commented Nov 13, 2023

I still think this is a better solution.

Multiple PRs can modify instructions in the readme folder. If those conflict, there's no other solution than to solve it. But if the conflict happens in the README, we shouldn't care when merging, as the bot would re-trigger the generation after merge.

Also this PR refactors the test suite in a more future-proof way (that can be extracted separately, of course).

So IMHO this still has its benefits and we should merge this.

@sbidoul
Copy link
Member

sbidoul commented Nov 13, 2023

Also this PR refactors the test suite in a more future-proof way (that can be extracted separately, of course).

👍 for that

Regarding the union merge, I think it may be fine for requirements.txt (although I have not personally witnessed such conflicts in practice).

For README.rst/index.hml, I'm not sure. The drawbacks you mention in the OP don't seem to be worth the gain.

@yajo
Copy link
Member Author

yajo commented Nov 15, 2023

OK, nevermind. We can come back to this later if needed.

@yajo yajo closed this Nov 15, 2023
@yajo yajo deleted the no-readme-generator-conflicts branch November 15, 2023 13:16
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