-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add ProjectsService #3718
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
base: master
Are you sure you want to change the base?
Add ProjectsService #3718
Conversation
This PR won't be merged soon because the only one maintainer, @gmlewis, has lost access to the repo. See #3689 (comment) So, let's wait when @google-admin grants access, and then proceed with adding the feature. |
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, @JoannaaKL!
One tiny tweak, please, and then LGTM.
Could you also please rename the PR from "Add projects" to "Add ProjectsService
"?
Also, please note that I still don't have write access to this repo, but figure I might as well attempt to catch up on my code reviews (which I usually allow the linter to process first... ah, well). |
Hey hey @gmlewis 👋 . I renamed the pr, there's one more tiny change I need to do to this pr before it's ready - update the pagination parameters. I hope you get your access back soon! |
Thank you, @JoannaaKL! Me too!!! ❤️ |
73aeb75
to
3a8cf0c
Compare
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.
req.Header.Set("Accept", mediaTypeProjectsPreview)
should be removed.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3718 +/- ##
==========================================
+ Coverage 91.11% 91.15% +0.03%
==========================================
Files 187 188 +1
Lines 16702 16776 +74
==========================================
+ Hits 15218 15292 +74
Misses 1296 1296
Partials 188 188 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
One todo item I have to follow up on tomorrow is making sure the pagination is correct |
@JoannaaKL - could you please also update the branch with the latest changes from |
Hi @gmlewis I ran |
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, @JoannaaKL!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.
cc: @stevehipwell - @alexandear
@JoannaaKL - now that #3735 is merged, could you please merge master into this PR and revert all changes to |
Co-authored-by: Oleksandr Redko <[email protected]>
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 great + great feedback from others
github/projects.go
Outdated
// GitHub API docs: https://docs.github.com/rest/projects/projects#get-project-for-organization | ||
// | ||
//meta:operation GET /orgs/{org}/projectsV2/{project_number} | ||
func (s *ProjectsService) GetProjectForOrg(ctx context.Context, org string, projectNumber int64) (*ProjectV2, *Response, error) { |
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.
Perhaps the type of projectNumber
should be the same as the type of Number
in the ProjectV2
structure:
func (s *ProjectsService) GetProjectForOrg(ctx context.Context, org string, projectNumber int64) (*ProjectV2, *Response, error) { | |
func (s *ProjectsService) GetProjectForOrg(ctx context.Context, org string, projectNumber int) (*ProjectV2, *Response, error) { |
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.
Great catch, @alexandear! This made me curious if the Number
property ever might be as huge as an "id" and as far as I can tell, that is not the case, so I do NOT think both should be int64
, but instead both should be int
as you have suggested.
Thoughts, @JoannaaKL?
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 the GH API project's ID is a number
type and project_number
is an integer type. It can hold int64 actually. number
type can hold any number so yes, I think it should be equal to int 64 as it is now. So I don't think they should be set to int.
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 the GH API project's ID is a
number
type andproject_number
is an integer type. It can hold int64 actually.number
type can hold any number so yes, I think it should be equal to int 64 as it is now. So I don't think they should be set to int.
I think we may have a disconnect here.
The ProjectV2 struct
has these fields (among others):
ID *int64 `json:"id,omitempty"`
Number *int `json:"number,omitempty"`
IDs in this repo are (now) always of type int64
because we empirically discovered IDs from GitHub many years ago that did not fit within an int
, so that is our policy moving forward.
Other integers in this repo that we never expect to overflow an int
remain an int
because that is the natural and familiar integer type for Go programmers.
What we are saying here is that we believe the ProjectV2.Number
field should remain an int
and on line 136 above you currently have projectNumber int64
which does not match its corresponding field in the struct.
Therefore, we would like you to change projectNumber int64
to projectNumber int
to make the two of them match.
Does this make sense, @JoannaaKL?
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 was talking about types described in the doc https://docs.github.com/en/rest/projects/fields?apiVersion=2022-11-28
projectNumber
there is described as integer
and that type can hold int64 link (correct me if I am wrong).
@gmlewis @alexandear I have some feedback regarding the pr review process - it would be much more productive if you did one round of review and ask for changes instead of this ping-pong we are doing. In every review you leave more comments and questions, after they are resolved you add another one. I understand that you are busy and it's not easy to find the time but I don't think it is the best use of our time. |
Unfortunately, @JoannaaKL, after working on Open Source projects for 9 years now, this is the nature of the process. Everyone here is volunteering their own time apart from whatever other demands (like work, family, etc.) are upon them. And there are policies that have been put in place for maintenance of open source projects like this one where we require two approvals for non-trivial changes (such as this one) before merging. As witnessed by the history of this repo, I am far from perfect in my code reviews and others invariably find things that I have missed. So I apologize for the inconvenience we are causing you, but there is not a better process or solution that I am aware of. Also, we obviously have a significant disconnect above, as we are asking for what appears to me to be a simple change, but you are talking about the definition of numbers in swagger documentation which to me seems to be irrelevant. I believe that if we can resolve this issue, then this PR will be ready for merging, as we are so close. |
2f2c53a
to
5cc797e
Compare
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, @JoannaaKL!
LGTM.
@alexandear - do you approve this PR now?
// List projects for org; pick the first available project we can read. | ||
projects, _, err := client.Projects.ListProjectsForOrg(ctx, org, opts) | ||
if err != nil { | ||
// If listing itself fails, abort this test. |
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 comment is redundant and can be removed without worsing readability and maintanability.
|
||
proj, _, err := client.Projects.GetProjectForUser(ctx, user, *project.Number) | ||
if err != nil { | ||
// can't fetch specific project; treat as fatal |
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 do we need this comment?
// Integration tests for Projects V2 endpoints defined in github/projects.go. | ||
// | ||
// These tests are intentionally defensive. They only require minimal | ||
// environment variables identifying a target org and user. Project numbers are | ||
// discovered dynamically by first listing projects and selecting one. For item | ||
// CRUD operations, the test creates a temporary repository & issue (where | ||
// possible) and adds/removes that issue as a project item. If prerequisites | ||
// (auth, env vars, permissions, presence of at least one project) are missing, | ||
// the relevant sub-test is skipped so other integration tests can still run. | ||
// | ||
// Required / optional environment variables: | ||
// GITHUB_AUTH_TOKEN (required for any of these tests to run) | ||
// GITHUB_TEST_ORG (org login; required for org project tests) | ||
// GITHUB_TEST_USER (user login; required for user project tests) | ||
// GITHUB_TEST_REPO (repo name) |
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 propose splitting the comment into separate comments for TestProjectsV2_Org
and TestProjectsV2_User
. We don't need to mention GITHUB_AUTH_TOKEN
since it's documented in the README:
Line 32 in b7f068f
GITHUB_AUTH_TOKEN=XXX go test -v -tags=integration ./integration |
Co-authored-by: Oleksandr Redko <[email protected]>
Co-authored-by: Oleksandr Redko <[email protected]>
Co-authored-by: Oleksandr Redko <[email protected]>
Co-authored-by: Oleksandr Redko <[email protected]>
First chunk to support new GitHub Projects API:
Additionally I added an integration test for the new api - it was helpful for me to run it agains the real API and check if all fields make sense. Lmk if you want to keep it!