-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Add --json export flag for workflow runs
#3869
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
| return e | ||
| } | ||
| return e | ||
| }) |
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.
When building gh, all subcommands inherits the root's FlagErrorFunc declared here:
Line 65 in 640a089
| cmd.SetFlagErrorFunc(rootFlagErrorFunc) |
But when testing a specific cmd isolated there's no Parent cmd so it panics when doing an error-check test like this:
https://github.com/cli/cli/runs/2876079048#step:5:94
(You can see it by adding an error-check test to any command that exports JSON like repo list, pr view, etc).
I've added this check to avoid accessing c.Parent if it doesn't exists, though I'm not sure if there's any better solution for this.
mislav
left a comment
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.
This all looks great! My last, but very important request is that we think about which fields do we expose and resolve the inconsistency between IDs returned in this JSON payload vs IDs returned from payloads in other gh commands.
pkg/cmd/run/shared/shared.go
Outdated
| "id", | ||
| "workflowId", |
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.
In --json output for some other commands, id and somethingId fields return GraphQL IDs because most of our data comes from GitHub API v4. However, in this case, information comes from GitHub API v3 (REST API) and so these IDs will be numeric database IDs. The different style and usability of these IDs makes me think that we should name these fields differently to avoid confusion. 🤔
What do you think about databaseId and workflowDatabaseId?
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.
Makes sense 👍🏼, GitHub API v4 also refers to db IDs as databaseId in nodes so will go with that.
|
Is this feature being built? :D I was thinking about doing a tiny automation using the |
|
Hi @karuppiah7890, will see if I can update this PR this weekend :) |
|
Any ETA on when this will be merged? |
mislav
left a comment
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.
Thanks for your patience!
|
@cristiand391 any chance of you adding HeadCommit/commit message as a json field? filtering on it is quite important in our workflow |
|
Hey @kirikorneev! Sorry for the delayed response, it seems the Run struct already defines a The field cli/pkg/cmd/run/shared/shared.go Line 84 in c9f44ff
Could you please open a new issue in this repo? That way you can get feedback/approval from the maintainers to add expose this new field. Thanks! |
This PR adds JSON export functionality to
gh run listandgh run view:Examples:
ghd run list -L 1 --json headSha,headBranch,workflowDatabaseId,databaseId[ { "databaseId": 1227385157, "headBranch": "run-json-format", "headSha": "6ab9ab8a3c113afa459e9acae393ac35ecc68d85", "workflowDatabaseId": 25016 } ]ghd run view 964177659 --json headSha,headBranch,workflowDatabaseId,databaseId{ "databaseId": 964177659, "headBranch": "draft-flow-gh-repo-edit", "headSha": "055bf84069f8e83986e215c388de2af45e65b0a9", "workflowDatabaseId": 1208059 }Closes #3477