Skip to content

Commit

Permalink
Fix auto minimizer to download all dependencies (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zimmi48 authored Jan 27, 2025
2 parents fba784b + 6c59769 commit e838d62
Showing 1 changed file with 37 additions and 35 deletions.
72 changes: 37 additions & 35 deletions src/actions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ open Lwt.Syntax

type coq_job_info =
{ docker_image: string
; build_dependency: string
; dependencies: string list
; compiler: string
; opam_variant: string }

Expand Down Expand Up @@ -77,27 +77,33 @@ let send_status_check ~bot_info job_info ~pr_num (gh_owner, gh_repo)
if string_match ~regexp line then Some (Str.matched_group 1 line)
else None ) )
in
let find_all regexps =
List.filter_map trace_lines ~f:(fun line ->
List.find_map regexps ~f:(fun regexp ->
if string_match ~regexp line then Some (Str.matched_group 1 line)
else None ) )
in
find
[ "^Using Docker executor with image \\([^ ]+\\)"
; "options=Options(docker='\\([^']+\\)')" ]
>>= fun docker_image ->
find ["^Downloading artifacts for \\(build:[^ ]+\\)"]
>>= fun build_dependency ->
let dependencies = find_all ["^Downloading artifacts for \\([^ ]+\\)"] in
find ["^COMPILER=\\(.*\\)"]
>>= fun compiler ->
find ["^OPAM_VARIANT=\\(.*\\)"]
>>= fun opam_variant ->
Some {docker_image; build_dependency; compiler; opam_variant}
Some {docker_image; dependencies; compiler; opam_variant}
in
let* summary_tail_prefix =
match coq_job_info with
| Some {docker_image; build_dependency; compiler; opam_variant} ->
| Some {docker_image; dependencies; compiler; opam_variant} ->
let switch_name = compiler ^ opam_variant in
let dependencies = String.concat ~sep:"` `" dependencies in
Lwt.return
(f
"This job ran on the Docker image `%s`, depended on the build job \
`%s` with OCaml `%s`.\n\n"
docker_image build_dependency switch_name )
"This job ran on the Docker image `%s` with OCaml `%s` and depended on jobs \
`%s` .\n\n"
docker_image switch_name dependencies )
| None ->
Lwt.return ""
in
Expand Down Expand Up @@ -911,15 +917,16 @@ let ci_minimization_extract_job_specific_info ~head_pipeline_summary
if
string_match
~regexp:
"This job ran on the Docker image `\\([^`]+\\)`, depended on the \
build job `\\([^`]+\\)` with OCaml `\\([^`]+\\)`.\n\n"
"This job ran on the Docker image `\\([^`]+\\)` with OCaml `\\([^`]+\\)` and depended on jobs \
\\(\\(`[^`]+` ?\\)+\\) .\n\n"
summary
then
let docker_image, build_job, opam_switch =
let docker_image, opam_switch, dependencies =
( Str.matched_group 1 summary
, Str.matched_group 2 summary
, Str.matched_group 3 summary )
in
let dependencies = Str.split (Str.regexp "[ `]+") dependencies in
let missing_error, non_v_file =
if
string_match
Expand All @@ -935,16 +942,19 @@ let ci_minimization_extract_job_specific_info ~head_pipeline_summary
else Some filename )
else (true, None)
in
let extract_artifacts url =
List.partition_map ~f:(fun name ->
match extract_artifact_url name url with
| Some v -> First v
| None -> Second name)
(name::dependencies)
in
match
( extract_artifact_url build_job base_pipeline_summary
, extract_artifact_url build_job head_pipeline_summary
, extract_artifact_url name base_pipeline_summary
, extract_artifact_url name head_pipeline_summary )
( extract_artifacts base_pipeline_summary
, extract_artifacts head_pipeline_summary )
with
| ( Some base_build_url
, Some head_build_url
, Some base_job_url
, Some head_job_url ) ->
| ( (base_urls, [])
, (head_urls, []) ) ->
Ok
( { base_job_failed
; base_job_errored
Expand All @@ -957,26 +967,18 @@ let ci_minimization_extract_job_specific_info ~head_pipeline_summary
; full_target= name
; docker_image
; opam_switch
; failing_urls= head_build_url ^ " " ^ head_job_url
; passing_urls= base_build_url ^ " " ^ base_job_url } )
| None, _, _, _ ->
Error
(f "Could not find base build job url for %s in:\n%s" build_job
(collapse_summary "Base Pipeline Summary"
base_pipeline_summary ) )
| _, None, _, _ ->
Error
(f "Could not find head build job url for %s in:\n%s" build_job
(collapse_summary "Head Pipeline Summary"
head_pipeline_summary ) )
| _, _, None, _ ->
; failing_urls= String.concat ~sep:" " head_urls
; passing_urls= String.concat ~sep:" " base_urls } )
| (_, ((_ :: _) as base_failed)), _ ->
Error
(f "Could not find base job url for %s in:\n%s" name
(f "Could not find base dependencies artifacts for %s in:\n%s"
(String.concat ~sep:" " base_failed)
(collapse_summary "Base Pipeline Summary"
base_pipeline_summary ) )
| _, _, _, None ->
| _, (_, ((_ :: _) as head_failed)) ->
Error
(f "Could not find head job url for %s in:\n%s" name
(f "Could not find head dependencies artifacts for %s in:\n%s"
(String.concat ~sep:" " head_failed)
(collapse_summary "Head Pipeline Summary"
head_pipeline_summary ) )
else
Expand Down

0 comments on commit e838d62

Please sign in to comment.