Commit Graph

455 Commits

Author SHA1 Message Date
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
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
Noah S-C
addba96f47
Revert "refactor: upgrade to rules_oci 2.0 (2nd attempt)" (#64351)
Reverts sourcegraph/sourcegraph#63829

Not working with Aspect Delivery

## Test plan

CI
2024-08-07 22:15:21 +00:00
Greg Magolan
be015c58c2
refactor: upgrade to rules_oci 2.0 (2nd attempt) (#63829)
2nd attempt of #63111, a follow up
https://github.com/sourcegraph/sourcegraph/pull/63085

rules_oci 2.0 brings a lot of performance improvement around oci_image
and oci_pull, which will benefit Sourcegraph. It will also make RBE
faster and have less load on remote cache.

However, 2.0 makes some breaking changes like

- oci_tarball's default output is no longer a tarball
- oci_image no longer compresses layers that are uncompressed, somebody
has to make sure all `pkg_tar` targets have a `compression` attribute
set to compress it beforehand.
- there is no curl fallback, but this is fine for sourcegraph as it
already uses bazel 7.1.

I checked all targets that use oci_tarball as much as i could to make
sure nothing depends on the default tarball output of oci_tarball. there
was one target which used the default output which i put a TODO for
somebody else (somebody who is more on top of the repo) to tackle
**later**.

## Test plan

CI. Also run delivery on this PR (don't land those changes)

---------

Co-authored-by: Noah Santschi-Cooney <noah@santschi-cooney.ch>
2024-08-07 22:21:49 +01:00
Matthew Manela
b2e550c8e5
feat(search): Enable improved symbol parsing for large repos (when using Rockskip) (#63988)
During an investigation, we saw that Rockskip was not using scip-ctags
for symbol parsing when applicable. This means that
1. Rockskip is getting less than optimal symbols for certain languages
(like Go)
2. Rockskip is getting no symbols for languages not in universal ctags
(Magik)

This PR attempts to solve this problem but updating Rockskip to re-use
the ctags parser pool logic from symbol service.

### Key Changes
- Update parser pool to be re-usable
- Push common logic for parser type detection into the parser pool
module
- Update rockskip service config to take a parser pool 
- Update and add unit/integration tests


## Questions
- What performance impact will using this pooled parser have compared to
its previous behavior of spawning a new ctags process each time?



## Test plan
- [x] Add unit tests
- [x] Update integration tests
- [x] Manually test rockskip
- [x] Manually test symbolservice (in case of regression)

---------

Co-authored-by: Keegan Carruthers-Smith <keegan.csmith@gmail.com>
2024-07-31 15:27:31 -04:00
Erik Seliger
41fdc5cc7c
symbols: Make symbols specific code internal (#63736)
This PR restructures the packages to move all symbols-only code into the
symbols service. This helps to reason better about which service is
accessing what datastores.

Test plan:

Just moved code, compiler and CI are happy.
2024-07-10 01:26:22 +02:00
Erik Seliger
60dc37d1a5
symbols: Minor code cleanup (#63708)
Was reading through the service, found these things and figured why not
commit them.

Test plan:

CI.
2024-07-10 01:22:03 +02:00
Erik Seliger
df4c636dc5
squirrel: Correctly use request context (#63729)
The ctx parameter was unused, and I noticed that the parser is called
without the request context. Fixing that here.

Test plan:

Code review and CI.
2024-07-09 22:06:01 +02:00
Erik Seliger
1287243cae
gitserver: Framework to support integration testing against gitserver (#62801)
This PR tinkers a bit with building a test helper to run integration
tests that are still ~lightweight against a real gitserver.
The caller can either clone a real repo to disk / embed it in the git
repo, or can create a small repo on the fly, and then get a running
gitserver gRPC server that returns all the data required.

These tests should only exist outside of cmd/ and internal/, as there is
a big potential to do cross-cmd imports from here, which can cause bad
coupling. But for just these tests, that should be fine.

The most trivial rockskip indexing job that I put in here to POC this
runs in 6.3s, including all setup and teardown. That seems very
reasonable to me.

Test plan:

The POC test passes.
2024-06-07 17:01:12 +02:00
Varun Gandhi
56f2f92491
chore: Delete old Dockerfile and build scripts (#62922)
We can build everything using Bazel, so these aren't used anywhere
2024-05-27 18:52:39 +02:00
Joe Chen
2589fef13e
lib/background: upgrade Routine interface with context and errors (#62136)
This PR is a result/followup of the improvements we've made in the [SAMS repo](https://github.com/sourcegraph/sourcegraph-accounts/pull/199) that allows call sites to pass down a context (primarily to indicate deadline, and of course, cancellation if desired) and collects the error returned from `background.Routine`s `Stop` method.

Note that I did not adopt returning error from `Stop` method because I realize in monorepo, the more common (and arguably the desired) pattern is to hang on the call of `Start` method until `Stop` is called, so it is meaningless to collect errors from `Start` methods as return values anyway, and doing that would also complicate the design and semantics more than necessary.

All usages of the the `background.Routine` and `background.CombinedRoutines` are updated, I DID NOT try to interpret the code logic and make anything better other than fixing compile and test errors.

The only file that contains the core change is the [`lib/background/background.go`](https://github.com/sourcegraph/sourcegraph/pull/62136/files#diff-65c3228388620e91f8c22d91c18faac3f985fc67d64b08612df18fa7c04fafcd).
2024-05-24 10:04:55 -04:00
Erik Seliger
c338a954b9
rockskip: Replace second long-running process with gRPC API (#62734)
We want to migrate the LogReverseEach call to gRPC methods as well.
However, it isn't a great practice to have to keep this process running for potentially hours, as any server restart will have to make the entire process start over.

With one call per commit, we're not occupying a process slot on gitserver, and rollouts of gitserver should much less affect rockskip, as individual commits can be retried before being returned to the rockskip code.

Closes #62100

Test plan:

Existing tests still pass, I let it index a repo locally and that was fast and I get results for symbols instantly now, but not a Rockskip expert so requesting review from the owners.
2024-05-21 17:45:27 +02:00
Erik Seliger
3594d26d9c
gitserver: Allow multiple ranges to be passed to Commits (#62705)
This will be useful for commit searches, and is generally supported by git so why not support it here. That also lets you express `A..B` as `B, ^A` if you want to do less string concatenation, for example.

Test plan:

Made sure all existing callers pass a non-empty string to the slice if they specify the slice at all, and all existing tests still pass.
2024-05-16 17:34:09 +02:00
Noah S-C
9b6ba7741e
bazel: transcribe test ownership to bazel tags (#62664) 2024-05-16 15:51:16 +01:00
Camden Cheek
a1949709ee
Make ignored types more explicit (#62576) 2024-05-09 12:25:52 -04:00
Camden Cheek
f139408329
Gitserver: add StatusTypeChanged to supported statuses in ChangedFiles (#62548)
This adds support for T statuses (type changed) to ChangedFiles. This was previously hard-erroring, which was causing problems for code insights and hybrid search.
2024-05-09 10:43:34 -04:00
Julie Tibshirani
9bf75a2f0f
Rockskip: refactor metrics registration (#62557)
This commit refactors the Rockskip metrics logic to use `observationCtx`. In
tests, we now pass `TestContext` which has a no-op metrics registerer.

This change lets us run more than one test that spins up a Rockskip service.
Without it, tests fail with "duplicate metrics registered" errors.
2024-05-09 07:43:13 -07:00
Geoffrey Gilmore
fc03ac90e9
symbols: replace usage of gitserver client's DiffSymbols method with new ChangedFiles method (#62355)
Part of https://github.com/sourcegraph/sourcegraph/issues/60654

This PR builds on the new ChangedFiles method introduced in https://github.com/sourcegraph/sourcegraph/pull/62354, and changes the symbols service to use it instead of the old custom diff symbols method.

## Test plan

Existing CI pipeline
2024-05-07 11:08:35 -07:00
Erik Seliger
75afb74586
gitserver: Utilize Commits method for RevList (#62369)
This PR replaces the gitserver client method RevList by the Commits method.
The Commits method can do the same, but it saves us from implementing and testing a second API. Also, the name RevList sounded very generic but it was super opinionated in the flags it uses, so it was really "ListCommitsForRockskip" but that is too application-specific so Commits is probably just as good.
We'll learn a bunch about our API endpoints as we finish migrating them all, so we can do proper optimizations afterwards.

Closes https://github.com/sourcegraph/sourcegraph/issues/62098

Test plan:

Integration and unit test for rockskip are still passing.
2024-05-06 16:54:59 +02:00
Erik Seliger
1423c2e8c8
rockskip: Switch from long-running process to pagination (#62259)
We want to migrate this call to gRPC. However, it isn't good practice to have to keep this process running for potentially hours, as any server restart will have to make the process start over.
With pagination here, we're not occupying a process slot on gitserver, and rollouts of gitserver should much less affect rockskip, as individual pages can be retried before being returned to the rockskip code.

Test plan:

Existing tests still pass, but not a Rockskip expert so requesting review from the owners.
2024-05-02 02:17:48 +02:00
Erik Seliger
7dc2707fff
chore: Break dependency of internal/trace on conf (#62177)
This PR adds an initializer function that will be called from the svcmain package through the call to tracer.Init.

The reasoning behind this is that it's very easy to accidentally use a package that uses conf internally from a service like Cody Gateway, Appliance, Migrator, or other MSP services and just because we don't have any config source for the trace ID should not let the process stall entirely.
To make it absolutely clear that a dependency is safe to use from a conf perspective, this change indicates that well by dropping the dependency on it entirely and making it another packages concern to pass this type down.

Test plan:

All tests for Sourcegraph are still passing.

---------

Co-authored-by: Robert Lin <robert@bobheadxi.dev>
2024-04-30 21:12:39 +02:00
Keegan Carruthers-Smith
6cb50bc283
symbols: use concurrency safe map for repoToSize in rockskip (#62114)
We are getting "fatal error: concurrent map writes" in production when
enabling rockskip at large customers. The root cause is the repoToSize
map which is read for every search request (and written every "cache
miss").

This was the easiest change to make. We should probably also be single
flighting this request, but that can be changed at another time.

Additionally fixed another bug where in the cache miss case we would do
`size :=` and therefore not update size from 0, which then does a
sqliteSearch. This means on the very first request to a rockskip repo we
would always do sqliteSearch which is also a waste of resources.

Test Plan: Stefan manually testing :)
2024-04-24 10:40:00 +02:00
Erik Seliger
70ef23e79c
chore: Remove dead code (#61899)
This code was unused or not reachable, so removing it.

Test plan:

Test suites still pass.
2024-04-16 10:17:47 +02:00
Will Dollman
d56fa926dd
Build images end-to-end using Bazel v2 (#61845)
* wip

* gitserver (mostly) wolfi 4 bazel

* the big heck of all things

* Add rules_apko lock translation rules to WORKSPACE

* Call apko_repositories() more

* fix rules_apko to handle our shorter repo urls

* fix workspace from rebase, and missing locks

* visibility on wolfi_base_image

* hand-fix a lock coz apko lock is 🅱️roken

* remove chainguard repo+keyring from base

* update locks

* add chainguard repo+keychain to single server manifest

* unrelated fixes, server+grafana still h*cked

* fix postgres-exporter

* the big fix

* aws lib got bumped?

* downgrade sso-oidc? idk

* ignore wolfi locks from prettier

* dynamically do the locks with a reporule

* document and make nice :nails:

* bazel run @rules_apko//apko patch

* Fix .typo.typo

* Update tooling for end-to-end Bazel images (#61106)

* Update sg wolfi image to build using Bazel

* bazel run @rules_apko//apko patch

* Fix .typo.typo

* Add update-images and implement apko YAML change monitoring

* Use bazel apko and add support for additional repos

* Refactor sg wolfi

* Rework wolfi base image auto-update pipeline

* sg bazel configure

* [rough] Add --check flag to sg wolfi lock

* Refactor sg wolfi lock --check

* Simplify check and update apko lock hash operations

* Fix resolveImagePath when running in bazel

* Fixup logic error in CheckApkoLockHashes

* Tweak DoBaseImageBuild output

* Remove debug output

* Fix sg wolfi lock --check behaviour for all images

* Replace base image build step with apko lock --check

* Remove debug line

* Minor fixups for CI step

* Wrap with AnnotatedCmd

* Fixup annotation

* Update apko lockfiles

* Allow additional repos to be passed

* Update build-base-image.sh with bazel + add back to pipeline

* Ensure that modified base images are rebuilt

* Solve bazelception

* Remove timestamp for bit-level reproducibility

* Skip local keygen when running on buildkite

* Add workaround for lack of local repo support in rules_apko

* Run apkoOps first as it's quick and might fail

* Remove blocking allBaseImagesBuilt step

* Remove unused promethus-gcp image

* Add special cases to resolveImagePath

* Cleanly handle case where no bazel build path exists

This could happen in cases where a base image is only used outside of sourcegraph/sourcegraph,
or if you've added a new base image config but haven't added the associated Bazel scaffolding

* Add debugging around failing docker builds

* More debugging

* Normalise apko_lockfile to match repo.bzl

* Fixup apko docker call

* Try passing imageconfigdir differently to docker

* Run ls in different container

* Soft-fail when using legacy build in Buildkite

* Add missing include

* Workaround for building sourcegraph and sourcegraph-dev

* Add postgresql-client package to server

This contains createdb, which was recently moved from postgresql

* Inflate postgres-12-codeinsights image to avoid rules_apko errors

* Remove update line from yaml files

* Fix issue caused by moving base sourcegraph image

* Remove apk-tools from server

* Update lockfiles

* Address review feedback

* Remove debug lines

* fix unbound var

---------

Co-authored-by: Noah Santschi-Cooney <noah@santschi-cooney.ch>

* go mod tidy + gazelle-update-repos after merging main

* Use aspect bazel cache

* Use Aspect bazel caching when calling bazel in bash and sg

* Append annotation

* Run apko lock on aspect agent

* Remove base image builds

Discussion in https://sourcegraph.slack.com/archives/C05EVRLQEUR/p1712307465660509

* Remove unused functionality

* Update BaseImageConfig comments

* Rewrite wolfi-images/README.md

* Add .apko/range.sh to .gitattributes

* Remove "wolfi" from :base_image and :base_tarball targets

* remove allowlist extras from debugging

* Tweak user instructions around package testing

* Add agent healthcheck to buildkite scripts

* prettier

* sg bazel configure

* bazel run //:gazelle-update-repos

---------

Co-authored-by: Noah Santschi-Cooney <noah@santschi-cooney.ch>
Co-authored-by: Noah S-C <noah@sourcegraph.com>
2024-04-12 16:18:43 +01:00
Erik Seliger
4c341b3400
conf: Move most confvalidators into common package (#61810)
Previously, some of these validators would not fire correctly, because some packages aren't imported from cmd/frontend.
The package that contributes validators MUST be imported into frontend, which is not guaranteed. By colocating the GetWarnings func and the validators in one package, this is effectively enforced.

There are a few left that were a little harder to migrate, but this feels like a useful first step (and the end of my time window for this rn 😬)

Test plan:

Moved code around, my instance can still start fine and doesn't report new errors.
2024-04-12 06:30:52 +02:00
Keegan Carruthers-Smith
a0b74fb665
symbols: avoid spamming handleParseRequest on context cancelation (#61732)
Understanding how Parse works (and its callers) with respect to
goroutines and channels is a sure path to the asylum. This is a short
term fix around how it behaves when the context is canceled.

From what I can tell we can have a large number of parse requests go
through handleParseRequest even once the context has been canceled,
leading to large amounts of logging of errors which all amount to
context canceled. This is a short term fix which drains the channel if
we know we are just gonna fail our call to handleParseRequest.

Test Plan: go test. Didn't manual test, but the code change is minor
enough that I trust it (famous last words).
2024-04-11 09:27:11 +02:00
Keegan Carruthers-Smith
e9d0d57d81
all: use observation.TestContextTB instead of TestContext (#61751)
observation.TestContextTB is better to use since your logs will be
scoped to your test and it will use a more pedantic prometheus registry.
To be honest TestContext should be removed but this is the first step.

This is a mechanical change. I replaced "&observation.TestContext" with
"observation.TestContextTB(t)". I then undid the change each time it
caused a compilation error (was only a handful of times).

Test Plan: go test
2024-04-10 14:07:39 +02:00
Keegan Carruthers-Smith
ae59c69d5a
symbols: canceling ParseRequest does not spam logs (#61719)
We are seeing lots of log spam related to cancelation of parse requests.
We haven't fully tracked this down yet, but the behaviour of spamming
logs in this case hides the real issue.

This adjusts the implementation in two places:
- We introduce a parseCanceled metric so we can still track this. This
  is used instead of parseFailed in case of cancelation. In this case we
  also do not emit the "Closing failed parser" even though we are. This
  is due to log spam.
- We introduce an ErrorFilter just for handleParseRequest that will
  elide Canceled from the logs. This is called per file. Note: we keep
  the error logging for canceled in the high level Parse handler which
  runs across all files.

Test Plan: go test. Unfortunetly that is as good as it gets for now, as
I investigate the root cause further I will test this code path (and
only merge once I have manually triggered and tested this code path).
2024-04-10 08:29:29 +02:00
Julie Tibshirani
f690f5c3f1
Symbols: Remove unused ctags config (#61701)
This PR removes the unused `ctagsBinary` field from symbols server and its
set-up commands. The binary that's actually used is loaded through a separate
codepath.
2024-04-09 08:21:32 -07:00
Keegan Carruthers-Smith
2ab15741c1
symbols: remove unused channel parseRequests (#61718)
We can remove it since it is only ever created and then closed, never
read or written to. It seems like at some point we moved to using
parseRequestOrErrors and didn't remove parseRequests.

Test Plan: go test
2024-04-09 13:00:31 +00:00
Will Dollman
2c1d55c00e
Revert "Hackathon: Build images end-to-end using Bazel (#60785)" (#61644)
This reverts commit 44db6658b6.
2024-04-05 13:43:19 +00:00
Will Dollman
44db6658b6
Hackathon: Build images end-to-end using Bazel (#60785)
* wip

* gitserver (mostly) wolfi 4 bazel

* the big heck of all things

* Add rules_apko lock translation rules to WORKSPACE

* Call apko_repositories() more

* fix rules_apko to handle our shorter repo urls

* fix workspace from rebase, and missing locks

* visibility on wolfi_base_image

* hand-fix a lock coz apko lock is 🅱️roken

* remove chainguard repo+keyring from base

* update locks

* add chainguard repo+keychain to single server manifest

* unrelated fixes, server+grafana still h*cked

* fix postgres-exporter

* the big fix

* aws lib got bumped?

* downgrade sso-oidc? idk

* ignore wolfi locks from prettier

* dynamically do the locks with a reporule

* document and make nice :nails:

* bazel run @rules_apko//apko patch

* Fix .typo.typo

* Update tooling for end-to-end Bazel images (#61106)

* Update sg wolfi image to build using Bazel

* bazel run @rules_apko//apko patch

* Fix .typo.typo

* Add update-images and implement apko YAML change monitoring

* Use bazel apko and add support for additional repos

* Refactor sg wolfi

* Rework wolfi base image auto-update pipeline

* sg bazel configure

* [rough] Add --check flag to sg wolfi lock

* Refactor sg wolfi lock --check

* Simplify check and update apko lock hash operations

* Fix resolveImagePath when running in bazel

* Fixup logic error in CheckApkoLockHashes

* Tweak DoBaseImageBuild output

* Remove debug output

* Fix sg wolfi lock --check behaviour for all images

* Replace base image build step with apko lock --check

* Remove debug line

* Minor fixups for CI step

* Wrap with AnnotatedCmd

* Fixup annotation

* Update apko lockfiles

* Allow additional repos to be passed

* Update build-base-image.sh with bazel + add back to pipeline

* Ensure that modified base images are rebuilt

* Solve bazelception

* Remove timestamp for bit-level reproducibility

* Skip local keygen when running on buildkite

* Add workaround for lack of local repo support in rules_apko

* Run apkoOps first as it's quick and might fail

* Remove blocking allBaseImagesBuilt step

* Remove unused promethus-gcp image

* Add special cases to resolveImagePath

* Cleanly handle case where no bazel build path exists

This could happen in cases where a base image is only used outside of sourcegraph/sourcegraph,
or if you've added a new base image config but haven't added the associated Bazel scaffolding

* Add debugging around failing docker builds

* More debugging

* Normalise apko_lockfile to match repo.bzl

* Fixup apko docker call

* Try passing imageconfigdir differently to docker

* Run ls in different container

* Soft-fail when using legacy build in Buildkite

* Add missing include

* Workaround for building sourcegraph and sourcegraph-dev

* Add postgresql-client package to server

This contains createdb, which was recently moved from postgresql

* Inflate postgres-12-codeinsights image to avoid rules_apko errors

* Remove update line from yaml files

* Fix issue caused by moving base sourcegraph image

* Remove apk-tools from server

* Update lockfiles

* Address review feedback

* Remove debug lines

* fix unbound var

---------

Co-authored-by: Noah Santschi-Cooney <noah@santschi-cooney.ch>

* go mod tidy + gazelle-update-repos after merging main

* Use aspect bazel cache

* Use Aspect bazel caching when calling bazel in bash and sg

* Append annotation

* Run apko lock on aspect agent

* Remove base image builds

Discussion in https://sourcegraph.slack.com/archives/C05EVRLQEUR/p1712307465660509

* Remove unused functionality

* Update BaseImageConfig comments

* Rewrite wolfi-images/README.md

* Add .apko/range.sh to .gitattributes

* Remove "wolfi" from :base_image and :base_tarball targets

* remove allowlist extras from debugging

* Tweak user instructions around package testing

* Add agent healthcheck to buildkite scripts

* prettier

---------

Co-authored-by: Noah Santschi-Cooney <noah@santschi-cooney.ch>
Co-authored-by: Noah S-C <noah@sourcegraph.com>
2024-04-05 13:57:45 +01:00
Noah S-C
21e8d2876b
bazel: move internal/version stamping to internal/version's go_library decl (#61495)
Instead of having to declare the stamp vars on every go_binary (and risk forgetting one, like in https://github.com/sourcegraph/sourcegraph/pull/61480/files#r1543982602), we can stamp at the go_library declaration point instead.

## Test plan

Locally tested with `strings`
2024-03-29 13:41:19 +00:00
Stefan Hengl
c370c99355
symbols: propagate errors (#61257)
Previously, errors from the Symbol service were not propagated due to a regression that occurred when we switched to grpc. This change fixes that. Additionally, we now signal whether the upper limit of symbol matches was hit so that we can show a notification.
2024-03-21 13:20:33 +01:00
Stefan Hengl
abf9ce3ef2
symbols: respect limits, merge properly (#61056)
fixes #60698

This fixes the following bugs for unindexed symbol search:

Now we respect the limit given by "frontend". Before, the upper limit of unindexed symbol search was hard coded to 500. This limit could not be overwritten with the count: filter.

Merge symbol matches properly, applying the same logic as we do for indexed search: Before, symbol matches within the same file were simply appended which created duplicates for AND/OR queries if separate terms of the query matched the same symbol.

Test plan:
New unit test
Partially covered by existing tests
2024-03-14 16:04:44 +01:00
Petri-Johan Last
0b5e7fd490
Replace all traditional for-loops (#60988) 2024-03-11 16:05:47 +02:00
Julie Tibshirani
c16806485f
Symbol search: support content-based lang detection (#60626)
The symbol service already stores each file's detected language. Now, when the
'search-content-based-lang-detection' feature is enabled, the symbols service
filters directly on the language column.

This PR doesn't update Rockskip, since it doesn't store the detected language.
2024-02-21 10:44:32 -08:00
Varun Gandhi
078da74505
squirrel: Allow .hxx extension for C++ (#60662) 2024-02-21 17:10:50 +08:00
Noah S-C
98e0f75d1e
bazel: use transitions to apply cross-compile platform automatically to oci_image (#60569)
Removes the need to pass `--config=docker-darwin` through the following mechanisms:

1. `--enable_platform_specific_config` to enable certain flags on macos only e.g. `--extra_toolchains @zig_sdk//toolchain:linux_amd64_gnu.2.34` and `--sandbox_add_mount_pair=/tmp` (see [.bazelrc change](https://github.com/sourcegraph/sourcegraph/pull/60569/files?file-filters%5B%5D=dotfile&show-viewed-files=true))
2. Apply a transition (using https://github.com/fmeum/with_cfg.bzl, please view [the following great video on it](https://www.youtube.com/watch?v=U5bdQRQY-io)) on `oci_image` targets when on the `@platforms//os:macos` platform to transition to the `@zig_sdk//platform:linux_amd64` platform. 
	- This will start at `oci_image` targets and propagate down to e.g. `go_{binary,library}` etc targets with the "transitioned" platform configuration, resulting in them being built with the transitioned-to platform
3. Remove `darwin_docker_e2e_go` config_setting and `darwin-docker` bool_flag.
	- These aren't necessary anymore, as the places where these were used were not in the transitive closure rooted at an `oci_image` target, meaning they wouldn't be transitioned.

To review, view [the following (filtered) files](https://github.com/sourcegraph/sourcegraph/pull/60569/files?file-filters%5B%5D=.bzl&file-filters%5B%5D=.sh&file-filters%5B%5D=.yaml&file-filters%5B%5D=No+extension&file-filters%5B%5D=dotfile&show-viewed-files=true)  along with [the root BUILD.bazel](https://github.com/sourcegraph/sourcegraph/pull/60569/files#diff-7fc57714ef13c3325ce2a1130202edced92fcccc0c6db34a72f7b57f60d552a3). All the other files are just changing the `load` statements from `@rules_oci` to `//dev:oci_defs.bzl`

## Test plan

CI, checked image locally and `sg test bazel-backend-integration` & `sg test bazel-e2e`
2024-02-20 13:57:56 +00:00
Noah S-C
19d9cfc73b
bazel: native go-mockgen in Bazel (#60386)
Adds a new:
- gazelle generator
- rule + rule targets + catchall target
for generating go-mockgen mocks & testing for their being up-to-date.

Each go_mockgen macro invocation adds targets for generating mocks, copying to the source tree, as well as testing whether the current source tree mocks are up-to-date.

How to use this: `bazel run //dev:go_mockgen` for the catch-all, or `bazel run //some/target:generate_mocks` for an individual package, and `bazel test //some/target:generate_mocks_tests` to test for up-to-date-ness. There is no catch-all for testing

This currently uses a fork of go-mockgen, with an open PR for upstream here: https://github.com/derision-test/go-mockgen/pull/50.

Closes https://github.com/sourcegraph/sourcegraph/issues/60099

## Test plan

Extensive testing during development, including the following cases:
- Deleting a generated file and its entry in a go_library/go_test `srcs` attribute list and then re-running `sg bazel configure`
- Adding a non-existent output directory to mockgen.test.yaml and running the bash one-liner emitted to prepare the workspace for rerunning `sg bazel configure`

The existing config tests a lot of existing paths anyway (creating mocks for a 3rd party library's interface, entries for a given output file in >1 config file etc)
2024-02-16 13:26:48 +00:00
Greg Magolan
20a3c0836e
bazel: don't build most oci_tarball targets with bazel build //... by tagging them all manual (#60529)
This change is to mitigate excessive remote cache network traffic in the event that oci_tarball targets are cache busted en masse.

Only //cmd/server:image_tarball and //docker-images/executor-vm:image_tarball and used as inputs to downstream targets so only
these two will be built and remote cached on CI.
2024-02-15 09:02:50 +00:00
Petri-Johan Last
458ce56cf3
Move ArchiveReader's git exec command to gitcli (#59933)
This PR migrates the ArchiveReader function's use of the exec endpoint to be in line with the rest of #59738

Additionally, sub-repo permission checks are now done on the server instead of in the client code.

---------

Co-authored-by: Erik Seliger <erikseliger@me.com>
2024-02-13 13:40:45 +02:00
Camden Cheek
1ead945267
Docs: update links to point to new site (#60381)
We have a number of docs links in the product that point to the old doc site. 

Method:
- Search the repo for `docs.sourcegraph.com`
- Exclude the `doc/` dir, all test fixtures, and `CHANGELOG.md`
- For each, replace `docs.sourcegraph.com` with `sourcegraph.com/docs`
- Navigate to the resulting URL ensuring it's not a dead link, updating the URL if necessary

Many of the URLs updated are just comments, but since I'm doing a manual audit of each URL anyways, I felt it was worth it to update these while I was at it.
2024-02-13 00:23:47 +00:00
Will Dollman
29338b0e50
ctags: ensure that binary has correct featureset (#60084) 2024-02-05 09:39:06 +00:00
Will Dollman
e3889dff42
Test for jansson shared library rather than .la file (#60082)
Test for jansson shared library rather than libtool archive
2024-02-02 10:43:54 +00:00
Varun Gandhi
7f705ecb2e
build: Bump go-tree-sitter version and fix Squirrel queries (#59847)
Changes needed due to Tree-sitter grammar updates (implicitly updated
when updating the smacker/go-tree-sitter bindings since it bundles the
grammars)

- Previously, the Java grammar lumped all comments under the 'comment'
  marker, but it changed the queries to use 'line_comment' and
  'block_comment', which broke one of the tests for locating hovers.
- We need to extract the identifier out of an as_pattern,
  because the way the grammar is written, the 'as' in the
  exception clause is no longer treated as a separate anonymous
  keyword but as an 'as' expression.
2024-01-25 20:15:30 +08:00
Erik Seliger
f999dd3420
gitserver: Unify filereader API (#59782)
This PR consolidates two methods that were effectively doing the same thing: `ReadFile` and `NewFileReader` - where `ReadFile` used the latter under the hood, and wrapped an `io.ReadAll`.
Given entire files are returned from this function that can be of arbitrary size, exposing a simple high-memory-use footgun made me uneasy here, and having to use io.ReadAll explicitly as the consumer hopefully makes the person using this API feel the same way.
Sometimes, we can currently not avoid it (GQL layer), but where possible, using the reader is very likely the better option. 

Since there would've been a slight change in how errors are reported, I also fixed that. Previously, `NewFileReader` would NOT return `os.ErrNotExist` errors, those would only be discovered when the returned reader is called.
Now, like `ReadFile`, and like `os.Open` we immediately return that error.

This comes at the cost of making a second gRPC request. This is not great, but we will migrate the FileReader API to a proper gRPC hopefully ASAP, which will let us optimize it better on the server-side.
Since Varun also asked for perf improvements here, this is probably one of the first things that would be easy to switch over to go-git, eliminating probably 50%+ of the overhead here.
2024-01-24 13:53:57 +01:00
Erik Seliger
bb09a4ac1f
Remove HTTP for inter-service RPC (#59093)
In the upcoming release, we will only support gRPC going forward. This PR removes the old HTTP client and server implementations and a few leftovers from the transition.
2024-01-11 19:46:32 +01:00
James McNamara
960d97bf8b
bazel: first pass at moving moving logging linting into nogo (#58910)
* First pass at moving moving logging linting into Bazel

* fixed negation operators

* Update dev/linters/logging/logging.go

Co-authored-by: William Bezuidenhout <william.bezuidenhout@sourcegraph.com>

* added more exceptions and refactored one or two impls

* added nogo lint pragmas to offending files

* ran configure

* reverted git-combine refactor

* ran configure

* reverted test as well

---------

Co-authored-by: William Bezuidenhout <william.bezuidenhout@sourcegraph.com>
2024-01-02 10:07:25 -08:00
Varun Gandhi
b1f7ee0547
client: Obtain languages from server for file tree icons (#59234)
To determine the icon to show for a file, we need to know
the language. The code previously relied on the getFileInfo
API which did this using file extensions, leading to
incorrect results for header files with the '.h' extension,
which could have either C, C++ or Objective-C code.

Instead, we now get the language from the server,
where the go-enry library can optionally use the file
contents to return a more appropriate result.

Consequently, we can remove the getFileInfo API altogether.

Updates both the React and Svelte versions of the code.

Other changes in this patch:

- I've added icons for a bunch of languages which were missing.
- I've centralized the icon lists (and the bulk of the related logic) for
   both React and Svelte in one place.
2023-12-29 22:34:40 +05:30