-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Self-Hosted] Allow integrating with 'github.com' without a GitHub App #9231
Conversation
Left TODO:
EDIT: Second problem is, listing user repositories here:
is paginated -- we only get the first 30. We could use EDIT: Fixed ✅ |
a63a602
to
392eff3
Compare
dc4448e
to
b255b97
Compare
44212e2
to
0632c15
Compare
Alrighty, this is now ready for review! 🎉 Please take a look. 🙏 (Also, please disregard the merge conflict -- I had to base my PR on an older commit because preview envs got broken in main, but I'll rebase again before merging.) |
Thank you @jankeromnes ! 🚀 Will have a look later today 👀 |
Friendly ping @geropl 😇 🙏 |
Thx @jankeromnes ! still have it on the radar, but might get delayed until tomorrow. |
@jankeromnes Starting now. |
@@ -26,7 +26,8 @@ export class GitHubService extends RepositoryService { | |||
@inject(GithubContextParser) protected githubContextParser: GithubContextParser; | |||
|
|||
async getRepositoriesForAutomatedPrebuilds(user: User): Promise<ProviderRepository[]> { | |||
const repositories = (await this.githubApi.run(user, (gh) => gh.repos.listForAuthenticatedUser({}))).data; | |||
const octokit = await this.githubApi.create(user); | |||
const repositories = await octokit.paginate(octokit.repos.listForAuthenticatedUser, { per_page: 100 }); |
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.
Cool to see there is a library method for this! 👍
We could try to push our map
function into paginate
to be more conscious about memory usage: https://github.com/octokit/plugin-paginate-rest.js/#octokitpaginate.
Because we do not have a filterMap
, it could return ProviderRepository | undefined
, followed by a filter(repo => !!)
afterwards.
The reason I'm raising this seemingly minor issue is that when looking at COU profiles, our code is riddled with uncertainties about cardinality, leading to performance drops/spikes.
Also happy to review a follow up for this.
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.
Good point! I believe we can simply move our after-the-fact filter
into the octokit.paginate
call (not sure what you mean with a filterMap
, but I think a simple filter
might do the trick).
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 believe we can simply move our after-the-fact filter into the octokit.paginate
Ah, didn't look close enough to recognize it receives a response
, not an individual shape only - nice.
Next step - and the intent of my message - was to also move our map
function into paginate
, so we can drop all fields we do not need before accumulating them in the repositories
array. But again, this is more of a nit. Let's see to merge this as-is to not have us blocked longer than necessary by re-build issues 🙄
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.
Ah, whoops, the map
would indeed have a much stronger memory reduction effect than the filter
alone. 💡 Follow-up issue to the rescue!
EDIT: #9461
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.
Approving now despite the conflic because my test worked flawlessly, and I like the code as is!
Please ping once the conflict is resolved.
Rebased (without change) and moved the filter into octokit.paginate. Will request re-approval if the deployment still works. |
/werft run with-clean-slate-deployment=true 👍 started the job as gitpod-build-jx-no-app.16 I noticed this error in the previous 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.
Description
Allow integrating with 'github.com' without requiring a GitHub App. This simply reuses the same common code as GitLab, Bitbucket and GitHub Enterprise, i.e. API and webhooks.
Related Issue(s)
Fixes #9163
How to test
github.com
repos 🎉Release Notes
Documentation