Commit Graph

37644 Commits

Author SHA1 Message Date
Robert Lin
082535836a
feat/enterpriseportal: add instance category (#64253)
Per some feedback around
https://docs.google.com/document/d/1NyBIQvZ-ziNhiz7Yuzbp4f72Gp6EUrVUoBYnnnviXi8/edit,
this adds a "instance type" enumeration for each subscription:

1. PRIMARY: production
2. SECONDARY: dev/testing/staging/whatever
3. INTERNAL: for us

## Test plan

Updated tests
2024-08-09 18:19:51 -07:00
Robert Lin
e2c646ad92
feat/enterpriseportal: all subscriptions APIs use enterprise portal DB (#63959)
This change follows
https://github.com/sourcegraph/sourcegraph/pull/63858 by making the
_all_ subscriptions APIs read and write to the Enterprise Portal
database, instead of dotcomdb, using the data that we sync from dotcomdb
into Enterprise Portal.

With this PR, all initially proposed subscriptions APIs are at least
partially implemented.

Uses https://github.com/hexops/valast/pull/27 for custom `autogold`
rendering of `utctime.Time`

Closes https://linear.app/sourcegraph/issue/CORE-156
Part of https://linear.app/sourcegraph/issue/CORE-158

## Test plan

- [x] Unit tests on API level
- [x] Adapters unit testing
- [x] Simple E2E test:
https://github.com/sourcegraph/sourcegraph/pull/64057
2024-08-09 17:26:18 -07:00
Felix Kling
8296e9804f
feat(svelte): Migrate dotcom community search pages to Svelte (#64388)
What: This PR does the bare minimum to migrate the current community
search pages to Svelte. A better strategy for managing them is needed in
the medium/long term.

How: The community pages live at the root (e.g. `/kubernetes`) which
complicates things, but I'll get to that later. The page is implemented
as a single parameterized route. A parameter matcher is used to validate
the community name. Because these pages should only be accessible on
dotcom the matcher also validates whether or not we are on dotcom (if
not, the path will be matched against a different route).

The page config is stored in a separate module so that it's no included
in every page and so that it can be used in the integration test.

The loader and page implementation themselves are straightforward. I
made a couple of changes in other modules to make implementation easier:

- Extracted the parameter type of the `marked` function so that it can
be used as prop type.
- Added an `inline` option to `marked` that allows formatting markdown
as 'inline', i.e. without `p` wrapper.
- Added a `wrap` prop to `SyntaxHighlightedQuery.svelte` to configure
line wrapping of syntax highlighted search queries (instead of having to
overwrite styles with `:global`).
- Extended the route code generator to be able to handle single
parameter segments and the `communitySearchContext` matcher.

Because the community routes should only be available on dotcom I added
a new tag to the code generator that allows it include routes only for
dotcom.
Once we change how all this works and have community search pages live
under a different path we can simplify this again.

Result:

| React | Svelte |
|--------|--------|
|
![2024-08-09_16-05](https://github.com/user-attachments/assets/a64c4e0c-a9dd-4248-9466-05b348559408)
|
![2024-08-09_16-04](https://github.com/user-attachments/assets/d8ad424b-d04a-4590-b198-a6b2f4a76816)
|


## Test plan

- New integration tests.
- Verified that `/kubernetes` shows a 'repo not found error' when
running against S2.
- Verified that `/kubernetes` shows the community page when running
against dotcom.
- Verified that `window.context.svelteKit.enabledRoutes` contains the
community page route in enterprise mode but not in dotcom mode.
2024-08-09 22:52:47 +02:00
Camden Cheek
f1060eccac
Svelte: add support for navigating search results with the keyboard (#64257)
This adds support for navigating between search results with keyboard
shortcuts. Similar to the React app, `j` or `down` means "next result",
and `k` or `up` means previous results. To accompany this change, when a
search is submitted, the first result is focused by default to
facilitate iterating over results with the keyboard.
2024-08-09 14:24:05 -06:00
Camden Cheek
3df76cb173
Explore panel: more granular file tree (#64372)
The first version of the file tree for the revision panel had flat file
names. This meant that files were not organized, they were very
horizontal-space-sensitive, and you could not filter to a directory
(only repo and file name).

This updates the file filter to be a full tree, which I find much easier
to use.
2024-08-09 17:14:09 +00:00
Robert Lin
0de249daf9
feat/enterpriseportal: more list options for subscriptions and licenses (#64114)
Required to build an updated subscriptions management UI.

Most of the diff is generated proto for some reason

Closes https://linear.app/sourcegraph/issue/CORE-226

## Test plan

Integration tests
2024-08-09 16:43:39 +00:00
Taras Yemets
14a4d7ce31
fix(cody): filter out deprecated models (#64381) 2024-08-09 16:37:42 +00:00
Robert Lin
8537000f9d
feat/enterpriseportal: existing subscriptions read APIs use enterprise portal DB (#63927)
This change follows
https://github.com/sourcegraph/sourcegraph/pull/63858 by making the
existing subscriptions APIs _read_ from the Enterprise Portal database,
instead of dotcomdb, using the data that we sync from dotcomdb into
Enterprise Portal.

Part of https://linear.app/sourcegraph/issue/CORE-156
Part of https://linear.app/sourcegraph/issue/CORE-158

## Test plan

Updated unit and integration tests
2024-08-09 09:36:40 -07:00
Robert Lin
3e9fe3a0b9
chore/enterpriseportal: make sf_opp_id license-level (#64087)
Per feedback on
https://docs.google.com/document/d/1NyBIQvZ-ziNhiz7Yuzbp4f72Gp6EUrVUoBYnnnviXi8/edit#heading=h.3lhmwnxotdew
and further research, the salesforce opportunity ID must be
license-level. Right now we keep this specific to the "license key"
license type.

## Test plan

CI
2024-08-09 16:16:37 +00:00
Robert Lin
43184a3dfe
feat/enterpriseportal: license expiry checker (#64317)
Port of the existing background job:
https://sourcegraph.sourcegraph.com/github.com/sourcegraph/sourcegraph/-/blob/cmd/frontend/internal/dotcom/productsubscription/license_expiration.go?L25:6-25:45,
originally added in
https://github.com/sourcegraph/sourcegraph/pull/10362

Most of the diff is generated mocks :)

Closes https://linear.app/sourcegraph/issue/CORE-183

## Test plan

- [x] Unit tests
- [x] Manual test:
```
[enterprise-...l] INFO service.licenseexpiration.store licenseexpiration/store.go:96 PostToSlack {"text": "The license for subscription `coreservices - Robert Lin - 2024-07-16 23:16:13` <https://sourcegraph.com/site-admin/dotcom/product/subscriptions/bee0a0d9-6c17-4acf-81a4-fd6e777ed6a4|will expire *in the next 24 hours*> 🚨"}
```
2024-08-09 09:08:59 -07:00
Jean-Hadrien Chabran
2df3a40744
chore(ci): bump the tag on which backcompat operates (#64387)
Backcompat test suite works by checking out the code at the previous
minor release, injects the database schema from `HEAD` and run all Go
tests. This ensures that the old code can run against the new schema,
thus being backward compatible.

We forgot to update this the last time, that's why I'm bumping by two
tags here.

## Test plan

CI
2024-08-09 13:17:08 +00:00
Erik Seliger
ba9fe24e0f
Revert "tenant: Introduce tenant_id to every table (#64323)" (#64386)
This reverts commit 43e06cef0c.

This migration deadlocked on S2, we didn't expect that we have processes
taking table locks but apparently so.. Reverting for now and will
manually fix up S2 once the build went through. We probably need to make
this one migration per table :rip:

## Test plan

Revert.
2024-08-09 15:02:12 +02:00
Felix Kling
c4ea4b64d0
chore(web): Upgrade playwright (#64384)
The new version seems to be able to handle TypeScript aliases, using
`$lib` or `$testing` in playwright tests should now work.

## Test plan

CI
2024-08-09 13:01:46 +00:00
Noah S-C
c4fefc1fe6
chore(local): dont buffer sg updatecheck commencement notice (#64329)
Previously, `sg` would give no notice that an auto-update of itself was
happening in the background, due to background output being buffered.
This would be confusing when an invocation hangs/doesnt terminate as
quickly as expected due to the update process still being in progress.
Instead, we should print at least certain output from the process
immediately

## Test plan

`go run ./dev/sg -- <some command>` with a time.Sleep

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-08-09 14:33:40 +02:00
Greg Magolan
c60ae9cd67
build(bazel): upgrade to rules_oci 2.0.0-beta2 (#64364)
beta2 release came out yesterday. A few minor fixes on top of beta1.

https://github.com/bazel-contrib/rules_oci/releases/tag/v2.0.0-beta2

## Test plan

CI

## Changelog
2024-08-09 13:32:12 +01:00
Julie Tibshirani
0960775782
Redis: always use pointer receiver in keyvalue (#64385)
All other methods take a pointer receiver, so we should be consistent
and avoid unnecessary copying.
2024-08-09 14:21:04 +03:00
Anton Sviridov
db87eb601b
Use correct DSN for schema validation in syntactic worker (#64383)
Connecting to the wrong DSN leads to a cryptic error:

```
      Message:     {"SeverityText":"FATAL","Timestamp":1723196934012096886,"InstrumentationScope":"init db (syntactic-codeintel-worker)","Caller":"shared/shared.go:87","Function":"github.com/sourcegraph/sourcegraph/cmd/syntactic-code-intel-worker/shared.initCodeintelDB","Body":"Failed to connect to codeintel database","Resource":{"service.name":"syntactic-code-intel-worker","service.version":"286647_2024-08-08_5.6-34a7914fb884","service.instance.id":"syntactic-code-intel-worker-7bb9ccc75c-mkzpk"},"Attributes":{"error":"database schema out of date"}}
```

## Test plan
- existing tests should continue to pass


<!-- REQUIRED; info at
https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles
-->

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-08-09 11:21:33 +01:00
Jean-Hadrien Chabran
883604b925
chore(local): fix outdated frontend target being used (#64382)
In https://github.com/sourcegraph/sourcegraph/pull/63946 we reworked how
we handle assets, but we overlooked updating the target in
`sg.config.yaml`.

## Test plan

CI + locally tested (made some changes on the home page, got reloaded as
expected)
2024-08-09 09:41:52 +00:00
Ólafur Páll Geirsson
ba85ea6f32
feat/API: add publicly available /api/v1/chat/completions REST endpoint (#64239)
Fixes CODY-3081

This is the first PR for the project [⏭️ Launch Cody API
Experimental](https://linear.app/sourcegraph/project/launch-cody-api-experimental-8fd5ec338bf4),
which falls under the umbrella of moving Cody's brains to the cloud.

Previously, there was no publicly available REST API for our customers
to interact with Cody. This is a frequently requested feature from
customers and prospects.

This PR adds a new `POST /api/v1/chat/completions` endpoint, which
should be compatible with existing OpenAI clients. The OpenAI API format
is increasingly becoming an industry standard so this seems like a good
first step towards exposing a stable publicly facing API for our
customers.

The goal is to add more Cody-specific APIs in the coming weeks to send
chat messages and reference context.

<!-- PR description tips:
https://www.notion.so/sourcegraph/Write-a-good-pull-request-description-610a7fd3e613496eb76f450db5a49b6e
-->

## Test plan

See added test cases.
<!-- REQUIRED; info at
https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles
-->

## Changelog

* API: new publicly available `/api/v1/chat/completions` REST endpoint
that is compatible with OpenAI clients with some restrictions. The detailed list of restrictions will eventually be documented on sourcegraph.com/docs

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-08-09 09:36:27 +00:00
Erik Seliger
43e06cef0c
tenant: Introduce tenant_id to every table (#64323)
We introduce the tenant_id column to every table without any magic
enforcement or magic default value. Instead we default to NULL and plan
to have an out of band migration. From out testing this change is
instant since it is only a table metadata change. According to the
documentation this sort of ALTER TABLE is instant since Postgres 11.

Test Plan: ran this migration against a clone of the s2 database.

---------

Co-authored-by: Keegan Carruthers-Smith <keegan.csmith@gmail.com>
2024-08-09 10:17:21 +02:00
Erik Seliger
7ad393bb35
db: Don't lose context when marking savepoints as done (#64361)
Currently, this uses context.Background, because the initial context
might've been canceled.
However, that causes us to lose any context involved here, so traces
won't include this query and tenant information would be lost.

This uses the new-ish context.WithoutCancel to avoid this issue and
stores the context used to create the transaction to close it later.

Test plan: Ran a local instance and didn't see errors, also integration
and E2E tests pass.
2024-08-09 10:16:06 +02:00
Stefan Hengl
f175436a73
tenant: update test to enforce tenant (#64379)
I forgot this when I added the test, so we were basically testing the
same thing twice.

## Test plan:
updated unit test
2024-08-09 10:03:41 +02:00
Julie Tibshirani
7402cd7769
Search: update Zoekt for telemetry improvement (#64380)
acacc5eda1...20c496e368

- https://github.com/sourcegraph/zoekt/commit/b4193c29e7 Remove
redundant phrase boost logic
- https://github.com/sourcegraph/zoekt/commit/801a704725 inline ctags
alpine script
- https://github.com/sourcegraph/zoekt/commit/e77b32d6f1 docker: remove
scip-ctags from Dockerfile
- https://github.com/sourcegraph/zoekt/commit/e372e97c88 Fix rare
failures in ngram selection tests
- https://github.com/sourcegraph/zoekt/commit/20c496e368 Add metric for
indexing delay
2024-08-09 11:03:13 +03:00
Julie Tibshirani
786a4753c0
Search: avoid phrase boost for non-text searches (#64369)
To ease the transition from older search semantics to keyword search, we
[boost matches on
phrases](https://github.com/sourcegraph/sourcegraph/pull/59940). This
phrase boosting applied to all search types, including repo, and symbol
searches. However, these search backends don't effectively handle the
extra boosted OR clause, so it can hurt performance and ranking.

This PR limits the phrase boosting to text searches (`type:file` and
`type:path`), as they benefit most from the boosting and can handle it
efficiently.
2024-08-09 10:09:03 +03:00
Naman Kumar
d0b88533b4
Remove old Cody Web completely (#64345)
closes:
https://linear.app/sourcegraph/issue/SRCH-622/remove-old-cody-web-entirely

Removes the old Cody Web completely.

## Test plan

- sg start
- visit /cody/chat and you should see the new unified panel Cody Web
without having to turn on any feature flags.
- check the blob view sidebar for the same.
## Changelog

- The new Cody Web is enabled by default and the older version of Cody
Web is completely removed from both standalone chat and sidebar.
2024-08-09 10:25:59 +05:30
Greg Magolan
119f17578c
build(bazel): upgrade to latest aspect bazel-lib and rules_js rules (#64365)
Some analysis phase performance improvements in rules_js 2.0.0-rc9 that
are worth picking up. rules_js is very close to 2.0.0 final now. Waiting
on one last improvement requiring and API change for bzlmod.

## Test plan

CI

## Changelog
2024-08-08 16:57:54 -07:00
Robert Lin
7c2d97858a
feat/dotcom: UI tracks Cody Gateway access directly in Enterprise Portal (#64090)
Upgrades the self-contained Cody Gateway modal to only depend on
Enterprise Portal to read/write Cody Gateway access.

I also made some minor tweaks to parsing empty form inputs, and also
made the "Cody Gateway access token" collapsed by default, with warnings
to discourage its use (opted not to remove entirely since it may be
useful for dev/debugging)

Depends on:

- https://github.com/sourcegraph/sourcegraph/pull/63926 
- https://github.com/sourcegraph/sourcegraph/pull/63925 
- https://github.com/sourcegraph/sourcegraph/pull/63858 

Closes https://linear.app/sourcegraph/issue/CORE-218

## Test plan

```
sg start dotcom
```

Edit the Cody Gateway access stuff, toggling it up and down.
Cross-reference with the `enterprise_portal_cody_gateway_access` table.
2024-08-08 16:37:16 -07:00
Robert Lin
447570628b
fix/enterpriseportal/codyaccess: allow removing rate limit overrides (#64376)
On double-checking the various Cody Gateway access management CRUD I
noticed that I did not implement the ability to remove the override
entirely properly - right now, removing a rate limit with `field_mask`
and no values results in a zero-value rate limit rather than a null one
as desired.

This change makes it so that if you provider a nil `*_rate_limit`
object, all field paths for that object is also set to nil, removing the
override and allowing the default active-license-plan-based rate limits
to apply.

This also adds a minor adjustment to Cody Gateway to correctly handle
zero durations for rate limit intervals, which should be treated as "no
access".

## Test plan

Unit/integration tests, and a manual test:

- Check out https://github.com/sourcegraph/sourcegraph/pull/64090 and
run `sg start dotcom`
- Go to a subscription, add a rate limit override 

![image](https://github.com/user-attachments/assets/9f417a60-5096-4f6e-8eea-1f0720cb4ada)
- Click the 🗑️ button to remove the rate limit override 

![image](https://github.com/user-attachments/assets/d53f4ae9-43d9-4bb2-a33b-7632f74ea2c8)
- Repeat above on each property
2024-08-08 15:19:58 -07:00
Robert Lin
076498f2dc
feat/enterpriseportal: implement UpdateCodyGatewayAccess (#63926)
Implements the only Cody Access write API we have right now, the ability
to apply overrides to Cody Gateway rate limits, which we'll have in
Enterprise Portal with
https://github.com/sourcegraph/sourcegraph/pull/63858

A lot of the diff is a new generated mock for the Cody Access store so
that we can write some simple unit tests.

With this addition, all initially proposed Cody Gateway access APIs are
implemented.

Part of https://linear.app/sourcegraph/issue/CORE-218
Closes https://linear.app/sourcegraph/issue/CORE-160

## Test plan

Unit and existing integration tests
2024-08-08 13:21:18 -07:00
Peter Guy
b625bea201
Doc and README update: Replace all usages of GH discussions with the SG community link. (#64374)
Sourcegraph's GitHub discussions have been defunct for awhile, but links
to them persisted in READMEs and documentation.

## Test plan

Documentation update only.
2024-08-08 13:04:13 -07:00
Naman Kumar
2dd38b3ffd
Fix Cody Web CSS (#64370)
closes:
https://linear.app/sourcegraph/issue/SRCH-866/improve-cody-web-theming-for-consistency-with-rest-of-product

This PR updates the Cody Web CSS based on the changes requested by
@rrhyne.

Few buttons implemented in Cody doesn't satisfy the design requirements
and do not use the css variable so we couldn't update them easily but
rather had to override the styles.

## Test plan

Before: 
![CleanShot 2024-08-08 at 22 53
48@2x](https://github.com/user-attachments/assets/95e10b42-b740-4663-a761-69449ec62296)

After:
![CleanShot 2024-08-08 at 22 54
12@2x](https://github.com/user-attachments/assets/bffbd10a-c87b-4eca-9582-b23eebccb60e)


## Changelog

- Make Cody Web styles more accessible.
2024-08-09 01:21:09 +05:30
Robert Lin
05ca108105
feat/enterpriseportal: use database for reading Cody Gateway access (#63925)
This change follows
https://github.com/sourcegraph/sourcegraph/pull/63858 by making the Cody
Access APIs _read_ from the Enterprise Portal database, instead of
dotcomdb, using the data that we sync from dotcomdb into Enterprise
Portal.

As part of this, I also expanded the existing "compatibility" test suite
that compares the result of our dotcomdb queries against the existing
GraphQL resolvers in dotcom to also compare the results of our new Cody
Access APIs, to validate that they return the same access.

> [!WARNING]
> There is one behavioural change, which is that hashes of _expired
licenses_ will no longer be valid as access tokens. This shouldn't be an
issue if customers use zero-config (implied access token from their
license key) - I will do some outreach before rolling this out.

Subsequent PRs will implement write APIs.


Part of https://linear.app/sourcegraph/issue/CORE-218
Part of https://linear.app/sourcegraph/issue/CORE-160

## Test plan

Integration and unit tests at various layers
2024-08-08 10:39:14 -07:00
Stefan Hengl
34a7914fb8
tenant: update FromContext to return error (#64363)
This updates `FromContext` to return an error instead of bool.

Follow-up from comment in
[#64335](https://github.com/sourcegraph/sourcegraph/pull/64335#discussion_r1708886602)

Test plan:
CI
2024-08-08 16:59:53 +02:00
Keegan Carruthers-Smith
ea55d761ba
database: optional pprof for tenantless_queries (#64337)
This adds a new profile output for when a sql query does not have a
tenant set. This can be downloaded like other pprof profiles and
inspected by "go tool pprof". This allows us to easily see the most
common stack traces and sources of missing context.

Test Plan: downloaded from the debugserver the new profile type and
inspected with "go tool pprof"

---------

Co-authored-by: Erik Seliger <erikseliger@me.com>
2024-08-08 14:18:59 +00:00
Felix Kling
e0702bea7d
build(svelte): Build Svelte app with enterprise runset (#64355)
Fixes srch-867

This commit adds a new command, `web-sveltekit-prod`, which simplies
builds the SvelteKit app and exits.
This command is now run by default when using `sg start`, so the assets
will be available locally.

Note however that the build process is quite slow, which is why I didn't
make it rebuild on file changes. Using the vite dev server, e.g. via `sg
start enterprise-sveltekit`, delivers a much better experience.

To make the integration a bit more ergonomic, I made additional changes:

- When run via `sg` (determined by checking `DEPLOY_TYPE`) compiler
warnings are not printed. That reduces noise in the `sg` output.
- I made similar changes to the svelte check bazel target to make it
easier to spot actuall errors (warnings are still important to fix but
since they don't cause the target to fail they just make it difficult to
spot the actual error).
- Since I finally found out about the `onwarn` handler, I made it so
that warnings about missing declarations are ignored. These warnings
occur for every icon because the Svelte compiler doesn't respect ambient
d.ts files.
- And since I made icon warning related changes I also documented a bit
how icons work in the app.

## Test plan

- `sg start` runs the `web-sveltekit-prod` command and the Svelte app is
served when going to `https://sourcegraph.test:3443/search`.
- The output of `bazel test //client/web-sveltekit:svelte-check` now
only contains errors.
- The output of `pnpm dev` (vite devserver) shows warnings that are not
related to icons.
2024-08-08 16:18:29 +02:00
Felix Kling
97ef93ddac
fix(svelte): Always close navigation sidebar when navigating to a different page (#64357)
Fixes srch-859

Problem: Currently the sidebar can reopen in the following scenario:
- Go to search home and submit a search
- On the search results page click the menu icon to open the sidebar and
click 'Code Search' to go back to search home.
- Execute a different query
- -> this brings you back to search results but with the menu sidebar
open

Looking at the code it's understandable that this happens: We never
close the sidebar. But this problem wasn't very visible because every
entry in the nav sidebar either brings you to the React app or to a page
with inline nav menu.

So this commit fixes the issue by closing the sidebar whenever we
navigate to a different page.

## Test plan

Manual testing. I added a temporary nav entry that would bring me to the
sourcegraph repo page. Clicking on it from the search results page
caused the sidebar to close.
2024-08-08 16:18:07 +02:00
William Bezuidenhout
cacc01be6f
ci: provide a more descriptive error when pipegen fails (#64362)
Give a more descriptive error when we are unable to find a merge base
and can't find the files that have changed.

Closes DINF-162
## Test plan
1. `git fetch -v --prune --depth=100 -- origin
ccbaba24b72f3c6f4524b3f560ca839143ea463b`
2. `git merge-base HEAD origin/main` --- you'll get nothing since there
is no merge base in the current history

Increase the repo history
1. `git fetch --unshallow`
2. `git merge-base HEAD origin/main`
```
0a6e509af3
```
## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->

Co-authored-by: Bolaji Olajide <bolaji.olajide@sourcegraph.com>
2024-08-08 14:13:07 +00:00
Erik Seliger
221b7f0fb6
tenant: Ensure tenant table also exists in codeintel and codeinsights DBs (#64359)
In some deployments, these are running in separate instances. This
migration makes sure that we can still reference the tenants from the
tenant_id column reliably everywhere.

It's critical that this migration is a noop on instances that already
have this table, so please double check me here during code review.

Test plan: Integration and E2E tests still pass, as this should be a
noop.
2024-08-08 15:33:49 +02:00
Stefan Hengl
c071a715cd
chore(backend): enable diskcache for multi-tenant (#64335)
Unless tenants are enforced, we use the old code path. If they are
enforced:
- zips are stored in `<cache-dir>/tenants/<tenantID>/<key>`
- evict runs globally

I also added another test helper to create tenants with fresh IDs for
every call

## Test plan:
- Updated unit tests
- Manual testing: I verified that unindexed symbol and text search work
and that a `/tenant/1` dir is created in both cache dirs
(`/tmp/searcher-archive` and `/tmp/symbols-cache`).
2024-08-08 13:18:34 +00:00
Erik Seliger
55cdb4961c
graphqlbackend: Move utils to internal/ (#64117)
The utils are currently used outside of cmd/frontend, so to break the
internal -> cmd import I'm moving and merging the utils package with
internal/gqlutil.

Test plan: Just moved around and renamed a package, the go compiler
doesn't complain.
2024-08-08 14:18:37 +02:00
Jean-Hadrien Chabran
2c73f72e85
chore(local): rename experiment single-program commandset (#64341)
Now that https://github.com/sourcegraph/sourcegraph/pull/64339 is
merged, we can tell users more about what to expect with `sg start
single-program-experimental-blame-sqs`. And as it's been in flight for a
while now, it's safe to say that's it's time to give it a shorter name
😊.

So it's been renamed from `single-program-experimental-blame-sqs` to
`minimal`. And to ensure nobody is getting confused, a `deprecated`
attribute has been added on the command sets, which is used here to
indicate that the new alternative is `sg start`.

 Thoughts about `sg start minimal`? `sg start single` perhaps? 

Running the old commandset: (ignore the yellow message, that's just a
local warning from `sg`)

![CleanShot 2024-08-07 at 17 37
31@2x](https://github.com/user-attachments/assets/a36afe54-7ccc-4437-b11b-ad288536c8da)

Running the new commandset, with the preamble explaining what to expect:

![CleanShot 2024-08-07 at 17 38
51@2x](https://github.com/user-attachments/assets/aa9af41a-8bad-48f5-ae46-68a357464bf5)

## Test plan

Locally tested.
2024-08-08 13:55:06 +02:00
Felix Kling
975b14f244
fix(svelte): Don't animate menu icon (#64358)
Fixes srch-858

Currently the menu icon rotates when hovering over it. The animation
should only target the Sourcegraph logo.

Additional changes:

- Move icon color style prop into CSS declaration (avoids inserting an
additional element)
- Let the animation target the link instead of the icon. There doesn't
seem to be reason why we actually need to target the `svg` element via
`:global`.


## Test plan

Manual testing.
2024-08-08 11:35:39 +00:00
Erik Seliger
1819daa7a7
tenant: Introduce tenant table to frontend database (#64322)
This PR adds a basic table for storing tenants in the database, and automatically inserts a tenant 1 for existing instances.

Test plan: Adds a new, not yet used table. The migration is very simple, so shouldn't cause any issues to existing instances.
2024-08-08 12:03:52 +02:00
Erik Seliger
f61ce6e8e8
tenant: Introduce first version of tenant package (#64271)
This PR aims to craft the /internal/tenant package for use by all Sourcegraph cluster-internal services to properly scope data visibility to the correct requesting tenant.
For now, we only expose methods we know we will DEFINITELY need.

This PR also adds the required middlewares so we can start to tinker with it in implementations.

## Test plan

CI passes. We don't enforce anything for now except not passing unparseable tenant IDs, which should be fine.
2024-08-08 12:02:19 +02:00
Felix Kling
1c729823d5
refactor(svelte): Improve integration with sg (#64333)
There currently isn't a 'one step' way to start a local Sourcegraph
instance with the SvelteKit app.

This commit adds `sg start enterprise-sveltekit` to fix that.

The changes in https://github.com/sourcegraph/sourcegraph/pull/64272
allow us to run the vite dev server in front of the Sourcegraph
instance, instead of building the assets and having them served by
frontend.
This gives us the benefit of hot module reloading and in general seems
to be a less fragile approach.

It's basically the same what we do with the React app in development
mode.

## Test plan

`sg start enterprise-sveltekit` starts the vite dev server as well as
the sourcegraph instance. Navigating to
`https://sourcegraph.test:3443/search` opens the Svelte app (when
enabled and logged in). Making a change in a source file updates the web
page immediately.

`sg start web-sveltekit-standalone` still works
2024-08-08 11:39:26 +02:00
Felix Kling
cf5467150b
fix(svelte): Improve hovercard UI for search based info (#64350)
I don't know why but having `overflow-x` causes the content of the
hovercard to not fully expand to the edges. It has something to do with
the sizing of the `hr` element.


## Test plan

Manual testing.
2024-08-08 09:36:49 +00:00
Erik Seliger
a3f23a5972
searcher: Consolidate FetchTar and FetchTarPaths (#64268)
There was a todo comment that said we want to consolidate them but didn't yet to keep another diff smaller - so now we're doing that.

Test plan: Integration tests for search still pass.
2024-08-08 11:04:38 +02:00
Erik Seliger
5a39f81d84
chore: Move cmd/frontend/backend to internal (#64261)
To prevent cross-cmd imports in the future, moving the backend package into internal.

Test plan: Just moved a package around, Go compiler doesn't complain and CI still passes.
2024-08-08 11:02:51 +02:00
Noah S-C
b9c4e2aae9
Revert "Revert "refactor: upgrade to rules_oci 2.0 (2nd attempt)"" (#64354)
Reverts sourcegraph/sourcegraph#64351

## Test plan

Need to test on main due to main-only CI steps (even with main dry-run)
2024-08-08 09:00:08 +00:00
Erik Seliger
db550f9618
auth: Remove redirects to session package (#64260)
These functions are not required to be called outside of frontend, so there's no need to reexport them. Instead, we consolidate the signout cookie logic in the session package.

Test plan: Just moved some code around, go compiler doesn't complain.
2024-08-08 10:40:53 +02:00