-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Download actions job logs from API #33858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I am sure you just copied & pasted the code from somewhere without understanding what each line does. |
Works for me.
I would prefer I guess EDIT Sorry some parts are incorrect from my side... The gh compatible api path of
|
We were looking at the wrong section of the gh docu. You are implementing this endpoint https://docs.github.com/en/rest/actions/workflow-jobs?apiVersion=2022-11-28#download-job-logs-for-a-workflow-run--code-samples under a different url. The one from GitHub has no |
job_id is a string which is from the workflow not the id stored in the database. |
GitHub is good in mixing names, yes job_id in workflow yaml is a string. job_id in workflow_job api object is a number from the database see here: The example has a really big number, that is a global database id I guess
GitHub Actions users have hard time to correlate a workflow execution from the runner to a workflow_job api id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, left some non functional suggestions
Co-authored-by: ChristopherHX <christopher.homberger@web.de>
Co-authored-by: ChristopherHX <christopher.homberger@web.de>
…unny/actions_log_api
* giteaofficial/main: [skip ci] Updated translations via Crowdin Download actions job logs from API (go-gitea#33858) Fail mirroring more gracefully (go-gitea#34002) Fix dropdown module accessing (go-gitea#34026) Polyfill WeakRef (go-gitea#34025) Fix dropdown delegating and some UI problems (go-gitea#34014)
var curJob *actions_model.ActionRunJob | ||
if jobIndex >= 0 && jobIndex < int64(len(runJobs)) { | ||
curJob = runJobs[jobIndex] | ||
if 0 < jobIndex || jobIndex >= int64(len(runJobs)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I didn't see this, my workflow that I tested was to short.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I made this typo. But why tests didn't catch it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But why tests didn't catch it?
The reason was, this test only verifies that downloading a job log with index 0 downloads successfully.
Now this "bug" only appears for the second,third,nth job.
I have commented on the fix PR a patch to the test that expands the test to check, which I cannot push with my privilege here directly into that fix.
Hi @lunny thank you for adding this feature. How can we obtain job_id in order to call this new API for downloading the job logs? |
@NikolayOG workflow_job webhook id field (do not trust the url yet)
|
I tried that but I think there is a bug. For what I have running (1.24.0+dev-572) when I query "api/v1/repos/nikg/test/actions/tasks" neither "id" nor "run_number" are 14, however, I am able to download some logs on "api/v1/repos/nikg/test/actions/jobs/14/logs" so there is some mismatch going on. |
@NikolayOG I can confirm a mismatch, it's odd subtract one from the id... workflow_job webhook reports the correct id, e.g. 1 + of the id field of the tasks endpoint Need to debug to understand why and how. I have plans to finish a rest api for workflow_job GitHub Style, but this might not make it in 1.24 |
This comment was marked as outdated.
This comment was marked as outdated.
Ok it's a different database id, sorry cannot be used. |
Related to #33709, #31416
It's similar with https://docs.github.com/en/rest/actions/workflow-jobs?apiVersion=2022-11-28#download-job-logs-for-a-workflow-run--code-samples.
This use
job_id
as path parameter which is consistent with Github's APIs.