Commit Graph

34282 Commits

Author SHA1 Message Date
Erik Seliger
f9ac351dc3
Remove App from codebase (#59115)
Cody no longer needs it and it is obsolete now!

Since App added a non-insignificant amount of new concepts and alternative code paths, I decided to take some time and remove it from out codebase.
This PR removes ~21k lines of code. If we ever want parts of single binary (app), the redis kv alternatives, or the release pipeline for a native mac app back, we can look back at this PR and revert parts of it, but maintaining 21k lines of code and many code paths for which I had to delete a surprisingly small amount of tests justifies this move for me very well.

Technically, to some extent SG App and Cody App both still existed in the codebase, but we don't distribute either of them anymore, so IMO we shouldn't keep this weight in our code.

So.. here we go.

This should not affect any of the existing deployments, we only remove functionality that was special-cased for app.
2023-12-21 01:07:05 +01:00
Robert Lin
63403f2a16
sg: add 'sg msp postgresql connect' (#59106)
This change introduces an `mi2`-like experience for interacting with MSP databases. By default we use the new readonly-SA introduced in https://github.com/sourcegraph/sourcegraph/pull/59105, otherwise with the `--write-access` flag you can connect as the same user as the Cloud Run workload, which gives a lot more permissions.

An alias, `sg msp pg connect`, is available for those less inclined to type out the entire `postgresql` subcommand name.

Closes https://github.com/sourcegraph/managed-services/issues/207

## Test plan

Applied to `msp-testbed`, which has a PG instance and provisioned tables.
Try both service accounts:

```
sg msp pg connect --write-access msp-testbed test
sg msp pg connect msp-testbed test 
```

![image](https://github.com/sourcegraph/sourcegraph/assets/23356519/c75bcb8c-5f7d-4f3b-90ec-9effb3306ba9)

With both of the above:

```
primary=> select * from users;
 id | created_at | updated_at | deleted_at | external_id | name | avatar_url 
----+------------+------------+------------+-------------+------+------------
(0 rows)
```
2023-12-20 14:53:34 -08:00
Robert Lin
972c9c3d0b
msp: provision read-only 'operator access' user for Cloud SQL (#59105)
This change adds an "operator access" service account that I plan to expand with various roles and stuff required to connect to MSP resources on a read-only basis. Currently, I'm focusing on the Cloud SQL use case as part of https://github.com/sourcegraph/managed-services/issues/207 for a `mi2`-like UX for connecting to databases, so I've also added SQL users for the operator access SA. For escalated access, operators will impersonate the existing Cloud Run workload SA instead.

From here we can impersonate the SA to connect to the instance using the connection name that I've added to the Cloudrun stack outputs in this PR - https://github.com/sourcegraph/sourcegraph/pull/59106

## Test plan

- https://github.com/sourcegraph/sourcegraph/pull/59106
- https://github.com/sourcegraph/managed-services/pull/220
2023-12-20 14:24:51 -08:00
Julie Tibshirani
0cffcac71f
Telemetry: track search pattern type (#59097)
Adds the search pattern type to the `SearchSubmitted` event. By looking for the
pattern type `newStandardRC1` vs. `newStandard`, this lets us see how many
users have enabled / disabled the query language improvements using the
toggle.
2023-12-20 11:57:37 -08:00
Vova Kulikov
0f8b28b5b9
Revert "use vite for web builds (#58228)" (#59132)
This reverts commit 86180de04a.
2023-12-20 16:23:45 -03:00
Maedah Batool
3fa35fff73
Fix typo on main docs page (#59104) 2023-12-20 20:09:43 +01:00
Jean-Hadrien Chabran
06542fc530
Port executors building/pushing scripts to use Bazel (#58892)
---------

Co-authored-by: William Bezuidenhout <william.bezuidenhout@sourcegraph.com>
2023-12-20 18:33:49 +00:00
Erik Seliger
d4cb67425b
Speed up some slow DB tests (#59131)
Found this package frustratingly slow, so looked at the worst offenders.

Top 5 before:

```
TestOutboundWebhookJobs,3.61
TestRecentViewSignalStore_InsertPaths_OverBatchSize,4.9
TestFeatureFlagStore,6.28
TestEventLogs_OwnershipFeatureActivity,7.05
TestExternalServicesStore_Upsert,9.72
```

Top 5 after:

```
TestPermsStore_GrantPendingPermissions,2.28
TestExternalServicesStore_DeleteExtServiceWithManyRepos,2.43
TestAccessTokens,2.47
TestWebhookUpdate,2.67
TestFeatureFlagStore,4.95
```
2023-12-20 17:42:23 +00:00
Stefan Hengl
2f6286d5f6
dev: revert to old search mode for local dev environment (#59129)
This reverts the default from loveable search to smart search for the
local dev environment. This is mainly to disentangle our protoype
running on S2 from everyone's dev experience.

Devs who want to use loveable search locally, can set the feature flag
"search-new-keyword".
2023-12-20 17:02:32 +01:00
William Bezuidenhout
a3143120c4
actions: create reusable workflow for sentry reports (#59098)
* actions: create reusable workflow for sentry reports
2023-12-20 17:05:03 +02:00
Stefan Hengl
a0e660e1a8
search: use literal suggestions for keyword search (#59120)
This updates suggestions to insert literals instead of regex-escaped values for repo and file filters.

Co-authored-by: Felix Kling <felix@felix-kling.de>
2023-12-20 15:58:22 +01:00
Stefan Hengl
92cfe03c10
search: support glob syntax for repo and file filters (#59080)
Relates to https://github.com/sourcegraph/sourcegraph/issues/58815
Ported directly from https://github.com/sourcegraph/sourcegraph/pull/58849/

We add support for glob syntax to file and repo filters.

Notes:
- `f:` matches nothing. I think this is less surprising than our [current behavior](https://sourcegraph.com/search?q=context:global+f:&patternType=standard&sm=1)
- `*` matches any sequence of characters, including `/`
- No other special characters are supported

Test plan:
- new unit tests
2023-12-20 12:42:05 +01:00
Jean-Hadrien Chabran
252637fdd1
dev: remove deadlink from buildchecker (#59118)
* dev: remove deadlink from buildchecker

* dev: doc that buildchecker is a GHA
2023-12-20 09:50:07 +00:00
dyma solovei
5b40640349
fix(sg): start Caddy admin server before caddy trust (#58928)
fix(sg): start Caddy admin before `caddy trust`

From docs:
This command will attempt to connect to Caddy's admin API to fetch the root certificate,
using the GET /pki/ca/<id>/certificates endpoint.

If the admin server is not running at the moment, the GET request
will not succeed, and the certificate won't be installed correctly.
2023-12-20 10:03:45 +02:00
Quinn Slack
86180de04a
use vite for web builds (#58228)
* remove little-used `web-standalone-http-prod`

This let you run a local web app built in production mode against a remote Sourcegraph endpoint. You can still run a local web app built in *dev* mode.

* add `sg test bazel-backend-integration`

* fix DeveloperDialog positioning

It was taking up 100% width and was translated -50% so the left half of it was off-viewport.

* use vite for web builds

[Vite](https://vitejs.dev/) is a fast web bundler. With Vite, a local dev server is available as fast as with esbuild, and incremental builds are (1) hot (no page reload needed) and (2) much faster (<500ms).

* fix "manifestPlugin.d.ts" was not created

* sg lint

* remove little-used `web-standalone-http-prod`

This let you run a local web app built in production mode against a remote Sourcegraph endpoint. You can still run a local web app built in *dev* mode.

* add `sg test bazel-backend-integration`

* fix DeveloperDialog positioning

It was taking up 100% width and was translated -50% so the left half of it was off-viewport.

* use vite for web builds

[Vite](https://vitejs.dev/) is a fast web bundler. With Vite, a local dev server is available as fast as with esbuild, and incremental builds are (1) hot (no page reload needed) and (2) much faster (<500ms).

* fix "manifestPlugin.d.ts" was not created

* sg lint

* small lint fix

* added events shim to client/web/BUILD.bazel

* updated via bazel configure

* added in side-effectful import for EventEmitter

* added in side-effectful import for EventEmitter

* ran bazel configure

* re-run bazel configure

* pnpm dedupe

---------

Co-authored-by: William Bezuidenhout <william.bezuidenhout@sourcegraph.com>
Co-authored-by: jamesmcnamara <jamesscottmcnamara@gmail.com>
Co-authored-by: Jean-Hadrien Chabran <jh@chabran.fr>
2023-12-19 19:16:51 -08:00
Robert Lin
400f719b7a
msp: reduce default project suffix length (#59109)
The default is from Cloud, and is way too long for the usual MSP use case - almost all services set a custom suffix length today to avoid hitting project name limits. https://github.com/sourcegraph/managed-services/pull/214 pins anything using the default today.
2023-12-19 14:48:19 -08:00
Robert Lin
4745696f48
msp: tfcworkspaces stack for notifications and provisioning runs (#59103)
This change adds a stack, `tfcworkspaces`, dedicated to managing MSP TFC workspaces. In this stack:

1. We apply additional configuration, like notifications! This way we don't have to re-implement the provider entirely, we just need to create/configure the initial workspaces via API and do the rest in Terraform.
2. Provision runs for the other workspaces - this will greatly improve the environment creation experience. The new workflow goes `msp tfc sync`, and hopefully the new `queueAllRuns` option will work to queue a run for the `tfcworkspaces` workspace. This workspace will then queue apply plans for each workspace, _in sequence_.

---------

Co-authored-by: Michael Lin <mlzc@hey.com>
2023-12-19 14:17:13 -08:00
Camden Cheek
6f49332fb4
Svelte: highlight expanded lines (#59101)
When clicking the "expand results" button, the expanded lines were not syntax highlighted for the svelte prototype. This happened the ranges we were fetching for highlights are pre-calculated from the collapsed groups. Instead, we want to fetch ranges for every group so when we expand, we have the highlighted result already. The first commit does that.
2023-12-19 10:12:44 -07:00
Robert Lin
496e69a1af
sg: include MSP toolchain in default builds (#59087)
This change bundles the `sg msp` toolchain in default `sg` builds. This was previously in a very experimental state and introduced a significant increase in the `sg` binary size, so we had it behind a build flag. However, we've discussed this a few times with Dev Infra and the consensus is that it is okay to include by default.

We have a demo prepared for this week, and with many of our core features now available, we want to make a renewed push for adoption, so now is a good time to start bundling this command by default.

There are no functionality changes - this PR just removes the overwrite-command-on-init-with-build-flag stuff and exports the full toolchain by default from the `dev/sg/msp` package.

Close https://github.com/sourcegraph/managed-services/issues/182

## Test plan

```
➜ go build -o ./sg ./dev/sg                                 
➜ ./sg msp init -h
NAME:
   sg managed-services-platform init - Initialize a template Managed Services Platform service spec

USAGE:
   
   sg msp init -owner core-services -name "MSP Example Service" msp-example


OPTIONS:
   --kind value   Kind of service (one of: 'service', 'job') (default: "service")
   --owner value  Name of team owning this new service
   --name value   Specify a human-readable name for this service
   --dev          Generate a dev environment as the initial environment (d
```
2023-12-19 08:41:13 -08:00
Felix Kling
94904658fa
svelte: Fix local build (#59100)
I don't know if this is only an issue for me, but I'm not able to run pnpm build locally anymore. The build fails with the error mentioned in the comment. Hover seeing that CI is green for other PRs and SvelteKit is deployed to S2 successfully, I don't really know why this is happening.
This change fixes it though.
2023-12-19 17:20:46 +01:00
Noah S-C
85b09cc66d
bazel: add sgexit lint to nogo (#59092)
Closes https://github.com/sourcegraph/sourcegraph/issues/54847

## Test plan

Sample deliberate error:

```
$ bazel build //dev/sg
INFO: Analyzed target //dev/sg:sg (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: /home/noah/Sourcegraph/sourcegraph/dev/sg/BUILD.bazel:128:10: GoCompilePkg dev/sg/sg.a failed: (Exit 1): builder failed: error executing command (from target //dev/sg:sg) bazel-out/k8-opt-exec-2B5CBBC6/bin/external/go_sdk/builder_reset/builder compilepkg -sdk external/go_sdk -installsuffix linux_amd64 -src dev/sg/analytics.go -src dev/sg/checks.go -src ... (remaining 245 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
compilepkg: nogo: errors found by nogo during build-time code analysis:
dev/sg/sg_run.go:28:4: use of `signal.Notify` forbidden because "breaks dev/sg/internal/interrupt" (forbidigo)
Aspect @rules_rust//rust/private:clippy.bzl%rust_clippy_aspect of //dev/sg:sg up-to-date (nothing to build)
INFO: Elapsed time: 52.557s, Critical Path: 26.79s
INFO: 1435 processes: 2 internal, 1433 linux-sandbox.
FAILED: Build did NOT complete successfully
```
2023-12-19 14:46:33 +00:00
David Veszelovszki
792afc7ca3
SSC: Enterprise copy tweaks (#59099) 2023-12-19 17:59:12 +05:30
Noah S-C
65524ee909
bazel: adapt go-dbconn-check.sh lint to nogo (#58971)
Closes https://github.com/sourcegraph/sourcegraph/issues/54836

## Test plan

Brought dbconn into the dependency graph of //cmd/executor in a few ways:
1. directly 
2. indirectly through a direct dependency
3. indirectly through a transitive dependency
4. inserting/removing from the graph in a few ways to try catch any Fact caching issues
2023-12-19 09:56:58 +00:00
Stefan Hengl
f883d66bc7
search: support "exact match" pattern using "..." (#59057)
Relates to #58815

With this change, a quoted pattern, like `"foo bar"`, is interpreted literally IE spaces are interpreted as spaces instead of as logical `AND`. Quotes that should be matched literally have to be escaped.

Example:

To search for the text `foo "bar"`, where `bar` is surrounded by quotes, the query is either `"foo \"bar\""` or, if we use single quotes, `'foo "bar"'`.

Note: This change only affects our keyword search prototype.

Test plan:
- updated unit test
2023-12-19 10:26:41 +01:00
sourcegraph-bot-devx
c7a6ef3b6a
chore: update third-party licenses (#58876)
Co-authored-by: burmudar <burmudar@users.noreply.github.com>
2023-12-19 10:46:33 +02:00
Erik Seliger
dad4871a96
Make sure we test gRPC in CI suites (#59094)
Some of the suites weren't yet using gRPC - this PR turns it on so we gain some more confidence before we start dropping HTTP entirely.
2023-12-19 00:35:56 +01:00
Robert Lin
3e5c6ee483
msp/cloudflare: add comment and tags for identifiability (#59047)
There are a lot of records and stuff in Cloudflare - this makes it easier to identify which ones are managed by MSP.
2023-12-18 14:12:24 -08:00
Robert Lin
594f08e92c
msp/spec: check length of final project name (#59044) 2023-12-18 14:12:10 -08:00
Felix Kling
3beed5896c
svelte: Fix setting theme from temporary settings (#59091)
Turns out the theme values stored in temporary setting are different
from what the prototype expected. It only accidentally worked when I
tested it.

This commit introduces a helper method that accepts an arbitrary string
value and updates the theme state accordingly, instead of using an
arbitrary string value as theme state (ideally TS would have complained
about this before but it looks like it didn't).
2023-12-18 22:48:29 +01:00
Camden Cheek
2e0d0884b0
Search Web: render results immediately using streamed content (#58979)
This builds on the change in #58943 to take advantage of the newly-complete chunks being streamed back from the backend. Now, search results are rendered immediately on receipt using the streamed chunk content.
2023-12-18 21:07:58 +00:00
Jason Hawk Harris
8a223a898b
Revert "Code Navigation: tokens highlight immediately on hover" (#59088)
Revert "Code Navigation: tokens highlight immediately on hover (#58384)"

This reverts commit 1f2cd593d0.
2023-12-18 15:07:10 -06:00
Julie Tibshirani
817c47b1a7
Searcher: pull out 'matcher' interface (#59040)
Currently searcher can only handle patterns with a single atom. We'd like to update searcher to handle AND/ OR patterns directly.

This refactor takes us a step towards being able to natively handle AND/ OR patterns by refactoring the way we match files. It pulls out a `matcher` interface, which for now just has a single implementation (`regexMatcher`), but eventually can represent nested matchers combined through AND/ OR. Even without this goal, I think the refactor stands on its own and helps clean up the logic.

Specific changes:
* Lots of renames to make things clearer, like `readerGrep` -> `regexMatcher`
* Define `matcher` interface, which finds matches given file contents, and related logic into new file
* Pull `pathMatcher` out of `matcher`, since it's really its own top-level concept
* Move all file content and buffer management to `search_regex`. This lets each `matcher` object become threadsafe, and avoids the need for copying them for every goroutine.
2023-12-18 12:37:07 -08:00
Vova Kulikov
bc244a46bc
Fix new flag for file preview feature/global navigation search box (#59084)
Use new flag for file preview feature/global navigation searc box
2023-12-18 15:36:03 -03:00
Felix Kling
6f9e6479f9
svelte: Initialize theme with user configured value (#59086)
Before this commit the theme was always initialized as 'system'. This
loads the configured theme from temporary settings. There will be a
flash of the wrong theme on load, but that's not avoidable atm.
2023-12-18 17:40:31 +00:00
Vova Kulikov
07cf64660d
[Blob UI]: Re-use cursor iterator in file match search calculations (#58240)
* Re-use cursor iterator in file match search calculations

* Remove prev loop value checks

* Skip empty matches
2023-12-18 13:56:43 -03:00
William Bezuidenhout
836271fddf
github-actions: report run failures to sentry (#59060)
* github-actions: report run failures to sentry

* report job name as well

* make buildchecker action consistent
2023-12-18 16:06:50 +00:00
Noah S-C
73e3500f0d
bazel: nicer error message for forbidigo patterns (#59081)
New output: `dev/linters/dbconn/dbconn.go:83:16: use of fmt.Errorf forbidden because “errors.Newf should be used instead” (forbidigo)`
Previous output: `dev/linters/dbconn/dbconn.go:83:16: use of fmt.Errorf forbidden by pattern ^fmt\.Errorf$ (forbidigo)`

## Test plan

Used `fmt.Errorf` in //dev/linters/dbconn` and ran bazel build on it
2023-12-18 16:06:19 +00:00
Jason Hawk Harris
6e3e54e86b
Sveltekit Prototype: add file icons to svelte prototype (#58861)
* add file icons to svelte prototype

* fix nits

* fix render bug

* adds check to determine whether generated extension exists in FileExtension enum

* Adjust containsTest export path

* optimize svelte kit file icons
2023-12-18 09:01:20 -06:00
William Bezuidenhout
790266de08
bazel: set retry flakes to 3 (#59078)
* bazel: set retry flakes to 3

* set it in the correct bazelrc
2023-12-18 16:58:53 +02:00
Felix Kling
8049a50f77
svelte: Link symbol search results (#59058)
svelte: Link symbol results to page
2023-12-18 15:46:53 +01:00
Noah S-C
10a0d12d5e
bazel: add tracing libraries lint to nogo (#58929)
Closes https://github.com/sourcegraph/sourcegraph/issues/54838

## Test plan

Added `github.com/opentracing/opentracing-go` to some package and did `bazel build //<pkg>` to observe:
`cmd/cody-gateway/internal/actor/limits.go:15:2: import 'github.com/opentracing/opentracing-go/log' is not allowed from list 'tracing libraries': use "go.opentelemetry.io/otel/trace" instead (depguard)`
2023-12-18 13:50:57 +00:00
William Bezuidenhout
d4660297f3
buildchecker: send an event to sentry if the action has failed (#59059)
* buildchecker: add step to report failures to sentry

* use dsn for sentry in action

* remove debug exit 1
2023-12-18 15:04:19 +02:00
Rafał Gajdulewicz
d5a6a0a007
Treat dotcom-user as dotcom user (duh) (#59054)
* Treat dotcom-user as dotcom user (duh)

* Also add unit tests
2023-12-18 09:52:53 +00:00
William Bezuidenhout
c4e28460b0
license checker: update reviewers for automated update license pr (#59053) 2023-12-18 10:56:43 +02:00
Stefan Hengl
7da4c4eb80
search: expose GitHub/GitLab topics in UI (#58927)
Currently, we sync topics from GitHub and GitLab and it is possible to
filter repositories by their topics with the `repo:has.topic` filter.

However, unlike user-added metadata, the synced topics are not visible in the UI,
neither for repo matches nor on the repo tree page. This means it is impossible 
for users to figure out which topics they can filter by.

With this PR we display topics, such as "language" or "golang", in addition to 
user-added metadata for repo matches and on the repo tree page.

## Test plan

Note: Our search language distinguishes between user provided metadata (has.meta) and automatically synced metadata (has.topic). 

- manual testing
  - I checked that clicking on a "topic" badge adds a "has.topic" filter, while clicking on a "metadata" badge add a "has.meta" filter
  - Adding and deleting metadata works like before
  - Topics and metadata are sorted alphabetically
  - Results without metadata or topics are displayed correctly
- added new unit test
2023-12-18 09:12:14 +01:00
Felix Kling
222da82631
svelte: Fix border style (#59049) 2023-12-17 12:11:23 +02:00
Robert Lin
2aa6e25796
externalAuthSignup: update v2 events to capture all cases (#59048)
Follow-up to https://github.com/sourcegraph/sourcegraph/pull/59036 , expanding the new `externalAuthSignup` event coverage for the purposes of a potential SAMS + telemetry V2 demo. Details in docstrings.
2023-12-15 21:34:08 -08:00
Camden Cheek
d0eb2e5e19
Extensions: some prep work for removal (#58640)
This is some setup for getting rid of all the cruft from extensions. The first step is to make the browser extension use the codeintel packages directly rather than requiring codeintel extensions running in a web worker. This extracts and simplifies few functions to prepare for that.
2023-12-15 20:07:14 -07:00
Robert Lin
8598eb1c9c
msp/iam: grant external secret to workload SA, not Cloud Run identity (#59045) 2023-12-15 17:08:17 -08:00
Camden Cheek
f3f8151c51
Search: respect the search.contextLines setting in the backend (#58943)
Currently, we do not respect the search.contextLines setting in the backend. Specifically, the search backend currently always yields results with zero lines of context.

One effect of this is in order to display matches with context lines, any client needs to make a followup request to fetch the full contents of the file. This makes the UI feel laggy because results filter in slowly as you scroll. This is exacerbated by the fact that we load the highlighted code, and highlighting can be unpredictable, sometimes taking a couple seconds to return.

We already stream the matched chunk back to the client, so this just updates the backend so that the streamed results include the number of context lines a user requested. Zoekt already supports this, so it was just a matter of taking advantage of that setting and updating searcher to do the same.
2023-12-15 16:32:25 -07:00