Skip to content

Drive PR sync team checks and welcome messages from repo_config - #378

Open
lykimq wants to merge 10 commits into
masterfrom
quyen@bot_generic_pr6
Open

lykimq wants to merge 10 commits into
masterfrom
quyen@bot_generic_pr6

Conversation

@lykimq

@lykimq lykimq commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Drive PR sync, merge, and comment-command team checks from repo_config instead of Rocq hardcodes.

  • Gate the welcome message on contributing_url (skip when absent)
  • Resolve org / teams / alert mentions from config (trigger_ci, merge_pr, alert_mention)
  • Thread config into run-ci, merge now, and bench command handling
  • Add Alcotest coverage for team helpers and welcome gating

@lykimq
lykimq requested a review from Zimmi48 August 4, 2026 10:13
@lykimq
lykimq force-pushed the quyen@bot_generic_pr6 branch from 15dc0a1 to e807add Compare August 31, 2026 09:11

@Zimmi48 Zimmi48 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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).

Comment on lines +363 to +366
"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 )

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Technically, these messages are quite specific to the repo as well and could become part of the parameters.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +113 to +115
"@%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."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread src/actions/pr_sync.ml Outdated
then (
match repo_config with
| Some cfg
when Option.is_some (Repo_config.team_for_permission cfg "trigger_ci")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread src/actions/pr_sync.ml Outdated
Comment on lines +231 to +234
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)."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The whole message could probably be passed as a parameter instead of just the link.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread src/config/repo_config.ml Outdated
| Some team ->
Some (f "@%s/%s" (project_organization cfg) team)

let should_send_welcome_message cfg ~same_branch_name ~opened =

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread src/webhooks/github.ml
@@ -127,10 +130,7 @@ let handle_comment_created ~bot_info ~key ~app_id ~github_bot_name
( f "@%s:? [Rr]un \\(full\\|light\\|\\) ?[Cc][Ii]"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread src/webhooks/github.ml
~body:"Ignoring merge request: no repo_config." ()
else if
string_match
~regexp:(f "@%s:? [Bb]ench native" @@ Str.quote github_bot_name)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread src/webhooks/github.ml
~body:"Ignoring run CI request: trigger_ci not configured." ()
else if
string_match
~regexp:(f "@%s:? [Mm]erge now" @@ Str.quote github_bot_name)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@Zimmi48 Zimmi48 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Feel free to self-merge or re-request a review from me.

Comment on lines +367 to +371
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 )

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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 \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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)?

Comment thread src/config/repo_config.ml
| Some team ->
Some (f "@%s/%s" (project_organization cfg) team)

let should_warn_same_branch_name cfg ~same_branch_name ~opened =

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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?

Comment thread src/config/repo_config.ml
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 =

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

team_mention is only used in tests. It was probably meant to be used in the messages that build @%s/%s by hand.

Comment thread src/actions/pr_sync.ml
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." ()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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).

Comment thread src/actions/pr_sync.ml
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"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Comment thread src/utils/bench.ml
| Some _ -> (
let artifact_url file =
(* gitlab_pages_artifact_url already succeeded for this config. *)
Option.value_exn

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Comment thread src/webhooks/github.ml
| _ ->
Server.respond_string ~status:`OK
~body:
"Ignoring bench native request: bench_native_variables or \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Comment on lines +83 to +90
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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 *)

Comment thread coqbot-config.toml
Comment on lines +57 to +59
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}).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

To keep the comment the same:

Suggested change
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}).

@Zimmi48

Zimmi48 commented Oct 16, 2026

Copy link
Copy Markdown
Member

BTW, a generic remark is that we might want to document all these configurable options now that they exist.

lykimq and others added 10 commits November 2, 2026 09:18
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
…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
@lykimq
lykimq force-pushed the quyen@bot_generic_pr6 branch from 49cc9b6 to e913cf8 Compare November 2, 2026 08:19
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.

2 participants