Page MenuHomePhabricator

[toolforge-cd] minimize test repetitions from merge request ci/cd pipelines
Open, LowPublic

Description

Right now the ci/cd pipelines run pre-commit and blubber tests three scenarios for a patch:

  1. when a patch is submitted or modified
  2. when a patch is merged
  3. again after the pipeline is merged

Scenario 3 is a bug and we have a task for it here https://phabricator.wikimedia.org/T353563

Scenario 2 (when a patch is merged into main) doesn't seem to make sense because the patch has already been merged.

This task is about running the pre-commit and blubber tests only in Scenario 1 (when a patch is submitted or modified)

Event Timeline

After a patch is merged into master, It doesn't seem to make sense to run the tests again because the patch has already been merged. Because of this I propose we find a way to only run pre-commit once, that is when a patch is submitted or modified.

This would be ok if we enforce rebasing before merging, otherwise the patch that is being tested might not be the same that will end up in the repository (as it will either create a merge commit, or rebase automatically after testing).

I'm ok doing so, but given that we did not agree before we might want to re-raise it again. I think that avoiding extra test runs is a good plus btw.

Another strategy that would help avoid extra tests, is avoid creating stacked merge requests, specially if the commits depend on each other (or do not add anything individually), as that would create a whole pipeline with images included for each commit. Instead we can bundle the related/dependent commits in a single MR (again, exercising moderation and avoid creating big MRs).

this seems like something that requires the opinion of everyone. Does this warrant a decision request or we can just discuss it in one of the toolforge council meetings?

this seems like something that requires the opinion of everyone. Does this warrant a decision request or we can just discuss it in one of the toolforge council meetings?

