Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
6b712fa
chore: move src/helpers to bot-components/Utils
Nov 3, 2025
e397b35
chore: move generic functions in actions to more suitable modules in …
Nov 3, 2025
e9c9b3a
chore: continue to split CI_utils, add new file Bench_utils for bench…
Nov 4, 2025
db68a84
chore: move generic functions in actions to bot-components, and call …
Nov 4, 2025
eace7e7
chore: remove string_of_installation_tokens, it is unused, format com…
Nov 4, 2025
e10e4d8
chore: add TODO comments at places with the legacy method PAT install…
coqbot Nov 5, 2025
55ed981
test: set up and add alcotest before remove the legacy installation
Nov 5, 2025
bc55abe
test: fix the mistaken in test_bot_info, add tests for webhook with i…
Nov 5, 2025
97a3bf1
feat: remove the legacy installation PAT
lykimq Nov 5, 2025
3b74313
test: update tests with the removal of legacy installation PAT
lykimq Nov 5, 2025
80b65c1
docs: mentioned PAT no longer support, remove the entire related to P…
lykimq Nov 5, 2025
600d086
feat: remove github.api_token configuration option
lykimq Nov 5, 2025
23d9b32
refactor: organize src into different modules
lykimq Nov 10, 2025
1858893
refactor: organize src into different modules
lykimq Nov 10, 2025
6056778
style: format code
lykimq Nov 11, 2025
35cceac
feat: add functions handle repo configuration
lykimq Nov 11, 2025
6db4b14
tests: add Alcotest for repo_config
lykimq Nov 11, 2025
8dedd1c
test: add test for config error cases and add property test for integer
lykimq Nov 11, 2025
8d6de95
test: add property-base tests by loading the test-config.toml
lykimq Nov 11, 2025
5ab2aab
feat: add repo-specification config
lykimq Nov 11, 2025
e32ea57
feat/test: replace hardcode in ci/documentation with the new repo_con…
lykimq Nov 11, 2025
8eec340
feat: replace repo_config for the hardcode in webhooks/github
lykimq Nov 11, 2025
c29de2a
feat: replace hardcode with repo_config for actions/pr_sync
lykimq Nov 11, 2025
66547b6
feat: replace hardcode with repo_config for backport
lykimq Nov 11, 2025
2aac8e2
feat: replace hardcode with repo_config for bench
lykimq Nov 11, 2025
f7cb270
feat: replace hardcode with repo_config
lykimq Nov 11, 2025
cd6617e
feat: extend github gitlab queries
lykimq Nov 12, 2025
92129cf
feat: implementation of GitHub Query functions with timeout
lykimq Nov 12, 2025
6e1c583
feat: Add GitLab query functions
lykimq Nov 12, 2025
7986714
feat/test: create and test generic defaults that work for any repo
lykimq Nov 12, 2025
96b360d
feat/test: add caching for auto-detection results to avoid rate limit…
lykimq Nov 12, 2025
11edc15
feat/test: implement API-based auto-detection with caching,
lykimq Nov 12, 2025
14584f1
feat/test: merge explicit config, auto-detected values and defaults w…
lykimq Nov 12, 2025
f81071a
feat/test: add installation ID caching from webhooks
lykimq Nov 12, 2025
d66e6bc
feat: replace hardcoded repo checks with config-based logic for webho…
lykimq Nov 12, 2025
5e50c6e
feat: replace hardcoded repo checks with config-based logic for actio…
lykimq Nov 12, 2025
796e198
feat: replace hardcoded repo checks with config-based logic for actio…
lykimq Nov 12, 2025
5a0b399
feat: replace hardcoded repo checks with config-based logic for actio…
lykimq Nov 12, 2025
290d5be
feat: replace hardcoded repo checks with config-based logic for ci/do…
lykimq Nov 12, 2025
55a661a
feat: replace all hardcode with the new config
lykimq Nov 12, 2025
fbb8186
test: add tests for the refactored code
lykimq Nov 12, 2025
2e3c305
feat: rename functions start with by removing the [rocq] so that it
lykimq Nov 12, 2025
6db03e3
feat/test: merge job_status_rocq to job_status
lykimq Nov 12, 2025
4372f77
test: add different tests to demo how the bot currently working
lykimq Nov 12, 2025
5f9fbe4
tests: merge the two test helpers into the test_helpers, remove dupli…
lykimq Nov 13, 2025
a51722e
feat: make minimizer_url configuable with both env and toml
lykimq Nov 13, 2025
cedd46b
refactor: move init_git_bare_repository to GitHub_utils because it is…
lykimq Nov 13, 2025
89ed2ce
test: addd integration tests for flags and minimizer settings, use Al…
lykimq Nov 13, 2025
f547742
test: add test for timeout with env var and TOML
lykimq Nov 13, 2025
f4b44f3
fix: resolve compilation errors after rebase - remove github_pat refe…
lykimq Nov 14, 2025
8f96ed8
fix: fix tests failed because of rebase
lykimq Nov 14, 2025
2bd6e76
chore: remove duplicate test, simplify comments
lykimq Nov 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 2 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,8 @@ Notes:
- Installation as a GitHub App is still in an experimental stage
and you may frequently receive requests to expand permissions.

