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

[projects] enable webhook registration for bitbucket.org and self-managed gitlab #7422

Merged
merged 1 commit into from
Jan 4, 2022

Conversation

AlexTugarev
Copy link
Member

@AlexTugarev AlexTugarev commented Jan 3, 2022

fixes #7367
fixes #7416

Fixes registration of webhooks for projects hosted on bitbucket.org and self-managed gitlab.

@gtsiolis
Copy link
Contributor

gtsiolis commented Jan 3, 2022

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 for picking this up, @AlexTugarev! Works as expected, this makes everything one step closer to having a consistent product behavior across GitLab and Bucket that require the webshook! 🔮

🍊 🍊 🍊 🍊

Opened some follow-up issues that can be considered out of the scope of this PR: #7424, #7425, #7426. Feedback is welcome!

🍋 🍋 🍋 🍋

Approving to unblock merging but holding in case we need someone from the team to take a closer look at the code changes.

/hold

@@ -115,7 +115,7 @@ export class ProjectsService {
protected async onDidCreateProject(project: Project, installer: User) {
let { userId, teamId, cloneUrl } = project;
const parsedUrl = RepoURL.parseRepoUrl(project.cloneUrl);
if ("gitlab.com" === parsedUrl?.host) {
if ("gitlab.com" === parsedUrl?.host || "bitbucket.org" === parsedUrl?.host) {
Copy link
Contributor

Choose a reason for hiding this comment

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

issue(non-blocking): Prebuilds are still not enabled for the default branch for GitLab and Bitbucket repositories but certainly out of the scope of this PR. ➿

Copy link
Member Author

Choose a reason for hiding this comment

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

That's interesting. Is this already planned/discussed/tracked somewhere in a GH issue?

Copy link
Contributor

Choose a reason for hiding this comment

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

@AlexTugarev I could be missing something but I've added #7424 to continue the discussion about this issue there. Up for closing it if the issue is not accurate or valid. 🏀

@roboquat
Copy link
Contributor

roboquat commented Jan 3, 2022

LGTM label has been added.

Git tree hash: cc0187c12c0ccb3fb53f4470a56675673090ab6e

@gtsiolis
Copy link
Contributor

gtsiolis commented Jan 3, 2022

Also, a good follow up step after this could be to consider removing the webhook (#5517) when the project is removed from the dashboard, right? What do you think? Cc @jldec

@jldec
Copy link
Contributor

jldec commented Jan 3, 2022

@gtsiolis enabling prebuilds on all branches on Bitbucket should be part of fixing #7367 see comment

Keeping in mind that there are overhead costs to creating and tracking new issues, let's avoid spawning followup issues to followup issues, when asking for clarification in the issue at hand would suffice.

(similar feedback applies to self-hosted GitLab and #7416)

@gtsiolis
Copy link
Contributor

gtsiolis commented Jan 3, 2022

... enabling prebuilds on all branches on Bitbucket should be part of fixing #7367

@jldec I agree but not entirely sure if there was a background decision for not enabling prebuilds for all branches by default, see relevant docs:

github:
  prebuilds:
    # enable for the default branch (defaults to true)
    master: true
    # enable for all branches in this repo (defaults to false)
    branches: false
    # enable for pull requests coming from this repo (defaults to true)
    pullRequests: true
    # enable for pull requests coming from forks (defaults to false)
    pullRequestsFromForks: false
    # add a check to pull requests (defaults to true)
    addCheck: true
    # add a "Review in Gitpod" button as a comment to pull requests (defaults to false)
    addComment: false
    # add a "Review in Gitpod" button to the pull request's description (defaults to false)
    addBadge: false

Also, I'm probably wrong here but this was most probably an efficient solution to 🅰️ avoid creating prebuilds for all branches while users were not using the product for other branches and 🅱️ introducing sensible defaults as prebuilds make more sense for the default branch which was probably the most common context for new workspaces.

question: Maybe we could a) gather some usage data metrics or b) get an implementation estimation before making the final call?

Keeping in mind that there are overhead costs to creating and tracking new issues, let's avoid spawning followup issues to followup issues, when asking for clarification in the issue at hand would suffice.

Fair point! 🤝

I still think there's a lot of value in breaking tasks is smaller follow-up issues in case the implementation overhead increases the risk of scope creep for a PR, even if the initial PR solves the follow up issue, but I agree this could be tackled in #7367.

question: Do you think we could try to tackle also #4353 within #7367?

@roboquat roboquat removed the lgtm label Jan 4, 2022
@AlexTugarev AlexTugarev changed the title [projects] enable webhook registration for bitbucket.org [projects] enable webhook registration for bitbucket.org and self-managed gitlab Jan 4, 2022
@AlexTugarev AlexTugarev requested a review from gtsiolis January 4, 2022 10:00
@AlexTugarev
Copy link
Member Author

AlexTugarev commented Jan 4, 2022

@jldec and @gtsiolis, great questions and discussion so far, and I'm looking forward to clean up the differences between repo providers 🙏🏻 obviously, it makes sense to have a similar behavior from the product perspective.

for the scope of this PR, I'd like to move forward if you think it solves the two mentioned issues as described.

@jldec
Copy link
Contributor

jldec commented Jan 4, 2022

Yes, thanks @AlexTugarev

@AlexTugarev
Copy link
Member Author

I will try with GitLab self-hosted as well if you could register an instance.

We can try with the internal test installation, though it's not required because the implementation now checks for the provider type (and not for the host name,) so if it works with gitlab.com it should work with mygitlab.com as well.

const repositoryService = this.hostContextProvider.get(parsedUrl?.host)?.services?.repositoryService;
const hostContext = parsedUrl?.host ? this.hostContextProvider.get(parsedUrl?.host) : undefined;
const type = hostContext && hostContext.authProvider.info.authProviderType;
if (type === "GitLab" || type === "Bitbucket") {
Copy link
Member Author

Choose a reason for hiding this comment

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

@jldec, this is the change which treats all GItLab installations equal, so testing with gitlab.com should be enough.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok - i'll wait for staging to test :)

@jldec
Copy link
Contributor

jldec commented Jan 4, 2022

/lgtm

@roboquat
Copy link
Contributor

roboquat commented Jan 4, 2022

LGTM label has been added.

Git tree hash: 19b26abbdb22da5b2a4c85c92f9643985a4463e2

@roboquat
Copy link
Contributor

roboquat commented Jan 4, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gtsiolis, jldec

Associated issue: #7367

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

@jldec
Copy link
Contributor

jldec commented Jan 4, 2022

/unhold

@roboquat roboquat merged commit 911d00e into main Jan 4, 2022
@roboquat roboquat deleted the at/bb-webhooks branch January 4, 2022 15:43
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Jan 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note size/XS team: webapp Issue belongs to the WebApp team
Projects
None yet
4 participants