Skip to content

Commit e838d62

Browse files
authored
Fix auto minimizer to download all dependencies (#333)
2 parents fba784b + 6c59769 commit e838d62

File tree

1 file changed

+37
-35
lines changed

1 file changed

+37
-35
lines changed

src/actions.ml

+37-35
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ open Lwt.Syntax
1212

1313
type coq_job_info =
1414
{ docker_image: string
15-
; build_dependency: string
15+
; dependencies: string list
1616
; compiler: string
1717
; opam_variant: string }
1818

@@ -77,27 +77,33 @@ let send_status_check ~bot_info job_info ~pr_num (gh_owner, gh_repo)
7777
if string_match ~regexp line then Some (Str.matched_group 1 line)
7878
else None ) )
7979
in
80+
let find_all regexps =
81+
List.filter_map trace_lines ~f:(fun line ->
82+
List.find_map regexps ~f:(fun regexp ->
83+
if string_match ~regexp line then Some (Str.matched_group 1 line)
84+
else None ) )
85+
in
8086
find
8187
[ "^Using Docker executor with image \\([^ ]+\\)"
8288
; "options=Options(docker='\\([^']+\\)')" ]
8389
>>= fun docker_image ->
84-
find ["^Downloading artifacts for \\(build:[^ ]+\\)"]
85-
>>= fun build_dependency ->
90+
let dependencies = find_all ["^Downloading artifacts for \\([^ ]+\\)"] in
8691
find ["^COMPILER=\\(.*\\)"]
8792
>>= fun compiler ->
8893
find ["^OPAM_VARIANT=\\(.*\\)"]
8994
>>= fun opam_variant ->
90-
Some {docker_image; build_dependency; compiler; opam_variant}
95+
Some {docker_image; dependencies; compiler; opam_variant}
9196
in
9297
let* summary_tail_prefix =
9398
match coq_job_info with
94-
| Some {docker_image; build_dependency; compiler; opam_variant} ->
99+
| Some {docker_image; dependencies; compiler; opam_variant} ->
95100
let switch_name = compiler ^ opam_variant in
101+
let dependencies = String.concat ~sep:"` `" dependencies in
96102
Lwt.return
97103
(f
98-
"This job ran on the Docker image `%s`, depended on the build job \
99-
`%s` with OCaml `%s`.\n\n"
100-
docker_image build_dependency switch_name )
104+
"This job ran on the Docker image `%s` with OCaml `%s` and depended on jobs \
105+
`%s` .\n\n"
106+
docker_image switch_name dependencies )
101107
| None ->
102108
Lwt.return ""
103109
in
@@ -911,15 +917,16 @@ let ci_minimization_extract_job_specific_info ~head_pipeline_summary
911917
if
912918
string_match
913919
~regexp:
914-
"This job ran on the Docker image `\\([^`]+\\)`, depended on the \
915-
build job `\\([^`]+\\)` with OCaml `\\([^`]+\\)`.\n\n"
920+
"This job ran on the Docker image `\\([^`]+\\)` with OCaml `\\([^`]+\\)` and depended on jobs \
921+
\\(\\(`[^`]+` ?\\)+\\) .\n\n"
916922
summary
917923
then
918-
let docker_image, build_job, opam_switch =
924+
let docker_image, opam_switch, dependencies =
919925
( Str.matched_group 1 summary
920926
, Str.matched_group 2 summary
921927
, Str.matched_group 3 summary )
922928
in
929+
let dependencies = Str.split (Str.regexp "[ `]+") dependencies in
923930
let missing_error, non_v_file =
924931
if
925932
string_match
@@ -935,16 +942,19 @@ let ci_minimization_extract_job_specific_info ~head_pipeline_summary
935942
else Some filename )
936943
else (true, None)
937944
in
945+
let extract_artifacts url =
946+
List.partition_map ~f:(fun name ->
947+
match extract_artifact_url name url with
948+
| Some v -> First v
949+
| None -> Second name)
950+
(name::dependencies)
951+
in
938952
match
939-
( extract_artifact_url build_job base_pipeline_summary
940-
, extract_artifact_url build_job head_pipeline_summary
941-
, extract_artifact_url name base_pipeline_summary
942-
, extract_artifact_url name head_pipeline_summary )
953+
( extract_artifacts base_pipeline_summary
954+
, extract_artifacts head_pipeline_summary )
943955
with
944-
| ( Some base_build_url
945-
, Some head_build_url
946-
, Some base_job_url
947-
, Some head_job_url ) ->
956+
| ( (base_urls, [])
957+
, (head_urls, []) ) ->
948958
Ok
949959
( { base_job_failed
950960
; base_job_errored
@@ -957,26 +967,18 @@ let ci_minimization_extract_job_specific_info ~head_pipeline_summary
957967
; full_target= name
958968
; docker_image
959969
; opam_switch
960-
; failing_urls= head_build_url ^ " " ^ head_job_url
961-
; passing_urls= base_build_url ^ " " ^ base_job_url } )
962-
| None, _, _, _ ->
963-
Error
964-
(f "Could not find base build job url for %s in:\n%s" build_job
965-
(collapse_summary "Base Pipeline Summary"
966-
base_pipeline_summary ) )
967-
| _, None, _, _ ->
968-
Error
969-
(f "Could not find head build job url for %s in:\n%s" build_job
970-
(collapse_summary "Head Pipeline Summary"
971-
head_pipeline_summary ) )
972-
| _, _, None, _ ->
970+
; failing_urls= String.concat ~sep:" " head_urls
971+
; passing_urls= String.concat ~sep:" " base_urls } )
972+
| (_, ((_ :: _) as base_failed)), _ ->
973973
Error
974-
(f "Could not find base job url for %s in:\n%s" name
974+
(f "Could not find base dependencies artifacts for %s in:\n%s"
975+
(String.concat ~sep:" " base_failed)
975976
(collapse_summary "Base Pipeline Summary"
976977
base_pipeline_summary ) )
977-
| _, _, _, None ->
978+
| _, (_, ((_ :: _) as head_failed)) ->
978979
Error
979-
(f "Could not find head job url for %s in:\n%s" name
980+
(f "Could not find head dependencies artifacts for %s in:\n%s"
981+
(String.concat ~sep:" " head_failed)
980982
(collapse_summary "Head Pipeline Summary"
981983
head_pipeline_summary ) )
982984
else

0 commit comments

Comments
 (0)