Skip to content
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

Import GitLab projects #5120

Merged
merged 1 commit into from
Aug 20, 2021
Merged

Import GitLab projects #5120

merged 1 commit into from
Aug 20, 2021

Conversation

AlexTugarev
Copy link
Member

@AlexTugarev AlexTugarev commented Aug 9, 2021

This PR enables importing of GitLab repositories as projects into Gitpod.

Your GitLab account needs to have at the access level of a maintainer in order to install webhooks for prebuilds. That's also a filter criteria for repositories to be choose from.

Screen Shot 2021-08-09 at 17 06 51

Closes #5278

import { Gitlab } from "@gitbeaker/node";

@injectable()
export class GitLabAppSupport {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The separation in EE and non-EE and the scope of the GitLabService binding makes it impossible to use that for the additions, unfortunately.

Copy link
Contributor

@gtsiolis gtsiolis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank for pushing this forward @AlexTugarev! 🍊

Not sure if this was ready to review but left some early comments below. 🍋

components/dashboard/src/projects/NewProject.tsx Outdated Show resolved Hide resolved
@inject(UserDB) protected readonly userDB: UserDB;
@inject(TokenProvider) protected readonly tokenProvider: TokenProvider;

async getProviderRepositoriesForUser(params: { user: User, provider: string, hints?: object }): Promise<ProviderRepository[]> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: This is probably minor for this iteration, as this is an edge case, but it takes 5-6 seconds for me to load the next step. FWIW, I'm a member of ~30 groups. In the future a loading indicator could help.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank for the hint. Just addmin perPage: 100 to override the default value of 20. That should be significant improvement in your case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @AlexTugarev! Seems 2x faster! FWIW, Still taking 2-3 seconds.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. How many projects do you see there? According to the logs, each API response takes ~600ms, which is really slow.

Copy link
Contributor

@gtsiolis gtsiolis Aug 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most groups contain less than 10 projects. For the personal account all projects (38) are listed. 💯

thought: I think the delay happens while fetching all groups or the ones with proper permissions and maybe because the account is a direct member of the gitlab-org group which contains 300+ second-level groups including public and private groups. Tried this with a test account and groups and projects loaded in under 1 second. 🎉

components/server/ee/src/container-module.ts Show resolved Hide resolved
@jankeromnes
Copy link
Contributor

jankeromnes commented Aug 13, 2021

Removing the automatic review request because this is still Draft. 😊

@jankeromnes jankeromnes removed their request for review August 13, 2021 13:16
@AlexTugarev AlexTugarev force-pushed the at/gitlab-projects branch 2 times, most recently from 5b87dab to f6990e7 Compare August 16, 2021 09:19
@roboquat roboquat added size/L and removed size/M labels Aug 16, 2021
@inject(UserDB) protected readonly userDB: UserDB;
@inject(TokenProvider) protected readonly tokenProvider: TokenProvider;

async getProviderRepositoriesForUser(params: { user: User, provider: string, hints?: object }): Promise<ProviderRepository[]> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @AlexTugarev! Seems 2x faster! FWIW, Still taking 2-3 seconds.

@roboquat roboquat added size/XL and removed size/L labels Aug 17, 2021
@AlexTugarev AlexTugarev changed the title WIP Import GitLab projects Import GitLab projects Aug 17, 2021
@AlexTugarev
Copy link
Member Author

/hold

@AlexTugarev AlexTugarev force-pushed the at/gitlab-projects branch 2 times, most recently from 79d9a8f to 55b86f3 Compare August 17, 2021 12:21
@gtsiolis
Copy link
Contributor

gtsiolis commented Aug 17, 2021

Looking at this now! 👀

Copy link
Contributor

@gtsiolis gtsiolis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @AlexTugarev! 🦊

Did another pass and left some comments below. 🏀

components/dashboard/src/projects/NewProject.tsx Outdated Show resolved Hide resolved
components/dashboard/src/projects/NewProject.tsx Outdated Show resolved Hide resolved
@@ -322,7 +371,7 @@ export default function NewProject() {

return (<div className="flex flex-col w-96 mt-24 mx-auto items-center">
<h1>New Project</h1>
<p className="text-gray-500 text-center text-base">Select a git repository.</p>
<p className="text-gray-500 text-center text-base">Select a git repository on <strong>{provider}</strong>.</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Worth linking to the provider itself? Feel free to ignore if it does not seem helpful.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi: Opened follow up issue in #5333

{icon && (
<img src={icon} className="rounded-full w-6 h-6 absolute top-1/4 left-4" />
)}
<input className="w-full px-12 cursor-pointer font-semibold" readOnly type="text" value={selectedAccount || ""}></input>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: Is it expected that group avatars fail to load for groups? It seems that shared projects with write access on personal accounts successfully fetch the avatars.

Missing avatars on groups (a) Missing avatars on personal accounts (b)
Screenshot 2021-08-17 at 5 44 31 PM Frame 34

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed :-(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi: Opened follow up issue in #5330.

<img src={CaretDown} title="Select Account" className="filter-grayscale absolute top-1/2 right-3" />
const renderRepos = () => (<>
<div className={`mt-10 border ${isGitHub() ? "rounded-t-xl border-b-0" : "rounded-xl"} border-gray-100 flex-col`}>
<div className="px-8 pt-8 flex flex-col space-y-2">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: For some reason, the pre-selected account is a specific but maybe random group. Does it make sense to default to pre-selecting your own account?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaulting to own account sounds good.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DEAL. Let's do this here or open a follow up issue to fine tune this later! Your call. 📞

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi: Opened follow up issue in #5331.

@AlexTugarev AlexTugarev force-pushed the at/gitlab-projects branch 2 times, most recently from 38e3465 to 8608b77 Compare August 18, 2021 07:26
@AlexTugarev
Copy link
Member Author

question: Did we remove the loading placeholder?

@gtsiolis, thanks for the reminder! first I thought it got so fast, that it's no longer needed ;-)
It should be back in with the last update.

@AlexTugarev
Copy link
Member Author

Known issue: wrong width for the bottom section.

Screen Shot 2021-08-19 at 17 52 32

@gtsiolis, wdyt of getting rid of the grayish background and render as simple as in #5120 (comment)?

@jankeromnes
Copy link
Contributor

jankeromnes commented Aug 19, 2021

Many thanks for adding GitLab support! 💯 🎆

I briefly skimmed the code, but I'm unfamiliar with the GitLab integration code and didn't have time to read more deeply into it.

I also briefly tested this PR:

  1. Connected both GitHub and GitLab accounts
  2. Tried to create a new project for my user
  3. There is a new loading state before anything shows up (empty list felt better)
  4. It shows me this -- it feels I don't get the choice between GitHub or GitLab?

Screenshot 2021-08-19 at 18 10 19

  1. Adding one of the proposed GitLab project seems to work well 🎉 (the old Configurator is even able to fetch the config)

Screenshot 2021-08-19 at 18 14 50

  1. Trying again a few times, I randomly stumbled on this hidden option to add GitHub projects and not GitLab -- feels like this should be placed somewhere much more obvious (e.g. a simple "change" link right after "Select a git repository on gitlab.com")

Screenshot 2021-08-19 at 18 16 10

  1. Authorizing GitHub didn't work (but I guess that's expected since it's not the focus of this PR -- still would have been cool to test GitLab and GitHub projects together)

Screenshot 2021-08-19 at 18 17 49

  1. It doesn't even take that long to add the GitLab repo itself 💪 (took barely a few seconds to import the project and load the config)

Screenshot 2021-08-19 at 18 19 06

@AlexTugarev AlexTugarev force-pushed the at/gitlab-projects branch 2 times, most recently from 1ad647a to 25b6037 Compare August 20, 2021 06:54
@AlexTugarev
Copy link
Member Author

AlexTugarev commented Aug 20, 2021

/werft run

👍 started the job as gitpod-build-at-gitlab-projects.31

protected async onDidCreateProject(project: Project) {
let { userId, teamId, cloneUrl } = project;
const parsedUrl = parseRepoUrl(project.cloneUrl);
if ("gitlab.com" === parsedUrl?.host) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should work with self-managed gitlab's as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi: There's a follow up issue for self hosted support in #5115. Cc @svenefftinge

Copy link
Member

@svenefftinge svenefftinge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and works well with gitlab.com. From the code besides one place it looks like it should work with self-managed GitLab's too.

@roboquat
Copy link
Contributor

LGTM label has been added.

Git tree hash: 22ca396613977b4cf0d10117e4d89c57daa1e41a

@roboquat
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: svenefftinge

Associated issue: #5278

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@AlexTugarev
Copy link
Member Author

From the code besides one place it looks like it should work with self-managed GitLab's too.

@svenefftinge, have you tested prebuilds with self-managed GitLabs?

@AlexTugarev
Copy link
Member Author

/hold cancel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Highlight the default branch for GitLab projects in branches Add support for importing GitLab projects
5 participants