@@ -736,7 +736,8 @@ type ci_minimization_info =
736
736
; passing_urls : string }
737
737
738
738
let run_ci_minimization ~bot_info ~comment_thread_id ~owner ~repo ~pr_number
739
- ~base ~head ~ci_minimization_infos ~bug_file_contents =
739
+ ~base ~head ~ci_minimization_infos ~bug_file_contents
740
+ ~minimizer_extra_arguments =
740
741
(* for convenience of control flow, we always create the temporary
741
742
file, but we only pass in the file name if the bug file contents
742
743
is non-None *)
@@ -752,7 +753,7 @@ let run_ci_minimization ~bot_info ~comment_thread_id ~owner ~repo ~pr_number
752
753
(fun {target; opam_switch; failing_urls; passing_urls; docker_image} ->
753
754
git_run_ci_minimization ~bot_info ~comment_thread_id ~owner ~repo
754
755
~pr_number ~docker_image ~target ~opam_switch ~failing_urls
755
- ~passing_urls ~base ~head ~bug_file_name
756
+ ~passing_urls ~base ~head ~minimizer_extra_arguments ~ bug_file_name
756
757
>> = fun result -> Lwt. return (target, result) )
757
758
ci_minimization_infos )
758
759
>> = fun results ->
@@ -1176,9 +1177,43 @@ let suggest_ci_minimization_for_pr = function
1176
1177
| _ ->
1177
1178
Suggest
1178
1179
1180
+ let format_options_for_getopts options =
1181
+ " " ^ options ^ " " |> Str. global_replace (Str. regexp " [\n\r\t ]" ) " "
1182
+
1183
+ let getopts options ~opt =
1184
+ map_string_matches
1185
+ ~regexp: (f " %s\\ (\\ .\\ |[ =:-]\\ |: \\ )\\ ([^ ]+\\ ) " opt)
1186
+ ~f: (fun () -> Str. matched_group 2 options)
1187
+ options
1188
+
1189
+ let getopt options ~opt =
1190
+ options |> getopts ~opt |> List. hd |> Option. value ~default: " "
1191
+
1192
+ let accumulate_extra_minimizer_arguments options =
1193
+ let extra_args = getopts ~opt: " extra-arg" options in
1194
+ let inline_stdlib = getopt ~opt: " inline-stdlib" options in
1195
+ ( if String. equal inline_stdlib " yes" then Lwt. return [" --inline-coqlib" ]
1196
+ else
1197
+ ( if not (String. equal inline_stdlib " " ) then
1198
+ Lwt_io. printlf
1199
+ " Ignoring invalid option to inline-stdlib '%s' not equal to 'yes'"
1200
+ inline_stdlib
1201
+ else Lwt. return_unit )
1202
+ >> = fun () -> Lwt. return_nil )
1203
+ >> = fun inline_stdlib_args -> inline_stdlib_args @ extra_args |> Lwt. return
1204
+
1179
1205
let minimize_failed_tests ~bot_info ~owner ~repo ~pr_number
1180
1206
~head_pipeline_summary ~request ~comment_on_error ~bug_file_contents
1181
- ?base_sha ?head_sha () =
1207
+ ~options ?base_sha ?head_sha () =
1208
+ let options = format_options_for_getopts options in
1209
+ accumulate_extra_minimizer_arguments options
1210
+ >> = fun minimizer_extra_arguments ->
1211
+ Lwt_io. printlf
1212
+ " Parsed options for the bug minimizer at %s/%s#%d from '%s' into \
1213
+ {minimizer_extra_arguments: '%s'}"
1214
+ owner repo pr_number options
1215
+ (String. concat ~sep: " " minimizer_extra_arguments)
1216
+ >> = fun () ->
1182
1217
fetch_ci_minimization_info ~bot_info ~owner ~repo ~pr_number
1183
1218
~head_pipeline_summary ?base_sha ?head_sha ()
1184
1219
>> = function
@@ -1264,7 +1299,8 @@ let minimize_failed_tests ~bot_info ~owner ~repo ~pr_number
1264
1299
>> = fun () ->
1265
1300
run_ci_minimization ~bot_info ~comment_thread_id ~owner ~repo
1266
1301
~pr_number: (Int. to_string pr_number) ~base ~head
1267
- ~ci_minimization_infos: jobs_to_minimize ~bug_file_contents
1302
+ ~ci_minimization_infos: jobs_to_minimize ~minimizer_extra_arguments
1303
+ ~bug_file_contents
1268
1304
>> = fun (jobs_minimized , jobs_that_could_not_be_minimized ) ->
1269
1305
let pluralize word ?plural ls =
1270
1306
match (ls, plural) with
@@ -1717,7 +1753,7 @@ let minimize_failed_tests ~bot_info ~owner ~repo ~pr_number
1717
1753
" Error while attempting to find jobs to minimize from PR #%d:\n %s"
1718
1754
pr_number err
1719
1755
1720
- let ci_minimize ~bot_info ~comment_info ~requests ~comment_on_error
1756
+ let ci_minimize ~bot_info ~comment_info ~requests ~comment_on_error ~ options
1721
1757
~bug_file_contents =
1722
1758
minimize_failed_tests ~bot_info ~owner: comment_info.issue.issue.owner
1723
1759
~repo: comment_info.issue.issue.repo ~pr_number: comment_info.issue.number
@@ -1730,7 +1766,7 @@ let ci_minimize ~bot_info ~comment_info ~requests ~comment_on_error
1730
1766
RequestAll
1731
1767
| requests ->
1732
1768
RequestExplicit requests )
1733
- ~comment_on_error ~bug_file_contents ()
1769
+ ~comment_on_error ~options ~ bug_file_contents ()
1734
1770
1735
1771
let pipeline_action ~bot_info pipeline_info ~gitlab_mapping : unit Lwt. t =
1736
1772
let gitlab_full_name = pipeline_info.project_path in
@@ -1862,7 +1898,7 @@ let pipeline_action ~bot_info pipeline_info ~gitlab_mapping : unit Lwt.t =
1862
1898
| "coq" , "coq" , "failed" , Some pr_number ->
1863
1899
minimize_failed_tests ~bot_info ~owner ~repo ~pr_number
1864
1900
~head_pipeline_summary: (Some summary) ~request: Auto
1865
- ~comment_on_error: false ~bug_file_contents: None
1901
+ ~comment_on_error: false ~options: " " ~ bug_file_contents:None
1866
1902
?base_sha:pipeline_info.common_info.base_commit
1867
1903
~head_sha: pipeline_info.common_info.head_commit ()
1868
1904
| _ ->
@@ -1874,25 +1910,21 @@ type coqbot_minimize_script_data =
1874
1910
1875
1911
let run_coq_minimizer ~bot_info ~script ~comment_thread_id ~comment_author
1876
1912
~owner ~repo ~options =
1877
- let options =
1878
- " " ^ options ^ " " |> Str. global_replace (Str. regexp " [\n\r\t ]" ) " "
1913
+ let options = format_options_for_getopts options in
1914
+ let getopt_version opt =
1915
+ options |> getopt ~opt |> Str. replace_first (Str. regexp " ^[vV]" ) " "
1879
1916
in
1880
- let getopt opt =
1881
- if
1882
- string_match
1883
- ~regexp: (f " %s\\ (\\ .\\ |[ =:-]\\ |: \\ )[vV]?\\ ([^ ]+\\ ) " opt)
1884
- options
1885
- then Str. matched_group 2 options
1886
- else " "
1887
- in
1888
- let coq_version = getopt " [Cc]oq" in
1889
- let ocaml_version = getopt " [Oo][Cc]aml" in
1917
+ accumulate_extra_minimizer_arguments options
1918
+ >> = fun minimizer_extra_arguments ->
1919
+ let coq_version = getopt_version " [Cc]oq" in
1920
+ let ocaml_version = getopt_version " [Oo][Cc]aml" in
1890
1921
Lwt_io. printlf
1891
1922
" Parsed options for the bug minimizer at %s/%s@%s from '%s' into \
1892
- {coq_version: '%s'; ocaml_version: '%s'}"
1923
+ {coq_version: '%s'; ocaml_version: '%s'; minimizer_extra_arguments: '%s' }"
1893
1924
owner repo
1894
1925
(GitHub_ID. to_string comment_thread_id)
1895
1926
options coq_version ocaml_version
1927
+ (String. concat ~sep: " " minimizer_extra_arguments)
1896
1928
>> = fun () ->
1897
1929
( match script with
1898
1930
| MinimizeScript {quote_kind; body} ->
@@ -1912,7 +1944,7 @@ let run_coq_minimizer ~bot_info ~script ~comment_thread_id ~comment_author
1912
1944
)
1913
1945
|> fun script ->
1914
1946
git_coq_bug_minimizer ~bot_info ~script ~comment_thread_id ~comment_author
1915
- ~owner ~repo ~coq_version ~ocaml_version
1947
+ ~owner ~repo ~coq_version ~ocaml_version ~minimizer_extra_arguments
1916
1948
>> = function
1917
1949
| Ok () ->
1918
1950
GitHub_mutations. post_comment ~id: comment_thread_id
@@ -1972,12 +2004,12 @@ let coq_bug_minimizer_resume_ci_minimization_action ~bot_info ~key ~app_id body
1972
2004
; pr_number ] -> (
1973
2005
message |> String. split ~on: '\n'
1974
2006
|> function
1975
- | docker_image
1976
- :: target
1977
- :: opam_switch
1978
- :: failing_urls
1979
- :: passing_urls :: base :: head :: bug_file_lines ->
1980
- ( let bug_file_contents = String. concat ~sep: " \n " bug_file_lines in
2007
+ | docker_image :: target :: opam_switch :: failing_urls :: passing_urls
2008
+ :: base :: head :: extra_arguments_joined :: bug_file_lines ->
2009
+ ( let minimizer_extra_arguments =
2010
+ String. split ~on: ' ' extra_arguments_joined
2011
+ in
2012
+ let bug_file_contents = String. concat ~sep: " \n " bug_file_lines in
1981
2013
fun () ->
1982
2014
init_git_bare_repository ~bot_info
1983
2015
>> = fun () ->
@@ -1986,6 +2018,7 @@ let coq_bug_minimizer_resume_ci_minimization_action ~bot_info ~key ~app_id body
1986
2018
(run_ci_minimization
1987
2019
~comment_thread_id: (GitHub_ID. of_string comment_thread_id)
1988
2020
~owner ~repo ~base ~pr_number ~head
2021
+ ~minimizer_extra_arguments
1989
2022
~ci_minimization_infos:
1990
2023
[ { target
1991
2024
; opam_switch
@@ -2430,7 +2463,7 @@ let run_ci_action ~bot_info ~comment_info ?full_ci ~gitlab_mapping
2430
2463
Lwt_io. printl " Unauthorized user: doing nothing." |> Lwt_result. ok
2431
2464
)
2432
2465
|> Fn. flip Lwt_result. bind_lwt_err (fun err ->
2433
- Lwt_io. printf " Error: %s\n " err ))
2466
+ Lwt_io. printf " Error: %s\n " err ) )
2434
2467
>> = fun _ -> Lwt. return_unit )
2435
2468
|> Lwt. async ;
2436
2469
Server. respond_string ~status: `OK
0 commit comments