- All the repositories that use the bot and belong to the same
owner must install the bot using the same method (GitHub App or
regular user).

- If you were previously using the legacy installation method,
make sure you disable any previously set up GitHub webhooks when
switching to the GitHub App, otherwise the bot will receive every
request twice.
- The bot requires GitHub App installation. The legacy installation
method using Personal Access Tokens (PAT) is no longer supported.

The bot can be installed as a GitHub App to either your account or
organization ([link to app](https://github.com/apps/coqbot-app)).
Expand Down Expand Up @@ -271,32 +265,6 @@ Once you finish the installation, follow these steps:
configuration file becomes `BOT_NAME.toml` where `BOT_NAME` is the name
of the bot.

### As a regular user account (legacy)

The bot used to be given access to each of your GitHub repositories as a
regular GitHub user account (**@coqbot**). This installation method is
still supported for repositories that haven't migrated to the GitHub App
yet. Here are the steps to follow in addition to those described in the
`As GitHub App` section:

- In your GitHub repository:

- go to "Settings" / "Manage access" to add
[**@coqbot**](https://github.com/coqbot) as a collaborator with
the "Write" role (so that it can push status checks, and set
labels).

Currently, every invitation requires a manual validation, so there
may be some lag before **@coqbot** can push status checks
to your repository.

- go to "Settings" / "Webhooks" and add one webhook with URL
<https://coqbot.herokuapp.com/github> that will only be triggered
at least by pull request events, and if you want to use the issue
milestone feature, by issue events as well. Make sure you change
the "content/type" value to "application/json".



## Architecture ##

Expand Down Expand Up @@ -352,7 +320,6 @@ to [Heroku](https://www.heroku.com/). Simply follow the official
The bot will need to read a few environment variables so make sure
these are configured in your Heroku app:

- `GITHUB_ACCESS_TOKEN` (can also be defined in the configuration file as `github.api_token`)
- `GITLAB_ACCESS_TOKEN` (can also be defined for each GitLab instance through the configuration file as `api_token` or through an environment variable whose name is defined in the configuration file as `api_token_env_var`)
- `GITHUB_WEBHOOK_SECRET` (can also be defined in the configuration file as `github.webhook_secret`)
- `GITLAB_WEBHOOK_SECRET` (can also be defined in the configuration file as `gitlab.webhook_secret`, will default to `GITHUB_WEBHOOK_SECRET` if not defined)
Expand Down
6 changes: 3 additions & 3 deletions src/bench_utils.ml → bot-components/Bench_utils.ml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
open Base
open Bot_components
open GitLab_types
open GitHub_types
open Utils
open HTTP_utils
open String_utils
open CI_utils
open Lwt.Infix

module BenchResults = struct
Expand Down Expand Up @@ -74,8 +74,8 @@ let fetch_bench_results ~job_info () =
| Ok summary_table -> (
(* The tables include how many entries there are, this is useful
information to know. *)
let* slow_number = Ci_minimization.parse_quantity slow_table "slow" in
let* fast_number = Ci_minimization.parse_quantity fast_table "fast" in
let* slow_number = parse_quantity slow_table "slow" in
let* fast_number = parse_quantity fast_table "fast" in
match (slow_number, fast_number) with
| Error e, _ | _, Error e ->
Lwt.return_error (f "Fetch bench regex issue: %s" e)
Expand Down
43 changes: 43 additions & 0 deletions bot-components/Bench_utils.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module BenchResults : sig
type t =
{ summary_table: string
; failures: string
; slow_table: string
; slow_number: int
; fast_table: string
; fast_number: int }
end

val fetch_bench_results :
job_info:GitLab_types.ci_common_info GitLab_types.job_info
-> unit
-> (BenchResults.t, string) Result.t Lwt.t

val bench_text : (BenchResults.t, string) Result.t -> string Lwt.t

val bench_comment :
bot_info:Bot_info.t
-> owner:string
-> repo:string
-> number:int
-> gitlab_url:string
-> ?check_url:string
-> (BenchResults.t, string) Result.t
-> unit Lwt.t

val update_bench_status :
bot_info:Bot_info.t
-> job_info:GitLab_types.ci_common_info GitLab_types.job_info
-> string * string
-> external_id:string
-> number:int option
-> unit Lwt.t

val run_bench :
bot_info:Bot_info.t
-> ?org:string
-> ?team:string
-> ?gitlab_domain:string
-> ?key_value_pairs:(string * string) list
-> GitHub_types.comment_info
-> unit Lwt.t
14 changes: 11 additions & 3 deletions bot-components/Bot_info.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,25 @@ open Base

type t =
{ gitlab_instances: (string, string * string) Hashtbl.t
; github_pat: string
; github_install_token: string option
; github_name: string
; email: string
; domain: string
; app_id: int }
; app_id: int
; api_timeout: float
(** API timeout in seconds for GitHub/GitLab queries. Defaults to 5.0 if not set. *)
}

(* Returns the GitHub installation token. Requires installation token to be set. *)
let github_token bot_info =
match bot_info.github_install_token with
| Some t ->
t
| None ->
bot_info.github_pat
(* TODO: use Result.t later *)
failwith
"GitHub installation token is required. Please ensure the GitHub App \
is installed and an installation token is available."

let gitlab_name_and_token bot_info gitlab_domain =
match Hashtbl.find bot_info.gitlab_instances gitlab_domain with
Expand All @@ -27,3 +33,5 @@ let gitlab_name_and_token bot_info gitlab_domain =

let gitlab_token bot_info gitlab_domain =
gitlab_name_and_token bot_info gitlab_domain |> Result.map ~f:snd

let gitlab_instances_keys bot_info = Hashtbl.keys bot_info.gitlab_instances
8 changes: 6 additions & 2 deletions bot-components/Bot_info.mli
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
type t =
{ gitlab_instances: (string, string * string) Base.Hashtbl.t
; github_pat: string
; github_install_token: string option
; github_name: string
; email: string
; domain: string
; app_id: int }
; app_id: int
; api_timeout: float
(** API timeout in seconds for GitHub/GitLab queries. Defaults to 5.0 if not set. *)
}

val github_token : t -> string

val gitlab_token : t -> string -> (string, string) Result.t

val gitlab_name_and_token : t -> string -> (string * string, string) Result.t

val gitlab_instances_keys : t -> string list
Loading