-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat!: Widen CustomProperties type to map[string]interface{} to align with GitHub API #3230
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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, @spalberg !
Just one comment, then we should be able to merge after a second LGTM+Approval from any other contributor to this repo.
github/repos_test.go
Outdated
|
||
t.Run("go-github repo (sanity check)", func(t *testing.T) { | ||
// regenerate using github cli: gh api repos/google/go-github | ||
data := []byte(`{"id":10270722,"node_id":"MDEwOlJlcG9zaXRvcnkxMDI3MDcyMg==","name":"go-github","full_name":"google/go-github","private":false,"owner":{"login":"google","id":1342004,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNDIwMDQ=","avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/google/go-github","description":"Go library for accessing the GitHub v3 API","fork":false,"url":"https://api.github.com/repos/google/go-github","forks_url":"https://api.github.com/repos/google/go-github/forks","keys_url":"https://api.github.com/repos/google/go-github/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/go-github/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/go-github/teams","hooks_url":"https://api.github.com/repos/google/go-github/hooks","issue_events_url":"https://api.github.com/repos/google/go-github/issues/events{/number}","events_url":"https://api.github.com/repos/google/go-github/events","assignees_url":"https://api.github.com/repos/google/go-github/assignees{/user}","branches_url":"https://api.github.com/repos/google/go-github/branches{/branch}","tags_url":"https://api.github.com/repos/google/go-github/tags","blobs_url":"https://api.github.com/repos/google/go-github/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/go-github/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/go-github/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/go-github/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/go-github/statuses/{sha}","languages_url":"https://api.github.com/repos/google/go-github/languages","stargazers_url":"https://api.github.com/repos/google/go-github/stargazers","contributors_url":"https://api.github.com/repos/google/go-github/contributors","subscribers_url":"https://api.github.com/repos/google/go-github/subscribers","subscription_url":"https://api.github.com/repos/google/go-github/subscription","commits_url":"https://api.github.com/repos/google/go-github/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/go-github/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/go-github/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/go-github/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/go-github/contents/{+path}","compare_url":"https://api.github.com/repos/google/go-github/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/go-github/merges","archive_url":"https://api.github.com/repos/google/go-github/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/go-github/downloads","issues_url":"https://api.github.com/repos/google/go-github/issues{/number}","pulls_url":"https://api.github.com/repos/google/go-github/pulls{/number}","milestones_url":"https://api.github.com/repos/google/go-github/milestones{/number}","notifications_url":"https://api.github.com/repos/google/go-github/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/go-github/labels{/name}","releases_url":"https://api.github.com/repos/google/go-github/releases{/id}","deployments_url":"https://api.github.com/repos/google/go-github/deployments","created_at":"2013-05-24T16:42:58Z","updated_at":"2024-08-10T14:28:23Z","pushed_at":"2024-08-08T09:23:25Z","git_url":"git://github.com/google/go-github.git","ssh_url":"git@github.com:google/go-github.git","clone_url":"https://github.com/google/go-github.git","svn_url":"https://github.com/google/go-github","homepage":"https://pkg.go.dev/github.com/google/go-github/v63/github","size":6879,"stargazers_count":10234,"watchers_count":10234,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"has_discussions":false,"forks_count":2026,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":81,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"allow_forking":true,"is_template":false,"web_commit_signoff_required":false,"topics":["github","github-api","go","golang","hacktoberfest"],"visibility":"public","forks":2026,"open_issues":81,"watchers":10234,"default_branch":"master","permissions":{"admin":false,"maintain":false,"push":false,"triage":false,"pull":true},"temp_clone_token":"","custom_properties":{},"organization":{"login":"google","id":1342004,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNDIwMDQ=","avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"network_count":2026,"subscribers_count":211}`) |
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.
Instead of an actual response, how about if you just put one value of each type that you found, please?
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.
I minimized the json as you suggested to have a small partial project
Maybe @chapurlatn can review these changes? |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3230 +/- ##
==========================================
- Coverage 97.72% 92.94% -4.78%
==========================================
Files 153 171 +18
Lines 13390 11633 -1757
==========================================
- Hits 13085 10812 -2273
- Misses 215 727 +512
- Partials 90 94 +4 ☔ View full report in Codecov by Sentry. |
wantErr: false, | ||
}, | ||
"With custom properties": { | ||
data: []byte(`{"custom_properties":{"boolean":"false","text":"a","single-select":"a","multi-select":["a","b","c"]}}`), |
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.
How about this?
data: []byte(`{"custom_properties":{"boolean":"false","text":"a","single-select":"a","multi-select":["a","b","c"]}}`), | |
data: []byte(`{"custom_properties":{"boolean":false,"int":42,"key":"value","array":["a","b","c"]}}`), |
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 would imply that there is a possible integer value when there is non (that we know of). I used the different custom property types offered by GitHub (see here) and observed their representation in the api, using their label in the github ui as key for this json.
I guess it depends on whats the goal - testing that the unmarshalling works according to the type or testing the possible values that github could send for the given field. What do you think?
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 see, well at least please change the boolean from a string to false
without the quotes.
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.
GitHub returns the value for boolean type custom properties as strings ("true" or "false"). Should I remove the quotes regardless?
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.
Are you sure? We have hundreds of endpoints that return booleans, and none of them are strings.
What makes you say this? You made a boolean custom property and it is returning a string?!?
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.
Yes, I configured custom properties of all types and looked at the api response from github.
This is the actual response from the github api with one custom property (named accordingly) of each type configured:
{
// ...
"custom_properties": {
"type-multi-select": [
"a",
"b"
],
"type-single-select": "b",
"type-text": "lala",
"type-true-false": "true"
},
//...
}
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.
I'd love it if they would return an actual boolean here 😄
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, bizarre.
Then it looks like there is one linting failure remaining... let me look.
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.
It looks like the generated files are out-of-date if you could please update them.
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.
The whole integration of file generation is a really cool golang feature!
Just pushed the updated files 👍
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, @spalberg !
LGTM
Awaiting second LGTM+Approval from any other contributor to this repo before merging.
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
And yeah I remember when I was doing #3200 that a boolean
type custom property comes as string
from the GitHub API.
Thank you, @arymoraes ! |
Fixes: #3229.
BREAKING CHANGE:
PushEventRepository.CustomProperties
is changed frommap[string]string
tomap[string]interface{}
.adds tests for json unmarshalling of projects