@Théo Zimmermann In job_action how can I get access to the pr_id? I see that I have the pr_num but I can't find how to get the corresponding id.
Getting from PR number to PR id unfortunately requires a request to the GitHub API.
What do you need this for?
In order to post a comment
val post_comment :
bot_info:Bot_info.t
-> id:id
-> message:string
-> (string, string) result Lwt.t
Right. There's no getting around that you need the PR id in this case.
Who do I call for that?
Let me check.
If you want to reuse an existing query, you can use get_pull_request_id_and_milestone
. Then (as a refinement), we could extract a query that only gets the ID.
So you mean use that and then change it at later date?
Or do you want the refinement now?
I mean you can use this for your code and I can take care of extracting the right query before merging (unless you do it yourself).
OK I will use that for now
@Théo Zimmermann I've drafted a PR: https://github.com/coq/bot/pull/217
Is this the right way to go about it?
Hum, yes I guess. Though the first step (IMHO) would be to just add the reporting as a check run summary. This would already be useful and would not prevent additionally posting a comment next.
Alright, I will work on the summary then
@Théo Zimmermann Is there a limit to how much can be put in the summary?
There certainly is a limit but I don't know how much.
I would expect something similar to the comment limit which is 32kB IIRC.
Ok so there is no way I can dump a 7mb file in the summary
Checking just in case
Indeed, I don't think so.
What is the 7mb file?
The bench artifacts consist of the speed ups, slow downs, summary and a file listing all line timing changes
https://gitlab.com/coq/coq/-/jobs/2234949947/artifacts/browse/_bench/timings/
In this case since I reduced the number of jobs in the bench the file is only 50kb
it is not essential to include
I have a question about fetching artifacts
I am tempted to copy the doc url stuff to do this
Is that ok or should I be doing it another way
url |> Uri.of_string |> Client.get
>>= fun (resp, _) ->
let status_code = resp |> Response.status |> Code.code_of_status in
if Int.equal 200 status_code then
Yes, it's OK.
If some of these more detailed files are available in HTML format, then I would suggest adding links to the HTML artifacts instead of putting them in the summary.
(And only including the really essential information in the summary.)
Théo Zimmermann said:
Yes, it's OK.
Actually, you may need to store the body of the artifact as well instead of just checking that the HTTP code is 200.
And if you can test your artifact fetching code locally (through utop), that would ensure that it doesn't fail unexpectedly once deployed.
The files are all basically txt files, but I am unsure how to tell gitlab to make them interactively browsable
Does it have to be html for that?
I think so.
Since 3 of them are small tables, I will post those directly in the summary
But the fourth would be nice to have in a browsable state, but that will require a change on the coq side
@Théo Zimmermann I've added a summary page now https://github.com/coq/bot/pull/217
Deploying for testing: https://github.com/Alizter/bot/runs/5649378771?check_suite_focus=true
I've managed to do a summary and it looks alright: https://github.com/coq/coq/pull/14748/checks?check_run_id=5651821583
However I don't know why it is so narrow.
That's the way GitHub formats code blocks I think.
It would be great if the generated artifacts that are used to display the summary could be in Markdown table format.
The generated artifacts are straight from the bench scripts: https://github.com/coq/coq/tree/master/dev/bench render_line_results.ml and render_results.ml. They can both easily be modified to also output the data as a GitHub table.
However I don't think that we would want to do this.
The tables these scripts create are pretty, compact and easy to read.
The GitHub markdown tables on the other hand might be a bit of a pain to read.
Oh I see that you finally managed to format the code blocks differently. How did you do?
Oh I see: you used the details section. Good idea!
I agree that the main table is more compact like this that it could ever be in Markdown format. But for the top 25 speedups / slowdowns, there would be a big advantage to use Markdown: you could transform the FILE
column into clickable links (such as to: https://coq.gitlab.io/-/coq/-/jobs/2239434488/artifacts/_bench/html/coq-mathcomp-fingroup/mathcomp/fingroup/gproduct.v.html).
Since the user time speedup / slowdown is also what most people are interested, extracting just this information as a Markdown table and including it in the summary could also make sense.
Anyway, these are only suggestions on making things better. The current state is already really good.
Those are good ideas, can you create an issue about them?
Sure.
Trying out comments from @coqbot bench
https://github.com/coq/coq/pull/14748#issuecomment-1081051970 Let's see if it works.
@Théo Zimmermann How can I get the url of the check summary? I would like to include it in the comment but I have no idea what it is.
The trick is to slightly modify the GraphQL mutation so that it returns something. I'll prepare the beginning of a patch.
Here:
diff --git a/bot-components/GitHub_GraphQL.ml b/bot-components/GitHub_GraphQL.ml
index 16f1df6..bba2d9d 100644
--- a/bot-components/GitHub_GraphQL.ml
+++ b/bot-components/GitHub_GraphQL.ml
@@ -328,7 +328,9 @@ module NewCheckRun =
}
externalId:$externalId
}) {
- clientMutationId
+ checkRun {
+ url @ppxCustom(module: "ParseAsString")
+ }
}
}
|}]
Instead of ignoring the result of the mutation (and returning unit), this mutation should return the URL of the resulting check run. You can follow the example of the comment posting mutation that already works like this.
(The URL of the comment is currently only used to be displayed in the log.)
Eventually, we should probably refactor the whole code so that anytime the bot creates something, it posts its URL to the log.
Here is the latest version of the comment btw: https://github.com/coq/coq/pull/14748#issuecomment-1081868183
Seems I have messed up the link, I thought GitHub did [link](url)
for links?
it seems to want a blank line after </details>
@Théo Zimmermann I had a go at splitting it, though it meant in a lot of places I had to wrap the create_check_run call like this:
let open Lwt.Syntax in
let+ _ =
GitHub_mutations.create_check_run ~bot_info ~name:context
~status ~repo_id ~head_sha:job_info.common_info.head_commit
?conclusion ~title:description ~details_url:job_url
~summary:"" ~external_id ()
in
()
Eventually we probably want to not do nothing there, or at least print the returned url. let+ is map and let* is bind btw
What about just propagating the value until where we actually run the request (no map) and modifying the types instead?
I'm not sure how to propagate these values. There is more than one, have a look at https://github.com/coq/bot/pull/217/files#diff-c234fddfca49f71b523e6a417a504296214e08c9c42f28575c0ac212f552be3f
The wrapper I gave is exactly the same behavior as before
The callers of create_check_run are not really expecting it to return anything
Hmm it seems the URL for the check summary is not being fetched properly. https://github.com/coq/coq/pull/14748#issuecomment-1082192069
I will need to do some more investigation.
The comment conditionally prints the url so that it doesn't block the entire comment.
29 Mar 2022 18:46:29.869129 <190>1 2022-03-29T17:46:29.485062+00:00 app web.1 - - Pushing status check for bench job.
29 Mar 2022 18:46:31.269297 <158>1 2022-03-29T17:46:30.793718+00:00 heroku router - - at=info method=POST path="/github" host=coqbot.herokuapp.com request_id=e6418c3c-729f-4f05-96f1-d951b460d49d fwd="140.82.115.251" dyno=web.1 connect=0ms service=1ms status=200 bytes=93 protocol=https
29 Mar 2022 18:46:31.388297 <158>1 2022-03-29T17:46:30.844578+00:00 heroku router - - at=info method=POST path="/github" host=coqbot.herokuapp.com request_id=48372171-6323-4805-bf56-bab4f65f2712 fwd="140.82.115.102" dyno=web.1 connect=0ms service=2ms status=200 bytes=82 protocol=https
29 Mar 2022 18:46:31.826300 <158>1 2022-03-29T17:46:31.372865+00:00 heroku router - - at=info method=POST path="/github" host=coqbot.herokuapp.com request_id=dce0b46d-1698-4d96-95eb-f8cc4cf84b47 fwd="140.82.115.110" dyno=web.1 connect=0ms service=2ms status=200 bytes=10618 protocol=https
29 Mar 2022 18:46:32.150297 <158>1 2022-03-29T17:46:31.735316+00:00 heroku router - - at=info method=POST path="/pipeline" host=coqbot.herokuapp.com request_id=f91c067c-1e41-4178-89ec-30a09637fed3 fwd="34.74.226.8" dyno=web.1 connect=0ms service=40ms status=200 bytes=54 protocol=https
29 Mar 2022 18:46:32.622296 <158>1 2022-03-29T17:46:32.250899+00:00 heroku router - - at=info method=POST path="/github" host=coqbot.herokuapp.com request_id=00ad905f-8a8a-4787-978e-58ea06f90268 fwd="140.82.115.89" dyno=web.1 connect=0ms service=1ms status=200 bytes=82 protocol=https
29 Mar 2022 18:46:32.781297 <158>1 2022-03-29T17:46:32.254793+00:00 heroku router - - at=info method=POST path="/github" host=coqbot.herokuapp.com request_id=f1741047-60bb-40df-a95a-ef5d2b4d9c74 fwd="140.82.115.116" dyno=web.1 connect=0ms service=2ms status=200 bytes=93 protocol=https
29 Mar 2022 18:46:32.905297 <158>1 2022-03-29T17:46:32.315866+00:00 heroku router - - at=info method=POST path="/github" host=coqbot.herokuapp.com request_id=893b4ee6-bed9-48cd-9474-b84a11dfdc4c fwd="140.82.115.242" dyno=web.1 connect=0ms service=1ms status=200 bytes=82 protocol=https
29 Mar 2022 18:46:37.431218 <190>1 2022-03-29T17:46:37.044836+00:00 app web.1 - - Bench Check Summary URL missing: Error while creating check run.I'm going to look for failed tests to minimize on PR #14748.
Ali Caglayan said:
I'm not sure how to propagate these values. There is more than one, have a look at https://github.com/coq/bot/pull/217/files#diff-c234fddfca49f71b523e6a417a504296214e08c9c42f28575c0ac212f552be3f
OK then your changes looks good indeed.
Last updated: May 28 2023 at 18:29 UTC