-
Notifications
You must be signed in to change notification settings - Fork 136
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
Add create-pipeline and job-regexp options #114
base: master
Are you sure you want to change the base?
Conversation
create-pipeline: If for some reason no valid pipeline is found for the MR (none exists, outdated, etc.), Marge will create a new one using the api. She will also leave a message, so she can know that she already created a pipeline and will not do it again and again. Default is false. job-regexp: The CI may be configured to run different jobs depending on the branch name, or pipeline source (push, trigger, api...). Marge will check the jobs in the current pipeline against this regexp. If any job matches the regexp, it's considered good and the status is checked as usual. If none matches, it's not a valid pipeline and either the merge will fail or a new pipeline will be created (see create-pipeline). If using both create-pipeline and job-regexp, make sure the important jobs are configured to run on "api" sources (see the "only" and "except" options of GitLab CI), so that the pipeline created by Marge will be valid.
By default GitLab turns the sha into a link to a diff inside the merge request, but we want a link to the plain commit.
I'm a bit confused by this. If you have set up your pipelines as intended in Github, why would something like this be needed on the marge side? Can you explain a bit more? |
What is "as intended in Github" (I guess you meant GitLab)? If "as intended" means that every push should create a pipeline that runs all jobs needed for verification, then right, this would not be needed. The point of this PR is to allow more flexible pipeline configuration. For example:
My use case is the second. I don't want to run the expensive tests for every push, and I don't want to require special names for MR branches. With these options, one can push to any branch, have basic sanity tests run, create a MR and, once it's assigned to marge, she will make sure the expensive tests are run before accepting the MR. The developer can also run the expensive tests locally before pushing. |
[Yeah, meant Gitlab, sorry] OK, I think I understand now: you want branches that are PRs to run special pipelines (too expensive to run on all branches), correct? I agree that's highly desirable functionality Gilab appears to agree in principle as well, but it doesn't look like they're gonna get around implementing it soon. For self-hosted gitlab instances there's a plugin snippet you could use in the issue linked above, but that won't help you if you're running on gitlab.com. So I'm sympathetic to adding some kludge to marge-bot in the interim. One thing that I'm not super-happy about is that as far as I can tell, there is no good way to deal with cheap pipeline for normal branches, expensive ones for (final) MR check before merging. If you're job regex fails to find the required job in the existing pipeline (if any) you trigger a new pipeline run. But in what cases would this actually help if there already has been a pipeline running for the sha? If it didn't have the required jobs, presumably the new one wouldn't either? Maybe I'm overlooking something that selects the desired jobs, but it seems the best you could do with this create pipeline functionality is have only one expensive pipeline which you trigger with marge, but only for MRs and never run any pipeline on normal branches. Is that right? |
Thinking about it, the way forward with this would probably to do something similar like we're doing for (In particular this also will still still work if you have flags active which create trailers, but you can't push to the MR repo) |
The way to ensure pipelines created by marge contain the required jobs is with proper CI configuration, with the If the configuration is broken and the new pipeline does not contain the required jobs, marge will detect she tried to run a pipeline already, and won't try again. |
As for "synthetic" MRs (I guess you meant to refer to #113), I guess it could be possible to use temporary branches as with the batch job, and configure the expensive jobs with them. There wouldn't be much difference, except for the creation of additional branches. I worked on this before the batch option was available, so I didn't really look at it... and I actually think simply creating a pipeline is cleaner. |
Cool, I didn't know that you could configure api-created pipelines differently! Yup, that makes it much more attractive. I still suspect the way to go is the generalize our use of temporary branches because it solves several problems in one fell swoop:
In particular the last one would be completely free and this PR and the associated extra flags and code would become redundant. Anyway, I think we'll need to think a bit how to best go about it, but this is something I'd like to support. |
Regardless of how it is implemented, I think something similar to the job-regexp option I propose is needed. Marge should not blindly accept any pipeline result she gets without checking that it has tested what it was supposed to test. While that is probably the responsibility of the repository owner/manager, it is too easy to miss something sooner or later. |
01534b3
to
ac94f36
Compare
This addresses #107, and replaces #109 (changing source branch)
create-pipeline
: If for some reason no valid pipeline is found for the MR (none exists, outdated, etc.), Marge will create a new one using the api. She will also leave a message, so she can know that she already created a pipeline and will not do it again and again. Default is false.job-regexp
: The CI may be configured to run different jobs depending on the branch name, or pipeline source (push, trigger, api...). Marge will check the jobs in the current pipeline against this regexp. If any job matches the regexp, it's considered good and the status is checked as usual. If none matches, it's not a valid pipeline and either the merge will fail or a new pipeline will be created (seecreate-pipeline
).If using both
create-pipeline
andjob-regexp
, make sure the important jobs are configured to run onapi
sources (see theonly
andexcept
options of GitLab CI), so that the pipeline created by Marge will be valid.