I guess that it might depend on what are you proposing to change xd
If it involves changing the development flows for everyone then we can move to a decision request (even if everyone agrees and it's just to gather input).

But before that, I would try to elaborate a bit more on the problem and the proposed changes (ex. it's not clear if the porposed change here is just skip testing on merge, or also forcing rebasing before merging).

If you have a clear idea of the changes you want, you can just write them all down on the task here.

If you don't have a clear idea of the changes, I'd start by writing down as much as you know of the problem you want to solve, and sharing that in a toolforge meeting/email/team meeting/etc.
That should help you brainstorm on solutions and finally come up with a proposal.

Raymond_Ndibe updated the task description. (Show Details)
Raymond_Ndibe updated the task description. (Show Details)
Raymond_Ndibe updated the task description. (Show Details)

After a patch is merged into master, It doesn't seem to make sense to run the tests again because the patch has already been merged. Because of this I propose we find a way to only run pre-commit once, that is when a patch is submitted or modified.

This would be ok if we enforce rebasing before merging, otherwise the patch that is being tested might not be the same that will end up in the repository (as it will either create a merge commit, or rebase automatically after testing).

I'm ok doing so, but given that we did not agree before we might want to re-raise it again. I think that avoiding extra test runs is a good plus btw.

Another strategy that would help avoid extra tests, is avoid creating stacked merge requests, specially if the commits depend on each other (or do not add anything individually), as that would create a whole pipeline with images included for each commit. Instead we can bundle the related/dependent commits in a single MR (again, exercising moderation and avoid creating big MRs).

thinking a bit more about this, I'm struggling to understand the concern here @dcaro.

so right now, when you create a branch locally from an up-to-date main branch, makes changes to the branch and create a MR, the new branch is ahead of main by 1 commit and main is head of the new branch by 0 commits. In this case there is no need for a rebase (rebase here will be no-op) if you decide to merge immediately after ci/cd pipeline runs.

if another MR is merged into main before we manage to merge our new MR, then now our branch is ahead of main by 1 commit and main is ahead of our branch by 1..n commits. Here we need to rebase, but then in this case we already get this prompt from gitlab that says Merge blocked: the source branch must be rebased onto the target branch. As a result we won't be able to merge this unless we rebase.

So why do we need to enforce another kind of rebase if we already have rebasing built into our current workflow?
It seems to me like we can remove scenario 3 and scenario 2 and only run pre-commit and blubber tests when the MR is created or modified, and all will be well in the world.

did I miss something?

dcaro triaged this task as Medium priority.Feb 7 2024, 10:11 AM

After a patch is merged into master, It doesn't seem to make sense to run the tests again because the patch has already been merged. Because of this I propose we find a way to only run pre-commit once, that is when a patch is submitted or modified.

This would be ok if we enforce rebasing before merging, otherwise the patch that is being tested might not be the same that will end up in the repository (as it will either create a merge commit, or rebase automatically after testing).

I'm ok doing so, but given that we did not agree before we might want to re-raise it again. I think that avoiding extra test runs is a good plus btw.

Another strategy that would help avoid extra tests, is avoid creating stacked merge requests, specially if the commits depend on each other (or do not add anything individually), as that would create a whole pipeline with images included for each commit. Instead we can bundle the related/dependent commits in a single MR (again, exercising moderation and avoid creating big MRs).

thinking a bit more about this, I'm struggling to understand the concern here @dcaro.

so right now, when you create a branch locally from an up-to-date main branch, makes changes to the branch and create a MR, the new branch is ahead of main by 1 commit and main is head of the new branch by 0 commits. In this case there is no need for a rebase (rebase here will be no-op) if you decide to merge immediately after ci/cd pipeline runs.

if another MR is merged into main before we manage to merge our new MR, then now our branch is ahead of main by 1 commit and main is ahead of our branch by 1..n commits. Here we need to rebase, but then in this case we already get this prompt from gitlab that says Merge blocked: the source branch must be rebased onto the target branch. As a result we won't be able to merge this unless we rebase.

So why do we need to enforce another kind of rebase if we already have rebasing built into our current workflow?
It seems to me like we can remove scenario 3 and scenario 2 and only run pre-commit and blubber tests when the MR is created or modified, and all will be well in the world.

did I miss something?

That message is not a policy in all the repositories, only on a few of them where I set it explictly as we decided some time ago not to enforce any specific flow (create merge commit, squash, rebase before merge, ...).

And I think we don't enforce the tests passing on many repos either (for the same reasons).

That's why I said " This would be ok if we enforce rebasing before merging", as we do not currently.

After a patch is merged into master, It doesn't seem to make sense to run the tests again because the patch has already been merged. Because of this I propose we find a way to only run pre-commit once, that is when a patch is submitted or modified.

This would be ok if we enforce rebasing before merging, otherwise the patch that is being tested might not be the same that will end up in the repository (as it will either create a merge commit, or rebase automatically after testing).

I'm ok doing so, but given that we did not agree before we might want to re-raise it again. I think that avoiding extra test runs is a good plus btw.

Another strategy that would help avoid extra tests, is avoid creating stacked merge requests, specially if the commits depend on each other (or do not add anything individually), as that would create a whole pipeline with images included for each commit. Instead we can bundle the related/dependent commits in a single MR (again, exercising moderation and avoid creating big MRs).

thinking a bit more about this, I'm struggling to understand the concern here @dcaro.

so right now, when you create a branch locally from an up-to-date main branch, makes changes to the branch and create a MR, the new branch is ahead of main by 1 commit and main is head of the new branch by 0 commits. In this case there is no need for a rebase (rebase here will be no-op) if you decide to merge immediately after ci/cd pipeline runs.

if another MR is merged into main before we manage to merge our new MR, then now our branch is ahead of main by 1 commit and main is ahead of our branch by 1..n commits. Here we need to rebase, but then in this case we already get this prompt from gitlab that says Merge blocked: the source branch must be rebased onto the target branch. As a result we won't be able to merge this unless we rebase.

So why do we need to enforce another kind of rebase if we already have rebasing built into our current workflow?
It seems to me like we can remove scenario 3 and scenario 2 and only run pre-commit and blubber tests when the MR is created or modified, and all will be well in the world.

did I miss something?

That message is not a policy in all the repositories, only on a few of them where I set it explictly as we decided some time ago not to enforce any specific flow (create merge commit, squash, rebase before merge, ...).

And I think we don't enforce the tests passing on many repos either (for the same reasons).

That's why I said " This would be ok if we enforce rebasing before merging", as we do not currently.

I think I got what you mean @dcaro.
however I searched for the our last decision request on gitlab workflow and this was what I saw https://phabricator.wikimedia.org/T321798.
According to that decision request we agreed to have a squash + fastforward merge workflow which I think requires rebasing to happen right ? (let me know if I am wrong)
If that is the case then we are not keeping to the decision request for any cloud repository that doesn't currently have that workflow enforced.
I don't think we need another decision request @dcaro since the problem has already been addressed in the above linked decision request. We only have to implement the decision.

wdyt @dcaro ? Am I missing something?

the decision to enforce/not enforce tests passing in the ci/cd is a different thing and doesn't affect what is being proposed in this task.

I think I got what you mean @dcaro.
however I searched for the our last decision request on gitlab workflow and this was what I saw https://phabricator.wikimedia.org/T321798.
According to that decision request we agreed to have a squash + fastforward merge workflow which I think requires rebasing to happen right ? (let me know if I am wrong)

Unfortunately, the 'fast-forward-merge only' on gitlab does not mean that you have to rebase your MR before getting it merged on the main, it means that it will try to rebase on the fly while merging it, and only force you to rebase the MR first if there's any conflicts;

Fast-forward merge

No merge commits are created.
Fast-forward merges only.
When there is a merge conflict, the user is given the option to rebase.
If merge trains are enabled, merging is only possible if the branch can be rebased without conflicts. What are merge trains?

So it's still possible that the tests are not run on the rebased MR, but only in the pre-rebased one if there's no conflict when rebasing (thus having untested code merged into main). :/

I think I got what you mean @dcaro.
however I searched for the our last decision request on gitlab workflow and this was what I saw https://phabricator.wikimedia.org/T321798.
According to that decision request we agreed to have a squash + fastforward merge workflow which I think requires rebasing to happen right ? (let me know if I am wrong)

Unfortunately, the 'fast-forward-merge only' on gitlab does not mean that you have to rebase your MR before getting it merged on the main, it means that it will try to rebase on the fly while merging it, and only force you to rebase the MR first if there's any conflicts;

Fast-forward merge

No merge commits are created.
Fast-forward merges only.
When there is a merge conflict, the user is given the option to rebase.
If merge trains are enabled, merging is only possible if the branch can be rebased without conflicts. What are merge trains?

So it's still possible that the tests are not run on the rebased MR, but only in the pre-rebased one if there's no conflict when rebasing (thus having untested code merged into main). :/

Ok, I'm going to ask a question:

  • in your opinion do you think this is something worth pursuing? do you think the time we'd save by running less number of tests is worth the effort we have to put in to enforce the rebase rule?

If this doesn't seem like something we should spend our time on then we can just close this task. If it is, then I think we probably need another decision request to address this particular case.

Ok, I'm going to ask a question:

  • in your opinion do you think this is something worth pursuing? do you think the time we'd save by running less number of tests is worth the effort we have to put in to enforce the rebase rule?

If this doesn't seem like something we should spend our time on then we can just close this task. If it is, then I think we probably need another decision request to address this particular case.

There's many aspects to balance out to answer that question, and none of them is absolute.
From my point of view, is something that it's not an issue yet, but it's likely to become one in the future. I'm pretty busy myself with other more urgent things, so it's something that I would not do right now unless I wanted to (ie. I wanted to learn from it/play with it/ or just scratch an itch).

That might be your case though, so feel free to tackle it.

I do think that this is a bit more complex to solve than what you had in mind (just removing the tests), so you might want to reconsider if you want to dedicate the time needed to fix it with that new information.

On the specifics of the solution, I don't have one myself, the flow would be:
Create MR -> ensure MR is rebased -> test MR -> merge

Usually, to make sure that works, there's what's called 'mr train' or other asynchronous process, that lets automation do the actual merge (like when we +2 stuff on gerrit), so it becomes:
create MR -> flag for merge -> automation picks it up + rebase + test -> automation closes MR and pushes to main

All that given that there's no way to force MRs to be always manually rebased before merging.

Ok. My initial thought was that we can just make a few changes to the gitlab-ci repo and have it only run tests once, but this issue of enforcing rebase means it'd be much more complex than that so maybe not what we should be doing right now.
I think we should still leave the task open but deprioritize it (remove from current iteration)

Raymond_Ndibe renamed this task from [toolforge-cd] discuss the possibility of removing tests from merge request ci/cd pipelines to [toolforge-cd] discuss the possibility of eliminating test repetitions from merge request ci/cd pipelines.Feb 13 2024, 8:01 AM
dcaro renamed this task from [toolforge-cd] discuss the possibility of eliminating test repetitions from merge request ci/cd pipelines to [toolforge-cd] minimize test repetitions from merge request ci/cd pipelines.Feb 13 2024, 9:29 AM
dcaro lowered the priority of this task from Medium to Low.