-
Notifications
You must be signed in to change notification settings - Fork 70
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
[wip] v3 effort #158
Draft
brendan-kellam
wants to merge
118
commits into
main
Choose a base branch
from
v3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
[wip] v3 effort #158
Changes from 2 commits
Commits
Show all changes
118 commits
Select commit
Hold shift + click to select a range
15b9e77
SQL Database (#157)
brendan-kellam 95f637f
point zoekt to v3 branch
brendan-kellam 3c3140e
bump zoekt version
msukkari 553f5d2
Add tenant ID concept into web app and backend (#160)
msukkari bd027f7
bump zoekt version
msukkari 7029aa7
parallelize repo indexing (#163)
msukkari 6cf10b4
Authentication (#164)
brendan-kellam 5d253ff
Add Org table (#167)
brendan-kellam a5091fb
Move logout button & profile picture into settings dropdown (#172)
brendan-kellam 7c6adf1
Multi tenancy support in config syncer (#171)
msukkari 738bbaa
add tenant mode support in docker container:
msukkari 9c120c6
Organization switching & active org management (#173)
brendan-kellam 8a3521b
updated syncedAt date after config sync:
msukkari a5006c5
Migrate to postgres (#174)
msukkari 0322cd8
Connection creation form (#175)
brendan-kellam ed0d28a
fix issue with yarn dev startup
brendan-kellam 78c9111
init (#176)
brendan-kellam bae7ca3
Add `@sourcebot/schemas` package (#177)
brendan-kellam dd8ff6e
Connection management (#178)
brendan-kellam 31114a9
add concept of secrets (#180)
msukkari a88f9e6
bump zoekt version
msukkari 75d4189
enforce tenancy on search and repo listing endpoints (#181)
msukkari dffbbae
adds garbage collection for repos (#182)
msukkari 9946901
add initial logic for staging environment
msukkari f92acc0
try to move encryption key env decleration in docker file to fix buil…
msukkari 92530a7
switch encryption key as build arg to se if that fixes build issues
msukkari 2b6125b
add deployment action for staging image
msukkari d37a969
try using mac github action runners instead
msukkari d513f93
switch to using arm64 runners on arm64 build
msukkari bb4ff37
change workflow names to fix trigger issue
msukkari 22e0096
trigger staging actions to see if it works
msukkari 7b6226b
fix working directory typo and pray it doesnt push to prod
msukkari 44dd53f
checkout v3 when deploying staging
msukkari 4e7ac93
try to change into the staging dir manuall
msukkari 94908c0
dummy commit to trigger v3 workflows to test
msukkari 4d4988d
update staging deploy script to match new version in main
msukkari 829eede
reference proper image:tag in staging fly config
msukkari afff36f
update staging fly config to point to ghcr
msukkari 846d73b
Connection management (#183)
brendan-kellam 9055018
add invite system and google oauth provider (#185)
msukkari 70f7729
fix reference to header component in connections
msukkari 5858e31
add google logo to google oauth
msukkari 7da8a7f
fix web build errors
msukkari 775138c
bump staging resources
msukkari 568ded8
change staging cpu to perf
msukkari 23f3c60
add side bar nav in settings page
msukkari 04991fd
improve styling of members page
msukkari fde2179
wip adding stripe checkout button
msukkari 9665f14
wip onboarding flow
msukkari 33ae585
add stripe subscription id to org
msukkari e7f8f51
save stripe session id and add manage subscription button in settings
msukkari 3ad6c2d
properly block access to pages if user isn't in an org
msukkari 0a79f7c
wip add paywall
msukkari 8d2c731
Domain support
brendan-kellam 34c9c1d
Domain support (#188)
brendan-kellam ac15b7c
Update Makefile to include crypto package when doing a make clean
brendan-kellam e0976e4
Add default for AUTH_URL in attempt to fix build
brendan-kellam d17c90a
attempt 2
brendan-kellam 98becf5
fix attempt #3: Do not require a encrpytion key at build time
brendan-kellam 53dac38
merge domain changes
msukkari ba333dd
Fix generate script race condition
brendan-kellam 19780aa
Attempt #4
brendan-kellam 6caed35
add back paywall and also add support for incrememnting seat count on…
msukkari 8ad6ba7
prevent self invite
msukkari 258585e
action button styling in settings and toast on copy
msukkari 84e8ec2
add ability to remove member from org
msukkari 0b4140f
move stripe product id to env var
msukkari 875f9b8
add await for blocking loop in backend
msukkari 193c7e0
add subscription info to billing page
msukkari e2c90b8
handle trial case in billing info page
msukkari 8929d05
add trial duration indicator to nav bar
msukkari a70c577
merge v3 changes into billing branch
msukkari 5a3eab2
check if domain starts or ends with dash
msukkari e369925
remove unused no org component
msukkari e6ee45c
Generate AUTH_SECRET if not provided (#189)
brendan-kellam b0cbcf0
remove package lock file and fix prisma dep version
msukkari d463748
revert dep version updates
msukkari 4c0805c
fix yarn.lock
brendan-kellam 0f43c00
add auth and membership check to fetchSubscription
msukkari cf97955
properly handle invite redeem with no valid subscription case
msukkari ea4c29d
change back fetch subscription to not require org membership
msukkari 87efbf7
add back subscription check in invite redeem page
msukkari 7c18712
Add stripe billing logic (#190)
msukkari 674511a
fix nits
msukkari 8fb438b
remove providers check
brendan-kellam fbd3e41
fix more nits
msukkari 6234967
merge v3 changes
msukkari 888a2e3
change stripe init to be behind function
msukkari 26cc70c
fix publishible stripe key handling in docker container
msukkari e2e5433
enforce owner perms (#191)
msukkari da33220
add back gitlab, gitea, and gerrit support (#184)
msukkari 4cf3024
fix apos usage in redeem page
msukkari 354b004
change csrf cookie to secure not host
msukkari 86a80a4
Credentials provider (#192)
brendan-kellam 3be3680
cleanup org's repos and shards if it's inactive (#194)
msukkari e0d3634
connections qol improvements (#195)
msukkari 2111a77
Fix build with suspense boundary
brendan-kellam 331a418
improved fix
brendan-kellam 54d14ea
add retries for 429 issues (#196)
msukkari e17331a
fix build errors and add index concurrency env var
msukkari e09b21f
add config upsert timeout env var
msukkari f652ca5
Membership settings rework (#198)
brendan-kellam bbf8b9b
Magic links (#199)
brendan-kellam 390d92d
Fix build
brendan-kellam 5d7a77b
db performance improvements and job resilience (#200)
msukkari 63af99a
remove non secret token options
msukkari b99a648
fix token examples in schema
msukkari fdd71cf
add better visualization for connection/repo errors and warnings (#201)
msukkari 62e64c1
add orgid unique constraint to repo
msukkari c930fe0
revert repo compile update logic to upsert loop
msukkari 0ac9509
log upsert stats
msukkari 5076ee7
[temp] disable polling everywhere (#205)
brendan-kellam a79c162
add health check endpoint
msukkari fee0767
Refined onboarding flow (#202)
brendan-kellam 70e309b
Redeem UX pass (#204)
brendan-kellam fa0bb82
add log for health check
msukkari dc42a76
fix new connection complete callback route
msukkari ced6c52
add cpu split logic and only wait for postgres if we're going to conn…
msukkari File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
[submodule "vendor/zoekt"] | ||
path = vendor/zoekt | ||
url = https://github.com/sourcebot-dev/zoekt | ||
# @nocheckin : update this to main when we have a release | ||
branch=v3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
import { PrismaClient } from '@sourcebot/db'; | ||
import { readFile } from 'fs/promises'; | ||
import stripJsonComments from 'strip-json-comments'; | ||
import { getGitHubReposFromConfig } from "./github.js"; | ||
import { getGitLabReposFromConfig, GITLAB_CLOUD_HOSTNAME } from "./gitlab.js"; | ||
import { SourcebotConfigurationSchema } from "./schemas/v2.js"; | ||
import { AppContext } from "./types.js"; | ||
import { getTokenFromConfig, isRemotePath, marshalBool } from "./utils.js"; | ||
|
||
export const syncConfig = async (configPath: string, db: PrismaClient, signal: AbortSignal, ctx: AppContext) => { | ||
const configContent = await (async () => { | ||
if (isRemotePath(configPath)) { | ||
const response = await fetch(configPath, { | ||
signal, | ||
}); | ||
if (!response.ok) { | ||
throw new Error(`Failed to fetch config file ${configPath}: ${response.statusText}`); | ||
} | ||
return response.text(); | ||
} else { | ||
return readFile(configPath, { | ||
encoding: 'utf-8', | ||
signal, | ||
}); | ||
} | ||
})(); | ||
|
||
// @todo: we should validate the configuration file's structure here. | ||
const config = JSON.parse(stripJsonComments(configContent)) as SourcebotConfigurationSchema; | ||
|
||
for (const repoConfig of config.repos ?? []) { | ||
switch (repoConfig.type) { | ||
case 'github': { | ||
const token = repoConfig.token ? getTokenFromConfig(repoConfig.token, ctx) : undefined; | ||
const gitHubRepos = await getGitHubReposFromConfig(repoConfig, signal, ctx); | ||
const hostUrl = repoConfig.url ?? 'https://github.com'; | ||
const hostname = repoConfig.url ? new URL(repoConfig.url).hostname : 'github.com'; | ||
|
||
await Promise.all(gitHubRepos.map((repo) => { | ||
const repoName = `${hostname}/${repo.full_name}`; | ||
const cloneUrl = new URL(repo.clone_url!); | ||
if (token) { | ||
cloneUrl.username = token; | ||
} | ||
|
||
const data = { | ||
external_id: repo.id.toString(), | ||
external_codeHostType: 'github', | ||
external_codeHostUrl: hostUrl, | ||
cloneUrl: cloneUrl.toString(), | ||
name: repoName, | ||
isFork: repo.fork, | ||
isArchived: !!repo.archived, | ||
metadata: { | ||
'zoekt.web-url-type': 'github', | ||
'zoekt.web-url': repo.html_url, | ||
'zoekt.name': repoName, | ||
'zoekt.github-stars': (repo.stargazers_count ?? 0).toString(), | ||
'zoekt.github-watchers': (repo.watchers_count ?? 0).toString(), | ||
'zoekt.github-subscribers': (repo.subscribers_count ?? 0).toString(), | ||
'zoekt.github-forks': (repo.forks_count ?? 0).toString(), | ||
'zoekt.archived': marshalBool(repo.archived), | ||
'zoekt.fork': marshalBool(repo.fork), | ||
'zoekt.public': marshalBool(repo.private === false) | ||
}, | ||
}; | ||
|
||
return db.repo.upsert({ | ||
where: { | ||
external_id_external_codeHostUrl: { | ||
external_id: repo.id.toString(), | ||
external_codeHostUrl: hostUrl, | ||
}, | ||
}, | ||
create: data, | ||
update: data, | ||
}) | ||
})); | ||
|
||
break; | ||
} | ||
case 'gitlab': { | ||
const hostUrl = repoConfig.url ?? 'https://gitlab.com'; | ||
const hostname = repoConfig.url ? new URL(repoConfig.url).hostname : GITLAB_CLOUD_HOSTNAME; | ||
const token = repoConfig.token ? getTokenFromConfig(repoConfig.token, ctx) : undefined; | ||
const gitLabRepos = await getGitLabReposFromConfig(repoConfig, ctx); | ||
|
||
await Promise.all(gitLabRepos.map((project) => { | ||
const repoName = `${hostname}/${project.path_with_namespace}`; | ||
const isFork = project.forked_from_project !== undefined; | ||
|
||
const cloneUrl = new URL(project.http_url_to_repo); | ||
if (token) { | ||
cloneUrl.username = 'oauth2'; | ||
cloneUrl.password = token; | ||
} | ||
|
||
const data = { | ||
external_id: project.id.toString(), | ||
external_codeHostType: 'gitlab', | ||
external_codeHostUrl: hostUrl, | ||
cloneUrl: cloneUrl.toString(), | ||
name: repoName, | ||
isFork, | ||
isArchived: project.archived, | ||
metadata: { | ||
'zoekt.web-url-type': 'gitlab', | ||
'zoekt.web-url': project.web_url, | ||
'zoekt.name': repoName, | ||
'zoekt.gitlab-stars': project.star_count?.toString() ?? '0', | ||
'zoekt.gitlab-forks': project.forks_count?.toString() ?? '0', | ||
'zoekt.archived': marshalBool(project.archived), | ||
'zoekt.fork': marshalBool(isFork), | ||
'zoekt.public': marshalBool(project.visibility === 'public'), | ||
} | ||
} | ||
|
||
return db.repo.upsert({ | ||
where: { | ||
external_id_external_codeHostUrl: { | ||
external_id: project.id.toString(), | ||
external_codeHostUrl: hostUrl, | ||
}, | ||
}, | ||
create: data, | ||
update: data, | ||
}) | ||
})); | ||
|
||
break; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nocheckin