Commit Graph

37351 Commits

Author SHA1 Message Date
Christoph Hegemann
e0502149cc
codeintel: returns surroundingContent from search result (#64022)
Closes
https://linear.app/sourcegraph/issue/GRAPH-765/use-surroundingcontent-returned-from-the-search-client

The primary reason for doing this is to avoid sending a bunch of extra
calls for file contents to gitserver, which dominate the profile/trace
after implementing the remaining opts from
https://github.com/sourcegraph/sourcegraph/pull/63971

Also limits the API to only return the line containing the match for now
as discussed with Camden.

We might need to bring back the `lineGetter` for precise usages, but it
should be easy enough to revive at that point /cc @varungandhi-src

## Test plan

Updated unit tests, some manual testing in the API console
2024-07-25 09:50:33 +02:00
Varun Gandhi
2644e24244
fix: Fix Chrome stack overflow during highlighting (#64072)
Using the spread operator with large arrays can trigger a
stack overflow in Chrome/V8. For example, see:
- https://github.com/nodejs/node/issues/16870

In a highlighting context, we can have 10k-100k occurrences
in a file, so let's avoid using the spread operator.

Fixes https://linear.app/sourcegraph/issue/GRAPH-772

## Test plan

Manually tested against sample file.

![](https://github.com/user-attachments/assets/e096c664-063e-44ed-a991-72629af36651)

## Changelog

- Fixes a Chrome-specific stack overflow when highlighting large files.
2024-07-25 11:50:03 +08:00
Warren Gifford
15036143bc
bug/release: update version consts in updatecheck handler (#64052)
update version consts in updatecheck handler, temp solutions

see:
https://linear.app/sourcegraph/issue/REL-145/release-tie-release-consts-to-release-registry

## Test plan
No test

<!-- 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-07-24 20:32:10 -07:00
Craig Furman
29fc613c37
chore(appliance): expose status in config package (#64032)
So that other appliance subpackages (notably reconciler) can import it
without risking a circular dependency.

Relates to
https://linear.app/sourcegraph/issue/REL-78/when-sourcegraph-frontend-is-down-a-user-trying-to-access-sourcegraph
but does not close it. Bottom of a stack, likely more PRs incoming
today.

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

## Test plan

This is a refactor, all tests 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-07-24 16:09:09 -04:00
Noah S-C
c016ce08c1
Revert "chore(bazel): rework push_all to improve concurrency by avoiding bazel server lock" (#64051)
Reverts sourcegraph/sourcegraph#64044

Dockerhub cant handle it and keeps ratelimiting us

## Test plan

CI
2024-07-24 19:33:21 +00:00
William Bezuidenhout
0309564f93
ci: make internal+promote release higher priority in runtypes (#64049)
With the https://github.com/sourcegraph/sourcegraph/pull/63985/files
PatchRelease is matched before InternalRelease leading to the wrong
build being generated.

We therefore move the Promote and Internal Release runtypes higher in
priority so that they get matched first.

## Test plan
```
export RELEASE_INTERNAL=true
export VERSION="5.5.2463"
go run ./dev/sg ci preview
```
👇🏼 
```
go run ./dev/sg ci preview
⚠️ Running sg with a dev build, following flags have different default value unless explictly set: skip-auto-update, disable-analytics
If the current branch were to be pushed, the following pipeline would be run:
  Parsed diff:
  changed files: [WORKSPACE client/web-sveltekit/BUILD.bazel client/web-sveltekit/playwright.config.ts client/web-sveltekit/src/lib/navigation/GlobalHeader.svelte client/web-
  sveltekit/src/routes/[...repo=reporev]/(validrev)/(code)/page.spec.ts client/web/src/cody/chat/new-chat/NewCodyChatPage.tsx client/web/src/cody/sidebar/new-cody-sidebar/NewCodySidebar.tsx
  client/web/src/cody/sidebar/new-cody-sidebar/NewCodySidebarWebChat.tsx client/web/src/enterprise/batches/settings/AddCredentialModal.tsx
  client/web/src/enterprise/batches/settings/BatchChangesCreateGitHubAppPage.tsx client/web/src/repo/blame/hooks.ts client/web/src/repo/blame/shared.ts cmd/frontend/auth/user.go
  cmd/frontend/auth/user_test.go cmd/frontend/internal/codycontext/context.go cmd/frontend/internal/codycontext/context_test.go deps.bzl dev/ci/push_all.sh dev/ci/runtype/runtype.go go.mod go.sum
  internal/codeintel/uploads/BUILD.bazel internal/codeintel/uploads/internal/background/backfiller/BUILD.bazel internal/codeintel/uploads/internal/background/backfiller/mocks_test.go
  internal/codeintel/uploads/internal/background/commitgraph/BUILD.bazel internal/codeintel/uploads/internal/background/commitgraph/job_commitgraph.go
  internal/codeintel/uploads/internal/background/expirer/BUILD.bazel internal/codeintel/uploads/internal/background/expirer/mocks_test.go
  internal/codeintel/uploads/internal/background/processor/BUILD.bazel internal/codeintel/uploads/internal/background/processor/mocks_test.go internal/codeintel/uploads/internal/store/BUILD.bazel
  internal/codeintel/uploads/internal/store/commitdate.go internal/codeintel/uploads/internal/store/commitdate_test.go internal/codeintel/uploads/internal/store/observability.go
  internal/codeintel/uploads/internal/store/store.go internal/codeintel/uploads/mocks_test.go internal/database/migration/shared/data/cmd/generator/consts.go
  internal/database/migration/shared/data/stitched-migration-graph.json package.json pnpm-lock.yaml schema/schema.go schema/site.schema.json]
  diff changes: "Go, Client, pnpm, Docs, Shell"
  The generated build pipeline will now follow, see you next time!

  • Detected run type: Internal release
  • Detected diffs: Go, Client, pnpm, Docs, Shell
  • Computed variables:
    • VERSION=5.5.2463
  • Computed build steps:
    • Aspect Workflow specific steps
      • 🤖 Generated steps that include Buildifier, Gazelle, Test and Integration/E2E tests
    • Image builds
      • :bazel::packer: 🚧 Build executor image
    • :bazel: Bazel prechecks & build  sg
    • :bazel: BackCompat Tests
    • :bazel:🧹 Go mod tidy
    • Linters and static analysis
      • 🍍:lint-roller: Run sg lint → depends on bazel-prechecks
    • Client checks
      • :java: Build (client/jetbrains)
      • :vscode: Tests for VS Code extension
      • :stylelint: Stylelint (all)
    • Security Scanning
      • Semgrep SAST Scan
    • Publish candidate images
      • :bazel::docker: Push candidate Images
    • End-to-end tests
      • :bazel::docker::packer: Executors E2E → depends on bazel-push-images-candidate
    • Publish images
      • :bazel::packer:  Publish executor image → depends on executor-vm-image:candidate
      • :bazel:⤴️ Publish executor binary
      • :bazel::docker: Push final images → depends on main::test main::test_2
    • Release
      • Release tests → depends on bazel-push-images
      • Finalize internal release

```
<!-- 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-07-24 18:59:58 +00:00
Robert Lin
777f69d8e3
feat/enterpriseportal: ignore context cancellation error in GetCodyGatewayUsage (#64016)
Since this queries BigQuery under the hood, it can be a bit slow, and if
the client cancels there's no need for a Sentry report.

## Test plan

n/a
2024-07-24 11:50:21 -07:00
Beatrix
468a01a3ab
cody-gateway: handle missing Google response (#63895)
- Logs a warning instead of returning an error when the Google response
is missing
- This prevents the API from returning an error when the Google response
is empty, which can happen when Google is not happy with the question
due to safety issues. We will only log a decoder error as error.

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

## Test plan

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

only the log level was updated for empty responses. the function
behavior was not changed.

## Changelog

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

cody-gateway: log missing Google response as warning
2024-07-24 17:58:19 +00:00
Michael Lin
56817a7a9e
Revert "Syntactic indexing policy toggle: UI and supporting APIs" (#64046)
Reverts sourcegraph/sourcegraph#63876
https://sourcegraph.slack.com/archives/CHXHX7XAS/p1721835847010889

### Test plan

CI
2024-07-24 15:59:48 +00:00
Will Dollman
092b8be07f
Unpin openjdk-11 version in blobstore package (#64045)
<!-- PR description tips:
https://www.notion.so/sourcegraph/Write-a-good-pull-request-description-610a7fd3e613496eb76f450db5a49b6e
-->
We previously pinned the version of openjdk-11 in order to avoid a bad
package signature. This is no longer required.

## Test plan

- CI
- Manually verify updated package

<!-- 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-07-24 16:57:21 +01:00
Noah S-C
14123fcc42
chore(bazel): rework push_all to improve concurrency by avoiding bazel server lock (#64044)
This PR is a second attempt at improving push_all.sh, continuing on from
(and inspired by) https://github.com/sourcegraph/sourcegraph/pull/63391.
As a recap, that PR uses
[--script_path](https://bazel.build/reference/command-line-reference#flag--script_path)
to emit a short bash script for every `oci_push` target, which
essentially does minor setup + invokes the executable as if running
`bazel run`.

While the idea in https://github.com/sourcegraph/sourcegraph/pull/63391
was good, it trades concurrent server locking with an equal amount of
overhead in sequentially building the scripts. By observing the
scripts<b>[1]</b> that it would emit, we can notice a few things:
- The path
`/home/noah/.cache/bazel/_bazel_noah/8fd1d20666a46767e7f29541678514a0/execroot/__main__/bazel-out/k8-fastbuild/bin/`
shows up twice, which is the same path that `./bazel-bin` points at
- The script only `cd`'s to a path, unsets some environment variables,
and then executes the underlying script of the target.

The path can be observed to be a combination of bazel-bin, the target's
package (`//cmd/batcheshelper` in this case), as well as the target with
some extra static strings (`candidate_push` with `push_` prefix and
`.sh{,.runfiles}` suffixes for the script & its runfiles respectively).
Knowing this, and assuming that this is reliably so, we can opt to
recreate this manually instead, saving on the hefty overhead of `bazel
run --script_path`.

The current average times for `Push candidate images` and `Push final
images` are ~7m50s and ~8m30s respectively. While the example
main-dry-run build
[here](https://buildkite.com/sourcegraph/sourcegraph/builds/284041#0190e54a-9aaa-471a-81bf-623fce6ffa45)
isnt fully representative of how much rebuilding is required, it sets a
pretty solid 3m20s baseline.

Note this may break with rules_oci changes, but imo thats a small and
very infrequent cost to pay for cleaner log output + shaving a good
piece of time off.

<details><summary><b>[1]</b> A <code>--script_path</code>
example</summary>

```
#!/nix/store/mqc7dqwp046lh41dhs7r7q7192zbliwd-bash/bin/bash
cd /home/noah/.cache/bazel/_bazel_noah/8fd1d20666a46767e7f29541678514a0/execroot/__main__/bazel-out/k8-fastbuild/bin/cmd/batcheshelper/push_candidate_push.sh.runfiles/__main__ && \
  exec env \
    -u JAVA_RUNFILES \
    -u RUNFILES_DIR \
    -u RUNFILES_MANIFEST_FILE \
    -u RUNFILES_MANIFEST_ONLY \
    -u TEST_SRCDIR \
    BUILD_WORKING_DIRECTORY=/home/noah/Sourcegraph/sourcegraph \
    BUILD_WORKSPACE_DIRECTORY=/home/noah/Sourcegraph/sourcegraph \
  /home/noah/.cache/bazel/_bazel_noah/8fd1d20666a46767e7f29541678514a0/execroot/__main__/bazel-out/k8-fastbuild/bin/cmd/batcheshelper/push_candidate_push.sh "$@"
```

</details> 

## Test plan

Observe a `sg ci build main-dry-run`
[here](https://buildkite.com/sourcegraph/sourcegraph/builds/284041#0190e54a-9aaa-471a-81bf-623fce6ffa45).

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-24 16:55:09 +01:00
Erik Seliger
4f0b5fad17
Make cody gateway usage worker a periodic routine (#64040)
Adds better observability, and follows more standard patterns. I don't
know why I did it that way a year ago when I implemented this 🤦

Test plan: Code review to find behavior changes that CI cannot cover;
also CI.
2024-07-24 16:16:31 +02:00
Erik Seliger
652b734937
Remove dead collaborators invite code (#64039)
This code isn't used anywhere, so removing it.

Test plan: Go compiler doesn't complain.
2024-07-24 15:51:28 +02:00
Petri-Johan Last
bc036ad2ba
fix(source): Fix issue where worker would crash if a Bitbucket Cloud token couldn''t be refreshed (#64028) 2024-07-24 15:03:37 +02:00
Anton Sviridov
c14f892e9f
Syntactic indexing policy toggle: UI and supporting APIs (#63876)
Fixes GRAPH-636
Fixes GRAPH-751

This PR aims to allow admins to enable syntactic indexing on per-policy
basis using the existing UI and APIs with the following amendments:

- New UI toggle for syntactic indexing – **only visible if the
experimental feature is enabled** (see screenshots below)
- New field in GraphQL API for syntactic indexing
- New Go resolvers to handle the new field

To support this on the backend, we also update the policies handling
code and SQL queries to ensure we can retrieve and update the
`syntactic_indexing_enabled` field.

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

## Test plan

- Backend part covered by updated policies tests
- Manual testing of UI

With experimental feature **enabled**:

![CleanShot 2024-07-22 at 12 56
56](https://github.com/user-attachments/assets/e95aa224-be9a-40a6-9e42-6f409478e2fc)

With experimental feature **disabled**:
![CleanShot 2024-07-22 at 12 57
21](https://github.com/user-attachments/assets/0d46a65d-95bc-4695-a3df-ad9aa86dbd36)

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

## Changelog

- In site-admin APIs for updating code intelligence policies:
  - field `indexingEnabled` is renamed to `preciseIndexingEnabled`
- a required `syntacticIndexingEnabled` is added (only takes effect if
experimental feature is enabled)
  - field `forIndexing` is renamed to `forPreciseIndexing`

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-24 13:57:33 +01:00
Varun Gandhi
2663704fed
chore: Change some APIs to use symbols instead of monikers (#64029)
Monikers carry a bunch of redundant fields which basically consist of
information parsed out of the symbol name. This patch cleans up
some APIs to work with symbol names directly instead of monikers.
2024-07-24 20:11:03 +08:00
Stefan Hengl
51b340847d
chore(worker): move aggregated user stats job to worker (#64033)
This moves the job from `frontend` to `worker`.

Note:
I believe there was a subtle bug in the original code. We only evaluated
the
feature flag on startup, which means that changes of the feature flag
only took effect after a restart.

## Test plan:
new unit test
2024-07-24 13:27:22 +02:00
sourcegraph-buildkite
2f24e0f66b
security: Auto-update package lockfiles for Sourcegraph base images (#63776)
Automatically generated PR to update package lockfiles for Sourcegraph
base images.

Built from Buildkite run
[#283904](https://buildkite.com/sourcegraph/sourcegraph/builds/283904).
## Test Plan
- CI build verifies image functionality

Co-authored-by: Buildkite <buildkite@sourcegraph.com>
2024-07-24 12:15:34 +01:00
Christoph Hegemann
19db59b72c
Removes the old GitTreeTranslator API (#64027)
Following through after #63938 

## Test plan

Existing tests continue to pass
2024-07-24 09:22:42 +00:00
Varun Gandhi
dc7da57edb
chore: Make location fetching queries more uniform (#64026)
This patch changes the location querying code so that:
1. We're populating structures corresponding to SCIP instead of LSIF
   (with "scheme" and "identifier" inside "MonikerData")
2. Avoid repeatedly allocating a constant string 'scip' for the scheme
    only to throw it away later.
3. Makes the two queries and their scanning code more similar for easier
    comparison. When I land precise usagesForSymbol, I will de-duplicate
    some of the scanning code between these two queries.

I have avoided renaming all of the local variables to avoid creating
more noise.

## Test plan

Covered by existing tests.
2024-07-24 11:14:22 +02:00
Will Dollman
9dd901f3c9
Integrate security release approval into release pipeline (#63990)
As part of the [Vuln Scanning
Improvements](https://linear.app/sourcegraph/project/[p0]-vulnerability-scanning-improvements-75299c4312dd/issues)
project, I've been working on tooling to automate the security approval
step of the release process.

This PR integrates these improvements into the release pipeline:

* Internal releases will run a vulnerability scan
* Promote-to-public releases will check for security approval

If a public release does not have security approval, it will block the
promotion process. The step happens at the start of the pipeline so
should be a fast-fail. You can also check for release approval before
running promotion by running `@secbot cve approve-release <version>` in
the #secbot-commands channel. In an ideal world we (security) will have
already gone through and approved ahead of release.

I've tested this PR as much as I can without running an actual release!
We have a 5.5.x release tomorrow so it'll be a good test. If it does
cause problems that can't be easily solved, it can always be temporarily
disabled.

I've tagged this PR to be backported to `5.5.x`.

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

## Pre-merge checklist

- [x] Revert commit that disables release promotion

## Test plan

Manual testing of the release process:
- [x] [Successful test
run](https://buildkite.com/sourcegraph/sourcegraph/builds/283774#0190dfd6-fa70-4cea-9711-f5b8493c7714)
that shows the security scan being triggered
- [x] [Promote to public test
run](https://buildkite.com/sourcegraph/sourcegraph/builds/283826) that
shows the security approval approving a release
- [x] [Promote to public test
run](https://buildkite.com/sourcegraph/sourcegraph/builds/283817#0190e0ec-0641-4451-b7c7-171e664a3127)
that shows the security approval rejecting a release with un-accepted
CVEs

<!-- 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-07-24 09:19:49 +01:00
Stefan Hengl
d3528061cd
chore(worker): move llm token counter to worker (#64008)
This moves the LLM token counter from `frontend` to the `worker`.

Test plan:
new unit test
2024-07-24 10:03:33 +02:00
Stefan Hengl
40a436d159
fix(search_jobs): flickering placeholder component (#64009)
We have to use `debouncedSearchTerm` to give the paginated fetcher some
time to fetch the new results.

## Test plan:
visual inspection
2024-07-24 10:02:08 +02:00
Varun Gandhi
1b0e004d03
chore(codeintel): Rename uploads/../Store -> codegraph/../DataStore (#64001)
Also consolidates mocks to avoid wasting time generating
and compiling them repeatedly, and reducing pollution of
Find Usages results in the editor (yes, I know these can be
filtered out, but it's silly to have multiple copies).
2024-07-24 08:24:20 +01:00
Christoph Hegemann
eefcc7ea14
codeintel: fetches diffs from gitserver in batches (#64025)
Closes
https://linear.app/sourcegraph/issue/GRAPH-769/fetch-diffs-in-batches

## Test plan
Covered by existing tests (noticeable because tests need updates as we
now use the path out of the returned diff)
2024-07-24 06:12:47 +00:00
Christoph Hegemann
46e589d6c8
codeintel: runs occurrence and symbol search in parallel (#64023)
Closes
https://linear.app/sourcegraph/issue/GRAPH-767/search-based-run-occurrence-search-and-symbol-search-in-parallel

## Test plan

Covered by existing tests and checking the trace to see executes
overlapping:

![image](https://github.com/user-attachments/assets/75d9644f-cae7-46b9-a1bf-d3cdbb396dc8)
2024-07-24 04:36:49 +00:00
Christoph Hegemann
34e40c372c
codeintel: GitTreeTranslator rewrite (#63938)
Closes
https://linear.app/sourcegraph/issue/GRAPH-742/simplify-gittreetranslator-implementation

- use unified diff format and 0 context lines to allow translation by
just using hunk headers
- only request hunks per file once, and sync follow-up requests for the
same file
- don't bother LRU caching the full hunk contents, just store 4 int32's
per hunk
- replace linear search through sorted hunks with binary search

Current PR keeps the old PR and just proxies to the new implementation.
Once this PR is reviewed and merged I'll remove the old API and update
all callsites.

## Test plan
New/existing tests
2024-07-24 04:13:36 +02:00
Quinn Slack
dd29976250
track usage stats for saved searches in UTC day increments (#63904)
This makes it easier to chart this metric on a daily basis. Transmitting
the count in a rolling 24-hour window is harder.

Note that this new usagestats schema for saved searches has not yet been
released in a patch or stable release.


## Test plan

CI
2024-07-23 19:17:40 -06:00
Robert Lin
e0b959b551
feat/enterpriseportal: support DevOnly in list subscriptions (#63837)
We need to ensure prod data does not end up in the dev Enterprise Portal
instance once we start syncing. This change adds support for the DevOnly
option in ListSubscriptions and strictly enforces it there (i.e. dev
subscriptions cannot end up in the prod instance either).

I've tried to minimize the changes elsewhere to reduce the impact of
this change for now.

## Test plan

Tests
2024-07-23 22:20:35 +00:00
Robert Lin
31b271b491
feat/frontend/dotcom: add toggles for various online license checks (#64013)
Adds the following toggles for various dotcom-mode online licensing
capabilities:

- `DOTCOM_ENABLE_ONLINE_LICENSE_CHECKS=false` makes it so that the
license check "pings" always return "you're good to go"
- `DOTCOM_ENABLE_ANOMALOUS_LICENSE_CHECKER=false` disables the Redis +
event_logs thing looking for suspicious pings
- `DOTCOM_ENABLE_UPCOMING_LICENSE_EXPIRATION_CHECKER=false` disables
Slack notifications for upcoming license expirations

All defaults still respect the existing behaviour.
https://github.com/sourcegraph/deploy-sourcegraph-cloud/pull/18712
explicitly sets the toggles for online license checks, per the
discussion in
https://sourcegraph.slack.com/archives/C012NU3PXA9/p1721669308549559

All of the above capabilities are planned to be migrated to Enterprise
Portal:

- https://linear.app/sourcegraph/issue/CORE-182
- https://linear.app/sourcegraph/issue/CORE-227
- https://linear.app/sourcegraph/issue/CORE-183

## Test plan

CI
2024-07-23 14:45:30 -07:00
Robert Lin
d19c1339a9
feat/enterpriseportal: db layer for subscription conditions (#63812)
Implements insert and retrieval of subscription conditions, similar to
#63792

Unlike for licenses, which have a more limited lifecycle (create and
revoke), subscriptions are longer-lived and may be updated frequently.
So the storage layer allows the caller to provide the conditions that
are of interest for recording.

Part of https://linear.app/sourcegraph/issue/CORE-156, but doesn't yet
use it from the API.
Part of https://linear.app/sourcegraph/issue/CORE-100

## Test plan

Integration tests
2024-07-23 19:27:08 +00:00
Robert Lin
cb7cef0348
chore/enterpriseportal: rewrite subscriptions API tests to be table-driven (#63831)
As we start adding more stuff here, we need a bit more flexibility to
add tests without it becoming overwhelming. The current copy-pasta is
quite difficult to read, this standardizes the expected behaviour for
the Update and List tests.

## Test plan

CI
2024-07-23 12:20:33 -07:00
Vova Kulikov
0a6e509af3
Bring back post-sign-up route to the backend router (#64011)
Fixes [inc-313
](https://sourcegraph.slack.com/archives/C07D8ETFAQP/p1721746352871739?thread_ts=1721745191.614829&cid=C07D8ETFAQP)

It should solve problems with the old auth flow in the new Svelte
version. Currently, the go router doesn't know anything about
post-sign-up flow, which is used in the JB Cody extension. Because of
this, it passes it to the Svelte version which doesn't implement this
route on the client (but the react version did have it on the client
which is why it worked before, before we rolled out Svelte version by
default)

## Test plan
- There is no good way to check this properly, but after this PR you
have to see a react (old) version of the App when you go to the
/post-sigh-up router
2024-07-23 12:27:11 -03:00
Jacob Pleiness
37cf4a7b7e
feature(appliance): UI installs Sourcegraph again (#63996)
<!-- PR description tips:
https://www.notion.so/sourcegraph/Write-a-good-pull-request-description-610a7fd3e613496eb76f450db5a49b6e
-->

The appliance UI creates a `configMap` that triggers our reconciler to
install Sourcegraph.

- Refactored React app to remove "demo" code where possible
- Added `status` functionality to get the status of deployments,
statefulsets, or persistent volume claims.
- Fix small code issue where `FromInt` was deprecated
- Add reconciliation loop for the appliance backing `configMap`


Install:

```shell
❯ k get pods
NAME                                         READY   STATUS    RESTARTS      AGE
blobstore-568d57d477-k5vrh                   1/1     Running   0             15m
codeinsights-db-0                            2/2     Running   0             15m
codeintel-db-0                               2/2     Running   0             15m
gitserver-0                                  1/1     Running   1 (14m ago)   14m
grafana-0                                    1/1     Running   0             15m
indexed-search-0                             2/2     Running   0             15m
pgsql-0                                      2/2     Running   0             15m
precise-code-intel-worker-6fd4d6c8d5-4rjbc   1/1     Running   1 (14m ago)   15m
precise-code-intel-worker-6fd4d6c8d5-6fjdw   1/1     Running   1 (14m ago)   15m
prometheus-6cd94d7485-4cx7n                  1/1     Running   0             15m
redis-cache-f4dc7d6b8-2tp5v                  2/2     Running   0             15m
redis-store-5d6fcc9c84-7sj8v                 2/2     Running   0             15m
repo-updater-9f695b7d5-r28t7                 1/1     Running   5 (14m ago)   15m
searcher-0                                   1/1     Running   0             15m
sourcegraph-frontend-64cc4458cd-4vdwq        1/1     Running   0             15m
sourcegraph-frontend-64cc4458cd-gd7bf        1/1     Running   0             15m
symbols-0                                    1/1     Running   0             13m
syntect-server-6d5d55fb4f-tgbsc              1/1     Running   0             15m
worker-66b4cd79b5-zw844                      1/1     Running   1 (13m ago)   15m

```

## Test plan

Unit tests where applicable and tested locally via UI and local cluster

<!-- 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-07-23 11:06:15 -04:00
Bolaji Olajide
067115910c
fix(ci): check command out for error when git fails (#63993)
Closes [#1110](https://github.com/sourcegraph/devx-support/issues/1110)
Closes DINF-96

We don't print the stdErr when a command fails … in particular when git
fails. Therefore we see very little in the panic of what went wrong.

Explanation:
> There's a weird behavior that occurs where an error isn't accessible
in the err variable
// from a *Cmd executing a git command after calling CombinedOutput().
// This occurs due to how Git handles errors and how the exec package in
Go interprets the command's output.
// Git often writes error messages to stderr, but it might still exit
with a status code of 0 (indicating success).
// In this case, CombinedOutput() won't return an error, but the error
message will be in the out variable.

## Test plan

Manual testing

```go
func main() {
	ctx := context.Background()
	cmd := exec.CommandContext(ctx, "git", "rev-parse", "--is-inside-work-tree")
	out, err := handleGitCommandExec(cmd)
	if err != nil {
		// er := errors.Wrap(err, fmt.Sprintf("idsdsd: %s", string(out)))
		panic(err)
	}
	fmt.Println("hello", string(out))
}
```

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-23 09:56:33 -05:00
Varun Gandhi
d93c0fdf90
chore: Document tech debt wrt multiple doc traversals (#64006) 2024-07-23 15:19:20 +02:00
Noah S-C
49b9b10468
chore(bazel): disable stamping on rust_binary targets (#64007)
We don't appear to make use of the stamp values for any rust_binary
targets, so lets not stamp it to save on cache invalidations

## Test plan

```
$ bazel build --stamp --workspace_status_command=./dev/bazel_stamp_vars.sh $(bazel query 'kind("rust_binary", //...)')
...
$ sha256sum bazel-bin/docker-images/syntax-highlighter/scip-ctags bazel-bin/docker-images/syntax-highlighter/crates/scip-syntax/scip-syntax bazel-bin/docker-images/syntax-highlighter/syntect_server
...
$ bazel build $(bazel query 'kind("rust_binary", //...)')
...
$ sha256sum bazel-bin/docker-images/syntax-highlighter/scip-ctags bazel-bin/docker-images/syntax-highlighter/crates/scip-syntax/scip-syntax bazel-bin/docker-images/syntax-highlighter/syntect_server
...
```
observe identical checksums

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-23 12:22:50 +00:00
Petri-Johan Last
777c7a0899
[logging] Only record events if a new user was created (#64004) 2024-07-23 13:48:11 +02:00
Rafał Gajdulewicz
a7f787a772
Implement server-side single-repo context fetching for RFC 969 (#63980)
Implements server-side part of AI-132, exposing a single-repo context
endpoint backed by Zoekt.

Differences from the current Enterprise endpoint (that is left
untouched):

- supports a single repo only
- supports passing a repo name, not Sourcegraph-assigned repo ID
- has a shorter, 5s timeout
- reports partial errors (if we hit issues converting search results to
git results, or if some retrievers time out)

## Test plan

- tested locally with 
```
{
  chatContext(
    query: "squirrel"
    repo: "github.com/sourcegraph/sourcegraph"
    interactionId: "foo"
  ) {
    contextItems {
      score
      retriever
      item {
        ... on FileChunkContext {
          blob {
            path
            repository {
              id
              name
            }
            commit {
              oid
            }
            url
          }
          startLine
          endLine
          chunkContent
        }
      }
    }
    partialErrors
  }
}

```
2024-07-23 13:36:00 +02:00
Varun Gandhi
978abd5020
chore(codeintel): Pass UsageKind instead of raw column names (#64003)
Pass down semantic information down as much as possible,
delaying lossy conversion to table names till the very end.

I will be introducing the `exhaustive` linter in a future PR
(https://golangci-lint.run/usage/linters/#exhaustive)
so that we can get a static error if you don't switch exhaustively.
2024-07-23 12:28:55 +02:00
Varun Gandhi
eeded69538
feat(build): Add exhaustruct linter (codeintel POC) (#63965)
For certain types, we do not want the zero-value initialization for structs.
This means we need to trade off readability vs exhaustive initialization
checking, as the Go syntax `Foo{Bar: bar}` is more readable, but doesn't do
exhaustiveness checking, and `Foo{bar}` does check for exhaustiveness but can be less
readable depending on context.

For now, the check is only introduced for one type, and is meant to be
opt-in so that code authors may choose for stricter checking.
2024-07-23 17:26:01 +08:00
Craig Furman
49a600220d
feat(appliance): deploy otel-agent (#63991)
Relates to
https://linear.app/sourcegraph/issue/REL-81/service-definition-otel-collector
but does not close it.
2024-07-23 09:04:12 +00:00
Craig Furman
6e31f0f4cc
chore(appliance): fix a failing test (#64002)
Semantic merge conflict in a test fixture, not caught by actual merge
conflict though.
2024-07-23 08:57:24 +00:00
Craig Furman
daae9adfb6
chore(appliance): split otel collector and agent (#63989)
Relates to

https://linear.app/sourcegraph/issue/REL-81/service-definition-otel-collector
but does not close it.

Some of the StandardConfig features (notably PodTemplateConfig) assume
that there is only one pod template "thing" per service. The otel
service contains an agent daemonset and a collector deployment, which
have quite different characteristics. We're less likely to paint
ourselves into a corner if we split these services at the config level.
2024-07-23 09:38:40 +01:00
Varun Gandhi
548cb609f3
chore(codeintel): Move mock generation near interface package (#64000)
This patch moves the mocks for `codenav/../lsifstore` package to a
separate package `lsifstore/mocks` instead of it living in `codenav`.
The problem is that if you update the `LsifStore` interface, then you
get an error when trying to regenerate mocks, as regeneration happens
in the `codenav` package, and that package's old mocks no longer
satisfy the new interface (so there is an error when looking at other test
files). Moving the codegen to a separate package avoids this problem.
2024-07-23 09:24:53 +01:00
Stefan Hengl
b2014e6abb
chore(search_jobs): improve description on main page (#63992)
The current description doesn't do a good job of explaining why Search
Jobs is useful and how to create a job.

## Test plan:
visual inspection

Co-authored-by: Erik Seliger <erikseliger@me.com>
2024-07-23 09:49:24 +02:00
Keegan Carruthers-Smith
48d61c44d3
cody: correct link to emacs-cody (#63974)
Test Plan: clicked link in editor to see if correct

Fixes https://github.com/sourcegraph/emacs-cody/issues/33
2024-07-23 09:40:49 +02:00
Stefan Hengl
8f7055249b
chore(worker): move event_logs janitor routines to worker (#63981)
This moves the janitor jobs for event logs from `frontend` to `worker`.

Next up: move the other recurring jobs as well.

## Test plan
- new unit tests
- manual testing: the worker dashboard showed the job is running
2024-07-23 09:40:22 +02:00
Varun Gandhi
2f09a80b6d
chore(codeintel): Move RequestState construction to separate func (#63998)
Separating out the logic into a different function so it can be reused
later for precise usagesForSymbol.
2024-07-23 07:09:27 +00:00
Varun Gandhi
dc693b504f
chore(codeintel): Simplify code using upload filtering (#63997)
A bunch of logic was constructing "visibleUpload" values but
it just needed to pass around CompletedUpload. Simplify that.
2024-07-23 14:50:01 +08:00