-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
refactor!: Update package types to align with webhook event #3515
Conversation
Update the types associated with GitHub packages to better align with the schema used by by the package event.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3515 +/- ##
==========================================
+ Coverage 91.17% 91.30% +0.12%
==========================================
Files 181 183 +2
Lines 15859 16094 +235
==========================================
+ Hits 14460 14695 +235
Misses 1225 1225
Partials 174 174 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
If you run |
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.
Thank you, @adrian-saunders!
I'll continue my review after you address the current issues.
github/packages.go
Outdated
@@ -85,7 +157,6 @@ type PackageFile struct { | |||
MD5 *string `json:"md5,omitempty"` | |||
ContentType *string `json:"content_type,omitempty"` | |||
State *string `json:"state,omitempty"` | |||
Author *User `json:"author,omitempty"` |
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.
Why is this field being removed?
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.
As far as I can tell, PackageFile
s only exist on a webhook event and the schema doesn't have it as a property
Should have mentioned as a breaking change though!
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.
OK, let's please leave the field in unless we can conclusively prove that it is no longer being used. Feel free to add a comment about your findings.
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.
OK will add back
Oh, sorry, I see your responses now in email. |
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.
Thank you, @adrian-saunders!
It is unfortunate that we have so many any
, map
and json.RawMessage
in this PR, but it sounds like it is pretty unavoidable due to the wide variety of possible data.
Let's please add back in the removed Author
field, and then we should be ready for a second LGTM+Approval from any other contributor to this repo before merging.
github/packages.go
Outdated
@@ -85,7 +157,6 @@ type PackageFile struct { | |||
MD5 *string `json:"md5,omitempty"` | |||
ContentType *string `json:"content_type,omitempty"` | |||
State *string `json:"state,omitempty"` | |||
Author *User `json:"author,omitempty"` |
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.
OK will add back
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.
Thank you, @adrian-saunders!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.
@stevehipwell - might you have time for a code review? Thank you!
@gmlewis I think this is another case where it's worth considering if |
I think that is certainly a possibility. Are there examples of what you are proposing elsewhere in this repo that can be used as a guide for implementation? If not, I think it may be too much to ask PR authors to try and understand what you are envisioning, as my personal understanding is a bit fuzzy and I would not be able to give guidance. Maybe the best way to go about this is to open one or more new Issues with enhancement proposals to make the developer experience better for users of this client library by implementing what you are proposing. In fact, maybe we could start with one or two specific API collections (maybe the two you've already mentioned... this PR and the other one you commented on) and see if we want to expand this idea throughout the repo based on how the changes are received? |
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.
LGTM
Thank you, @stevehipwell! |
Thank you both for the review! |
BREAKING CHANGE:
PackageVersion.Body
andPackageVersion.Metadata
are both nowjson.RawMessage
.Hello,
Firstly, thank you for maintaining this project! It has made interacting with GitHub significantly easier. I know this is a little backward to raise a PR without even a comment on the original issue so sorry but I had to get some legal approval first. Anyway...
This PR is meant to better align the package types with the webhook event schema.
Fixes: #2033
Breaking changes:
PackageVersion.Body
is nowjson.RawMessage
- I'm not sure in what scenarios this is a string or object but it can be both.PackageVersion.Metadata
is nowjson.json.RawMessage
- webhooks return an array here, rather than aPackageMetadata
I've added getters for both of these fields.
References:
Webhooks: https://github.com/octokit/webhooks/tree/main/payload-schemas/api.github.com/package
REST: https://docs.github.com/en/rest/packages/packages?apiVersion=2022-11-28
Please do let me know your comments and if there is anything I haven't thought of!