Repository navigation
Conversation
15dc0a1 to
e807add
Compare
Zimmi48
left a comment
There was a problem hiding this comment.
Thanks!
I believe this goes in the right direction, but there are a few places where this kind of stops in the middle, e.g., because the feature can now be configured for any repo, but some of its actual actions are still too specific to be applicable anywhere else. See detailed comments below (two of them generated by an AI that I used to make sure I was not missing anything).
| "Sorry, @%s, I only accept requests from members of the `@%s/%s` \ | ||
| team. If you are a regular contributor, you can request to join the \ | ||
| team by asking any core developer." | ||
| comment_info.author org team ) |
There was a problem hiding this comment.
Technically, these messages are quite specific to the repo as well and could become part of the parameters.
| "@%s: You can't merge this PR because you're not a \ | ||
| member of the `@rocq-prover/pushers` team. Look at \ | ||
| the contributing guide for how to join this team." | ||
| comment_info.author ) | ||
| member of the `@%s/%s` team. Look at the \ | ||
| contributing guide for how to join this team." |
| then ( | ||
| match repo_config with | ||
| | Some cfg | ||
| when Option.is_some (Repo_config.team_for_permission cfg "trigger_ci") |
There was a problem hiding this comment.
The part below is really specific to the Rocq repo, not something that could apply to any repo having a trigger_ci team set up.
| In the future, we strongly recommend that you *do not* use %s \ | ||
| as the name of your branch when submitting a pull request.\n\ | ||
| By the way, you may be interested in reading [our contributing \ | ||
| guide](https://github.com/rocq-prover/rocq/blob/master/CONTRIBUTING.md)." | ||
| pr_info.base.branch.name ) | ||
| guide](%s)." |
There was a problem hiding this comment.
The whole message could probably be passed as a parameter instead of just the link.
| | Some team -> | ||
| Some (f "@%s/%s" (project_organization cfg) team) | ||
|
|
||
| let should_send_welcome_message cfg ~same_branch_name ~opened = |
There was a problem hiding this comment.
Maybe we should call this differently, given that the trigger is quite different from what other projects usually use for welcome messages (typically: always sent for first-time contributions).
| @@ -127,10 +130,7 @@ let handle_comment_created ~bot_info ~key ~app_id ~github_bot_name | |||
| ( f "@%s:? [Rr]un \\(full\\|light\\|\\) ?[Cc][Ii]" | |||
There was a problem hiding this comment.
Similarly to my previous comment, the full/light aspect is pretty specific to the Rocq project. But it could simply be ignored for other projects for now.
| ~body:"Ignoring merge request: no repo_config." () | ||
| else if | ||
| string_match | ||
| ~regexp:(f "@%s:? [Bb]ench native" @@ Str.quote github_bot_name) |
There was a problem hiding this comment.
This one (bench/bench native) is still pretty specific.
Generated by Claude Sonnet 5: This function is now reachable for any repo satisfying trigger_ci + gitlab_domain, but the regex used to extract the GitLab build/project id still hardcodes gitlab.inria.fr/coq/coq literally (Str.quote "[bench](https://gitlab.inria.fr/coq/coq/-/jobs/"), and fetch_bench_results/update_bench_status hardcode coq.gitlabpages.inria.fr / gitlab.inria.fr/coq/coq for artifact and job URLs regardless of the passed gitlab_domain. A second repo satisfying the new generic gate would fail here. Also, key_value_pairs:[("coq_native", "yes")] for the "bench native" command (in webhook.ml) is a Coq-specific GitLab CI variable reachable through this same generic path.
| ~body:"Ignoring run CI request: trigger_ci not configured." () | ||
| else if | ||
| string_match | ||
| ~regexp:(f "@%s:? [Mm]erge now" @@ Str.quote github_bot_name) |
There was a problem hiding this comment.
Generated by Claude Sonnet 5: merge_pull_request_action now takes ~org ~pushers_team ?alert_mention, implying it's meant to work for any repo with a merge_pr team, but it still hardcodes not (String.equal reviews_info.baseRef "master") (assumes master is the only mergeable branch name) and the post-merge overlay check dev/ci/user-overlays/(.*), which is Rocq's specific CI-overlay convention. Neither is derived from repo_config, so a second repo enabling merge_pr would inherit Rocq-specific branch-name assumptions and irrelevant overlay reminders.
Zimmi48
left a comment
There was a problem hiding this comment.
Feel free to self-merge or re-request a review from me.
| let inform_user_not_in_contributors ~bot_info ~org ~team ~comment_info = | ||
| GitHub_mutations.post_comment ~bot_info ~id:comment_info.issue.id | ||
| ~message: | ||
| (f | ||
| "Sorry, @%s, I only accept requests from members of the \ | ||
| `@rocq-prover/contributors` team. If you are a regular contributor, \ | ||
| you can request to join the team by asking any core developer." | ||
| comment_info.author ) | ||
| (f "Sorry, @%s, I only accept requests from members of the `@%s/%s` team." | ||
| comment_info.author org team ) |
There was a problem hiding this comment.
We can probably make this check more generic to target any team. (And also use it in the case of the merge check.) And make it configurable so that the fallback message depends on the repo/team.
Then it would allow keeping repo-specific guidance such as how to join the team.
| `dev/tools/merge-pr.sh` script to merge this PR. Merging \ | ||
| with the bot is not supported yet." | ||
| comment_info.author reviews_info.baseRef ) | ||
| "@%s: This PR targets branch `%s` instead of `%s`. The bot \ |
There was a problem hiding this comment.
This drops the Rocq-specific guidance (only release managers can merge in release branches, use dev/tools/merge-pr.sh), so it is a behavior change for rocq-prover/rocq. Similar to my other comment, could the repo-specific part of this message come from the configuration (e.g., an optional extra text appended to the generic message)?
| | Some team -> | ||
| Some (f "@%s/%s" (project_organization cfg) team) | ||
|
|
||
| let should_warn_same_branch_name cfg ~same_branch_name ~opened = |
There was a problem hiding this comment.
The test for cfg.same_branch_warning is already part of format_same_branch_warning, so maybe this function can be removed and replaced by a check String.equal base head and a match on the format_same_branch_warning return value?
| List.find_map cfg.teams ~f:(fun t -> | ||
| if String.equal t.permission permission then Some t.team_name else None ) | ||
|
|
||
| let team_mention cfg ~permission = |
There was a problem hiding this comment.
team_mention is only used in tests. It was probably meant to be used in the messages that build @%s/%s by hand.
| match Repo_config.team_for_permission repo_config "trigger_ci" with | ||
| | None -> | ||
| Server.respond_string ~status:`OK | ||
| ~body:"Ignoring run CI request: no trigger_ci team configured." () |
There was a problem hiding this comment.
This branch is unreachable since github.ml already checks that a trigger_ci team is configured before calling run_ci_action. Maybe keep only one of the two checks (e.g., have run_ci_action take the team as an argument).
| let org = Repo_config.project_organization cfg in | ||
| let* config_modified = | ||
| git_test_modified ~base:pr_info.base.sha ~head:pr_info.head.sha | ||
| ".*gitlab.*\\.yml" |
There was a problem hiding this comment.
Now that this check applies to any repo with a trigger_ci team, the .*gitlab.*\.yml pattern is still Rocq-specific (and the comment above still talks about the Rocq Prover repo). Should the pattern for CI configuration files be configurable as well?
Similarly, in the not can_trigger_ci branch below, adding needs_full_ci_label only makes sense for repos with use_rocq_ci_options: other repos with a trigger_ci team would get this label added.
| | Some _ -> ( | ||
| let artifact_url file = | ||
| (* gitlab_pages_artifact_url already succeeded for this config. *) | ||
| Option.value_exn |
There was a problem hiding this comment.
Calling gitlab_pages_artifact_url once to check it is Some and then calling it again with Option.value_exn for each file is a bit convoluted. Instead, gitlab_pages_artifact_url cfg ~job_id could return (artifact:string -> string) option, so that the configuration is checked once and the caller gets a URL builder in the Some case.
| | _ -> | ||
| Server.respond_string ~status:`OK | ||
| ~body: | ||
| "Ignoring bench native request: bench_native_variables or \ |
There was a problem hiding this comment.
Note that for a repo with bench_job but without bench_native_variables, @coqbot bench native is now ignored, whereas it would previously have fallen through to the plain bench branch (since [Bb]ench also matches). As I'm not the author of this code, I don't know what is the right choice here.
| else if | ||
| match mergeable_base_branch with | ||
| | Some expected -> | ||
| not (String.equal reviews_info.baseRef expected) | ||
| | None -> | ||
| false | ||
| then | ||
| let expected = Option.value_exn mergeable_base_branch in |
There was a problem hiding this comment.
Instead of this pattern, you could do:
else
match mergeable_base_branch with
| Some expected
when not (String.equal reviews_info.baseRef expected) ->
(* the else if case *)
| _ ->
(* the else case *)| Hello, thanks for your pull request! | ||
| Please avoid using {base_branch} as the name of your head branch when it matches the base branch. | ||
| You may want to read the [contributing guide]({contributing_url}). |
There was a problem hiding this comment.
To keep the comment the same:
| Hello, thanks for your pull request! | |
| Please avoid using {base_branch} as the name of your head branch when it matches the base branch. | |
| You may want to read the [contributing guide]({contributing_url}). | |
| Hello, thanks for your pull request! | |
| In the future, we strongly recommend that you *do not* use {base_branch} as the name of your branch when submitting a pull request. | |
| By the way, you may be interested in reading [our contributing guide]({contributing_url}). |
|
BTW, a generic remark is that we might want to document all these configurable options now that they exist. |
Replace Rocq hardcodes in PR sync, merge, and comment with org/team/alert/contributing_url and gitlab_domain from repo config
…uld_send_welcome_message with and without contributing_url
…ts in coqbot-config.toml
…er hardcoded Rocq, rename should_send_welcome_message to should_warn_same_branch_name
…therwise it is forced to None, so non-Rocq repos just get a normal run-CI
… requires bench_job, bench_native only runs when bench_native_variables is configured
49cc9b6 to
e913cf8
Compare
Drive PR sync, merge, and comment-command team checks from repo_config instead of Rocq hardcodes.