-
Notifications
You must be signed in to change notification settings - Fork 120
v3 effort #158
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
Merged
Merged
v3 effort #158
Changes from 4 commits
Commits
Show all changes
247 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 0ff34d1
Inline secret creation (#207)
brendan-kellam bf8bfdb
use docker scopes to try and improve caching
brendan-kellam e648ed3
Dummy change
brendan-kellam d70b729
remove cpu split logic
msukkari ce52f65
Add some instrumentation to web
brendan-kellam de44c81
add posthog events on various user actions (#208)
msukkari 69db8f2
fix merge error
msukkari 07cafdd
use staging posthog papik when building staging image
msukkari e1f7cd9
fix other merge error and build warnings
msukkari 72da582
Add invite email (#209)
brendan-kellam 04f6772
wrap posthog provider in suspense to fix build error
msukkari fc33f26
add grafana alloy config and setup (#210)
msukkari 07863b2
remove invalid characters when auto filling domain
msukkari f853335
add login posthog events
msukkari 88fe84e
remove hard coded sourcebot.app references
msukkari 3f586dd
make repo garbage collection async (#211)
msukkari 5c2bf01
fix typo in trial card
msukkari fab2fea
onboarding tweaks
brendan-kellam 8531b14
rename some prom metrics and cleanup unused
msukkari b77f55f
wipe existing repo if we've picked up a killed job to ensure good state
msukkari 50b94b2
Connections UX pass + query optimizations (#212)
brendan-kellam 386a3b5
remove git & local schemas (#213)
brendan-kellam 4869137
skip stripe checkout for trial + fix indexing in progress UI + additi…
msukkari 6316166
fix skipping onboard complete check
msukkari c0b62a2
fix build error
msukkari 3d6c7dc
add back button in onboard connection creation flow
msukkari 46be044
Add back revision support (#215)
brendan-kellam fcf0b83
fix build
brendan-kellam 85d7b1e
Fix bug with repository snapshot
brendan-kellam cfff416
fix share links
brendan-kellam d0b75ce
fix repo rm issue, 502 page, condition on test clock
msukkari 161f21e
Make login and onboarding mobile friendly
brendan-kellam 8b44505
fix ordering of quick actions
msukkari 7ce1067
remove error msg dump on failed repo index job, and update indexedAt …
msukkari b935234
Add mobile unsupported splash screne
brendan-kellam 1bdb65c
cherry pick fix for file links
msukkari e1533f2
[Cherry Pick] Syntax reference guide (#169) (#216)
brendan-kellam 6d3be81
Add .env to db gitignore
brendan-kellam 5006a93
fix case where we have repos but they're all failed for repo snapshot
msukkari 83ab0a0
/settings/secrets page (#217)
brendan-kellam cdfcb5a
display domain properly in org create form
msukkari 7685d9c
Quick action tweaks (#218)
brendan-kellam bdab90b
revamp repo page (#220)
msukkari 8f6052c
fix (#219)
brendan-kellam 4093442
remove / keyboard shortcut hint in search bar
msukkari 072f77b
prevent switching to first page on data update and truncate long repo…
msukkari 041eab1
General settings + cleanup (#221)
brendan-kellam 8b9a469
First attempt at sending logs to grafana
brendan-kellam a5fdcb3
logs wip
brendan-kellam 6edfb1b
add alloy logs
brendan-kellam 4c4482d
wip
brendan-kellam 06ba66d
[temp] comment out loki for now
brendan-kellam b527ec4
update trial card content and add events for code host selection on o…
msukkari c841894
reduce scraping interval to 15s
brendan-kellam 51186fe
Add prometheus metric for pending repo indexing jobs
brendan-kellam ff35056
switch magic link to invite code (#222)
msukkari 47b3e1a
remove unused middleware file
msukkari ec5ec9d
fix build error and warnings
msukkari 85c21a2
fix build error with useSearchParam not wrapped in suspense
msukkari a93ee65
add sentry support to backend and webapp (#223)
msukkari 7307134
Fix root domain issue on onboarding
brendan-kellam 7253c5a
add setup sentry cli step to github action
msukkari 36f79d7
login to sentry
msukkari 20eac7b
fix sentry login in action
msukkari 99fda9a
Update grafana loki endpoint
brendan-kellam d33185c
switch source map publish to runtime in entrypoint
msukkari b27507e
catch and rethrow simplegit exceptions
msukkari 806db26
alloy nits
brendan-kellam d281523
fix alloy
brendan-kellam c48c093
backend logging (#224)
brendan-kellam 274b635
revert grafana loki config
brendan-kellam 66c8c74
fix login ui nits
msukkari 5ea7197
fix quick actions
brendan-kellam 395afcf
fix typo in secret creation
msukkari d920d0d
fix private repo clone issue for gitlab
brendan-kellam d439933
add repo index timeout logic
msukkari eab0007
add posthog identify call after registeration
msukkari a212e85
various changes to add terms and security info (#225)
msukkari 49e24e8
fix build error
msukkari e82c5e4
nit fix: center 'get in touch' on security card
brendan-kellam 2286d94
Dark theme improvements (#226)
brendan-kellam 98a662c
(fix) Fixed bug with gitlab and gitea not including hostname in the r…
brendan-kellam e8acfcc
Merge branch 'main' into v3
brendan-kellam 483217b
Switch to using t3-env for env-var management (#230)
brendan-kellam 600cefb
Add missing env var
brendan-kellam 98ec2c9
fix build
brendan-kellam ad60c5f
Centralize to using a single .env.development for development workflo…
brendan-kellam e8667da
Make billing optional (#232)
brendan-kellam 583df1d
Massage environment variables from strings to numbers (#234)
brendan-kellam 4ecd700
Single tenancy & auth modes (#233)
brendan-kellam dd49375
Add docs to this repo
brendan-kellam 2b17fd6
dummy change
brendan-kellam 4c52059
Declarative connection configuration (#235)
brendan-kellam 338993e
fix build
brendan-kellam 98abe23
upgrade to next 14.2.25
msukkari 023edd1
Improved database DX
brendan-kellam 484aea8
migrate to yarn v4
brendan-kellam 7d0540d
Use origin from header for baseUrl of emails (instead of AUTH_URL). A…
brendan-kellam d8fd958
Remove SOURCEBOT_ENCRYPTION_KEY from build arg
brendan-kellam c892268
Fix issue with linking default user to org in single tenant + no-auth…
brendan-kellam 8b65a1d
Fix fallback tokens (#242)
brendan-kellam fda7986
add SECURITY_CARD_ENABLED flag
msukkari f4db3d2
Add repository weburl (#243)
brendan-kellam 92a8138
Random fixes and improvements (#244)
brendan-kellam b099b4a
add zoekt max wall time env var
msukkari c42bc97
remove empty warning in docs
msukkari a1b5d98
fix reference in sh docs
msukkari 691c593
add connection manager upsert timeout env var
msukkari 27a1066
Declarative connection cleanup + improvements (#245)
brendan-kellam 78b8916
change contact us footer in app to point to main contact form
msukkari 8e3235a
PostHog event pass (#246)
brendan-kellam 889d488
fix typo
brendan-kellam df357e7
Add sourcebot cloud environment prop to staging workflow
brendan-kellam c2a129a
Update generated files
brendan-kellam 1f4a5ae
remove AUTH_URL since it unused and (likely) unnecessary
brendan-kellam 47bbad5
Revert "remove AUTH_URL since it unused and (likely) unnecessary"
brendan-kellam af2d123
cleanup GitHub action releases (#252)
brendan-kellam ba1e438
remove alloy, change auth defaul to disabled, add settings page in me…
msukkari 2c0cd1a
enforce connection management perms to owner (#253)
msukkari 23644a9
add CONTRIBUTING.md file
msukkari 82f9d8b
hide settings in dropdown with auth isnt enabled
msukkari 3b61138
handle case where gerrit weburl is just gitiles path
msukkari 725ef80
Docs overhall (#251)
brendan-kellam 6230b13
Merge branch 'main' into v3
brendan-kellam 0ea9620
remove nocheckin
brendan-kellam 0ac2fa7
fix build error
msukkari 84968e4
remove v3 trigger from deploy staging
brendan-kellam e7dd35b
fix build errors round 2
msukkari 4fe85f9
another error fix
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,137 @@ | ||
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'; | ||
const tenantId = repoConfig.tenantId ?? 0; | ||
|
||
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, | ||
tenantId: tenantId, | ||
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, | ||
tenantId: 0, // TODO: add support for tenantId in GitLab config | ||
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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.