bazel: fix remaining backend tests (#47961)

This PR fixes the last round of backend tests that are getting in the
way.

While most fixes are pertaining to adapting the code to deal with the
sandbox, or adjusting targets in some cases, we had to ignore the tests
from the database stitch migration (see
123cb55005)
(cc @efritz) because they are making strong assumptions toward running
inside the Sourcegraph repository, which is kinda non trivial to adapt.

Another one, albeit non consequential is the disabling of some tests
peforming external requests, which I think should be deleted anyway
(c83d8ebba8)

Fix https://github.com/sourcegraph/sourcegraph/issues/46837
Fix https://github.com/sourcegraph/sourcegraph/issues/46856
Fix https://github.com/sourcegraph/sourcegraph/issues/46862
Fix https://github.com/sourcegraph/sourcegraph/issues/46864
Fix https://github.com/sourcegraph/sourcegraph/issues/46833
Fix https://github.com/sourcegraph/sourcegraph/issues/46835
Fix https://github.com/sourcegraph/sourcegraph/issues/46836
Fix https://github.com/sourcegraph/sourcegraph/issues/46847
Fix https://github.com/sourcegraph/sourcegraph/issues/46838
Fix https://github.com/sourcegraph/sourcegraph/issues/46843
Fix https://github.com/sourcegraph/sourcegraph/issues/46845
Fix https://github.com/sourcegraph/sourcegraph/issues/46849
Fix https://github.com/sourcegraph/sourcegraph/issues/46851
Fix https://github.com/sourcegraph/sourcegraph/issues/46855
Fix https://github.com/sourcegraph/sourcegraph/issues/46857
Fix https://github.com/sourcegraph/sourcegraph/issues/46858
Fix https://github.com/sourcegraph/sourcegraph/issues/46859
Fix https://github.com/sourcegraph/sourcegraph/issues/46861
Fix https://github.com/sourcegraph/sourcegraph/issues/46863
Fix https://github.com/sourcegraph/sourcegraph/issues/46865
Fix https://github.com/sourcegraph/sourcegraph/issues/46867
Fix https://github.com/sourcegraph/sourcegraph/issues/46853

## Test plan

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->

Ran locally with bazel.

---------

Co-authored-by: davejrt <davetry@gmail.com>
This commit is contained in:
Jean-Hadrien Chabran 2023-03-01 18:03:01 +01:00 committed by GitHub
parent 9b5ce9c726
commit bc6a791710
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
202 changed files with 1319 additions and 333 deletions

View File

@ -32,6 +32,7 @@ linters-settings:
- github.com/hashicorp/go-multierror: "Use github.com/sourcegraph/sourcegraph/lib/errors instead"
# More performant regexp
- regexp: "Use github.com/grafana/regexp instead"
- github.com/hexops/autogold$: "Use github.com/hexops/autogold/v2 instead"
gocritic:
disabled-checks:
- appendAssign # Too many false positives

View File

@ -1820,7 +1820,6 @@ ENTERPRISE_BUNDLE_DATA_DEPS = BUNDLE_DATA_DEPS + [
# TODO(bazel): this is already in the main ts_project(srcs). Why also here?
"src/enterprise/codeintel/configuration/schema.json",
":enterprise-yaml",
]

View File

@ -23,6 +23,7 @@ go_library(
go_test(
name = "blobstore_test",
srcs = ["blobstore_test.go"],
data = glob(["testdata/**"]),
deps = [
":blobstore",
"//internal/observation",

View File

@ -54,6 +54,7 @@ go_test(
"//schema",
"@com_github_derision_test_go_mockgen//testutil/require",
"@com_github_google_go_cmp//cmp",
"@com_github_stretchr_testify//assert",
"@com_github_stretchr_testify//require",
],
)

View File

@ -9,7 +9,6 @@ go_library(
"inventory.go",
"mocks.go",
"mocks_temp.go",
"own.go",
"repos.go",
"repos_mock.go",
"symbols.go",
@ -48,8 +47,6 @@ go_library(
"//internal/gitserver/gitdomain",
"//internal/httpcli",
"//internal/inventory",
"//internal/own/codeowners",
"//internal/own/codeowners/v1:codeowners",
"//internal/randstring",
"//internal/rcache",
"//internal/repoupdater",
@ -77,7 +74,6 @@ go_test(
name = "backend_test",
srcs = [
"external_services_test.go",
"own_test.go",
"repos_test.go",
"repos_vcs_test.go",
"user_emails_test.go",
@ -107,8 +103,6 @@ go_test(
"//internal/gitserver",
"//internal/gitserver/gitdomain",
"//internal/inventory",
"//internal/own/codeowners",
"//internal/own/codeowners/v1:codeowners",
"//internal/rcache",
"//internal/repoupdater",
"//internal/repoupdater/protocol",

View File

@ -17,6 +17,7 @@ js_library(
go_library(
name = "graphqlbackend",
srcs = [
"access_requests.go",
"access_token.go",
"access_tokens.go",
"auth_provider.go",
@ -34,6 +35,7 @@ go_library(
"doc.go",
"dotcom.go",
"email_invitation.go",
"embeddings.go",
"empty_response.go",
"event_log.go",
"event_logs.go",
@ -46,7 +48,6 @@ go_library(
"executor_secret_connection.go",
"executor_secrets.go",
"executors.go",
"extension_registry.go",
"external_account.go",
"external_account_data_resolver.go",
"external_accounts.go",
@ -92,7 +93,7 @@ go_library(
"own.go",
"package_repos.go",
"parse_search_query.go",
"permission_sync_jobs.go",
"permissions_sync_jobs.go",
"person.go",
"phabricator.go",
"preview_repository_comparison.go",
@ -178,6 +179,7 @@ go_library(
"outbound_webhooks.graphql",
"rbac.graphql",
"own.graphql",
"embeddings.graphql",
],
importpath = "github.com/sourcegraph/sourcegraph/cmd/frontend/graphqlbackend",
deps = [
@ -197,6 +199,7 @@ go_library(
"//cmd/frontend/internal/search/logs",
"//cmd/frontend/internal/siteid",
"//cmd/frontend/internal/suspiciousnames",
"//cmd/migrator/shared",
"//internal/actor",
"//internal/adminanalytics",
"//internal/api",
@ -204,6 +207,7 @@ go_library(
"//internal/auth/sourcegraphoperator",
"//internal/authz",
"//internal/authz/permssync",
"//internal/binary",
"//internal/cloneurls",
"//internal/codeintel/dependencies",
"//internal/codeintel/resolvers",
@ -212,6 +216,8 @@ go_library(
"//internal/conf/deploy",
"//internal/conf/reposource",
"//internal/database",
"//internal/database/migration/cliutil",
"//internal/database/migration/schemas",
"//internal/encryption",
"//internal/encryption/keyring",
"//internal/env",
@ -269,7 +275,7 @@ go_library(
"//internal/webhooks/outbound",
"//lib/batches",
"//lib/errors",
"//lib/group",
"//lib/output",
"//schema",
"@com_github_gogo_protobuf//jsonpb",
"@com_github_golang_jwt_jwt_v4//:jwt",
@ -281,7 +287,7 @@ go_library(
"@com_github_graph_gophers_graphql_go//errors",
"@com_github_graph_gophers_graphql_go//introspection",
"@com_github_graph_gophers_graphql_go//relay",
"@com_github_graph_gophers_graphql_go//trace",
"@com_github_graph_gophers_graphql_go//trace/otel",
"@com_github_graphql_go_graphql//language/ast",
"@com_github_graphql_go_graphql//language/kinds",
"@com_github_graphql_go_graphql//language/parser",
@ -290,11 +296,11 @@ go_library(
"@com_github_hexops_gotextdiff//myers",
"@com_github_inconshreveable_log15//:log15",
"@com_github_masterminds_semver//:semver",
"@com_github_neelance_parallel//:parallel",
"@com_github_opentracing_opentracing_go//:opentracing-go",
"@com_github_opentracing_opentracing_go//ext",
"@com_github_prometheus_client_golang//prometheus",
"@com_github_prometheus_client_golang//prometheus/promauto",
"@com_github_sourcegraph_conc//pool",
"@com_github_sourcegraph_go_diff//diff",
"@com_github_sourcegraph_go_langserver//pkg/lsp",
"@com_github_sourcegraph_jsonx//:jsonx",
@ -304,12 +310,14 @@ go_library(
"@com_github_sourcegraph_zoekt//stream",
"@com_github_stretchr_testify//require",
"@com_github_throttled_throttled_v2//:throttled",
"@io_opentelemetry_go_otel//:otel",
],
)
go_test(
name = "graphqlbackend_test",
srcs = [
"access_requests_test.go",
"access_tokens_test.go",
"client_configuration_test.go",
"event_log_test.go",
@ -373,6 +381,8 @@ go_test(
"virtual_file_test.go",
"webhook_logs_test.go",
],
# graphqlbackend_test.go opens itself during its test, so we need to make it available.
data = ["graphqlbackend_test.go"], # keep
embed = [":graphqlbackend"],
deps = [
"//cmd/frontend/auth/providers",
@ -387,10 +397,12 @@ go_test(
"//internal/auth",
"//internal/authz",
"//internal/authz/permssync",
"//internal/binary",
"//internal/conf",
"//internal/conf/conftypes",
"//internal/database",
"//internal/database/dbtest",
"//internal/database/fakedb",
"//internal/encryption",
"//internal/extsvc",
"//internal/extsvc/gerrit",
@ -401,6 +413,7 @@ go_test(
"//internal/gitserver/gitdomain",
"//internal/gitserver/protocol",
"//internal/inventory",
"//internal/oobmigration",
"//internal/rcache",
"//internal/repos",
"//internal/repoupdater",
@ -432,7 +445,7 @@ go_test(
"@com_github_graph_gophers_graphql_go//:graphql-go",
"@com_github_graph_gophers_graphql_go//errors",
"@com_github_graph_gophers_graphql_go//relay",
"@com_github_hexops_autogold//:autogold",
"@com_github_hexops_autogold_v2//:autogold",
"@com_github_inconshreveable_log15//:log15",
"@com_github_sourcegraph_go_diff//diff",
"@com_github_sourcegraph_log//:log",

View File

@ -29,6 +29,7 @@ go_library(
"//cmd/frontend/internal/app/otlpadapter",
"//cmd/frontend/internal/app/router",
"//cmd/frontend/internal/app/ui",
"//cmd/frontend/internal/auth/accessrequest",
"//cmd/frontend/internal/auth/userpasswd",
"//cmd/frontend/internal/routevar",
"//cmd/frontend/internal/session",

View File

@ -22,8 +22,10 @@ go_library(
"//internal/database",
"//internal/env",
"//internal/lazyregexp",
"//internal/types",
"//internal/version",
"//schema",
"@com_github_graph_gophers_graphql_go//:graphql-go",
],
)

View File

@ -14,16 +14,22 @@ go_library(
"//internal/otlpenv",
"//lib/errors",
"@com_github_gorilla_mux//:mux",
"@com_github_prometheus_client_golang//prometheus",
"@com_github_sourcegraph_log//:log",
"@com_github_sourcegraph_log//std",
"@io_opentelemetry_go_collector//component",
"@io_opentelemetry_go_collector//config",
"@io_opentelemetry_go_collector//config/confighttp",
"@io_opentelemetry_go_collector//config/configtelemetry",
"@io_opentelemetry_go_collector//config/configtls",
"@io_opentelemetry_go_collector//exporter/otlpexporter",
"@io_opentelemetry_go_collector//exporter/otlphttpexporter",
"@io_opentelemetry_go_collector//receiver/otlpreceiver",
"@io_opentelemetry_go_collector//exporter",
"@io_opentelemetry_go_collector//receiver",
"@io_opentelemetry_go_collector_component//:component",
"@io_opentelemetry_go_collector_exporter_otlpexporter//:otlpexporter",
"@io_opentelemetry_go_collector_exporter_otlphttpexporter//:otlphttpexporter",
"@io_opentelemetry_go_collector_receiver_otlpreceiver//:otlpreceiver",
"@io_opentelemetry_go_otel//:otel",
"@io_opentelemetry_go_otel_exporters_prometheus//:prometheus",
"@io_opentelemetry_go_otel_metric//:metric",
"@io_opentelemetry_go_otel_sdk_metric//:metric",
"@org_uber_go_atomic//:atomic",
"@org_uber_go_zap//:zap",
],

View File

@ -7,7 +7,6 @@ go_library(
"handlers.go",
"help.go",
"landing.go",
"legacy_extensions_redirects.go",
"preview.go",
"raw.go",
"router.go",
@ -27,6 +26,7 @@ go_library(
"//cmd/frontend/globals",
"//cmd/frontend/hubspot",
"//cmd/frontend/hubspot/hubspotutil",
"//cmd/frontend/internal/app/assetsutil",
"//cmd/frontend/internal/app/jscontext",
"//cmd/frontend/internal/app/ui/router",
"//cmd/frontend/internal/handlerutil",
@ -97,7 +97,6 @@ go_test(
"//internal/search/result",
"//internal/types",
"//internal/version",
"//schema",
"//ui/assets",
"@com_github_gorilla_mux//:mux",
"@com_github_stretchr_testify//assert",

View File

@ -0,0 +1,37 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "accessrequest",
srcs = ["handlers.go"],
importpath = "github.com/sourcegraph/sourcegraph/cmd/frontend/internal/auth/accessrequest",
visibility = ["//cmd/frontend:__subpackages__"],
deps = [
"//cmd/frontend/internal/auth/userpasswd",
"//internal/actor",
"//internal/conf",
"//internal/database",
"//internal/deviceid",
"//internal/errcode",
"//internal/featureflag",
"//internal/types",
"//internal/usagestats",
"@com_github_sourcegraph_log//:log",
],
)
go_test(
name = "accessrequest_test",
srcs = ["handlers_test.go"],
embed = [":accessrequest"],
deps = [
"//internal/conf",
"//internal/database",
"//internal/database/dbtest",
"//internal/errcode",
"//internal/types",
"//schema",
"@com_github_sourcegraph_log//logtest",
"@com_github_stretchr_testify//require",
"@tools_gotest//assert",
],
)

View File

@ -3,6 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "bg",
srcs = [
"app_ready.go",
"check_redis_cache_eviction_policy.go",
"delete_old_cache_data_in_redis.go",
"delete_old_event_logs_in_postgres.go",
@ -12,6 +13,8 @@ go_library(
importpath = "github.com/sourcegraph/sourcegraph/cmd/frontend/internal/bg",
visibility = ["//cmd/frontend:__subpackages__"],
deps = [
"//cmd/frontend/globals",
"//internal/conf/deploy",
"//internal/database",
"//internal/rbac",
"//internal/rcache",
@ -20,6 +23,7 @@ go_library(
"//lib/errors",
"@com_github_gomodule_redigo//redis",
"@com_github_inconshreveable_log15//:log15",
"@com_github_pkg_browser//:browser",
"@com_github_sourcegraph_log//:log",
],
)

View File

@ -519,7 +519,7 @@ func gitserverAddr(environ []string) (string, error) {
// Detect 'go test' and setup default addresses in that case.
p, err := os.Executable()
if err == nil && strings.HasSuffix(p, ".test") {
if err == nil && (strings.HasSuffix(filepath.Base(p), "_test") || strings.HasSuffix(p, ".test")) {
return "gitserver:3178", nil
}

View File

@ -28,7 +28,6 @@ go_library(
"@com_github_getsentry_raven_go//:raven-go",
"@com_github_gorilla_mux//:mux",
"@com_github_inconshreveable_log15//:log15",
"@com_github_neelance_parallel//:parallel",
"@com_github_sourcegraph_log//:log",
],
)

View File

@ -3,6 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "highlight",
srcs = [
"chroma.go",
"highlight.go",
"html.go",
"language.go",
@ -12,14 +13,18 @@ go_library(
importpath = "github.com/sourcegraph/sourcegraph/cmd/frontend/internal/highlight",
visibility = ["//cmd/frontend:__subpackages__"],
deps = [
"//internal/binary",
"//internal/conf",
"//internal/conf/conftypes",
"//internal/conf/deploy",
"//internal/env",
"//internal/gosyntect",
"//internal/honey",
"//internal/observation",
"//internal/trace/ot",
"//lib/errors",
"@com_github_alecthomas_chroma_v2//:chroma",
"@com_github_alecthomas_chroma_v2//lexers",
"@com_github_go_enry_go_enry_v2//:go-enry",
"@com_github_grafana_regexp//:regexp",
"@com_github_inconshreveable_log15//:log15",

View File

@ -1,47 +1,18 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "api",
srcs = [
"doc.go",
"extension_connection_graphql.go",
"extension_graphql.go",
"extension_manifest.go",
"extension_remote_graphql.go",
"extensions.go",
"extensions_helpers.go",
"gating.go",
"http_api.go",
"registry_graphql.go",
],
importpath = "github.com/sourcegraph/sourcegraph/cmd/frontend/registry/api",
visibility = ["//visibility:public"],
deps = [
"//cmd/frontend/envvar",
"//cmd/frontend/graphqlbackend",
"//cmd/frontend/registry/client",
"//internal/conf",
"//internal/database",
"//internal/jsonc",
"//lib/errors",
"@com_github_graph_gophers_graphql_go//:graphql-go",
"@com_github_graph_gophers_graphql_go//relay",
],
)
go_test(
name = "api_test",
srcs = [
"extension_connection_graphql_test.go",
"extension_manifest_test.go",
"extensions_test.go",
],
embed = [":api"],
deps = [
"//cmd/frontend/envvar",
"//cmd/frontend/graphqlbackend",
"//cmd/frontend/registry/client",
"//internal/conf",
"//schema",
],
)

View File

@ -63,8 +63,8 @@ go_library(
"//internal/honey",
"//internal/hostname",
"//internal/lazyregexp",
"//internal/limiter",
"//internal/metrics",
"//internal/mutablelimiter",
"//internal/observation",
"//internal/ratelimit",
"//internal/search/streaming/http",
@ -137,7 +137,7 @@ go_test(
"//internal/gitserver/protocol",
"//internal/httpcli",
"//internal/httptestutil",
"//internal/mutablelimiter",
"//internal/limiter",
"//internal/observation",
"//internal/ratelimit",
"//internal/testutil",

View File

@ -272,7 +272,7 @@ func TestGitGCAuto(t *testing.T) {
// Create a test repository with detectable garbage that GC can prune.
wd := t.TempDir()
repo := filepath.Join(wd, "garbage-repo")
runCmd(t, wd, "git", "init", repo)
runCmd(t, wd, "git", "init", "--initial-branch", "main", repo)
// First we need to generate a moderate number of commits.
for i := 0; i < 50; i++ {
@ -290,7 +290,7 @@ func TestGitGCAuto(t *testing.T) {
}
// Bring everything back together in one branch.
runCmd(t, repo, "git", "checkout", "master")
runCmd(t, repo, "git", "checkout", "main")
runCmd(t, repo, "git", "merge", "secondary")
// Now create a bare repo like gitserver expects

View File

@ -49,8 +49,6 @@ go_library(
"@com_github_json_iterator_go//:go",
"@com_github_sourcegraph_log//:log",
"@com_github_tidwall_gjson//:gjson",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//reflection",
"@org_golang_x_sync//semaphore",
"@org_golang_x_time//rate",
],

View File

@ -3,6 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "repoupdater",
srcs = [
"grpc_server.go",
"observability.go",
"server.go",
],
@ -15,6 +16,7 @@ go_library(
"//internal/codeintel/dependencies",
"//internal/database",
"//internal/errcode",
"//internal/extsvc",
"//internal/extsvc/github",
"//internal/httpcli",
"//internal/instrumentation",
@ -22,6 +24,7 @@ go_library(
"//internal/observation",
"//internal/repos",
"//internal/repoupdater/protocol",
"//internal/repoupdater/v1:repoupdater",
"//internal/trace",
"//internal/types",
"//lib/errors",
@ -29,6 +32,8 @@ go_library(
"@com_github_sourcegraph_log//:log",
"@io_opentelemetry_go_otel//attribute",
"@io_opentelemetry_go_otel_trace//:trace",
"@org_golang_google_grpc//codes",
"@org_golang_google_grpc//status",
],
)
@ -50,10 +55,13 @@ go_test(
"//internal/extsvc/awscodecommit",
"//internal/extsvc/github",
"//internal/extsvc/gitlab",
"//internal/grpc",
"//internal/grpc/defaults",
"//internal/observation",
"//internal/repos",
"//internal/repoupdater",
"//internal/repoupdater/protocol",
"//internal/repoupdater/v1:repoupdater",
"//internal/timeutil",
"//internal/types",
"//internal/types/typestest",
@ -63,5 +71,6 @@ go_test(
"@com_github_inconshreveable_log15//:log15",
"@com_github_sourcegraph_log//logtest",
"@io_opentelemetry_go_otel_trace//:trace",
"@org_golang_google_grpc//:go_default_library",
],
)

View File

@ -28,12 +28,15 @@ go_library(
"//internal/env",
"//internal/extsvc",
"//internal/goroutine",
"//internal/grpc",
"//internal/grpc/defaults",
"//internal/httpcli",
"//internal/httpserver",
"//internal/instrumentation",
"//internal/observation",
"//internal/ratelimit",
"//internal/repos",
"//internal/repoupdater/v1:repoupdater",
"//internal/service",
"//internal/trace",
"//internal/types",
@ -42,6 +45,8 @@ go_library(
"@com_github_prometheus_client_golang//prometheus",
"@com_github_sourcegraph_log//:log",
"@io_opentelemetry_go_otel//:otel",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//reflection",
"@org_golang_x_time//rate",
],
)

View File

@ -27,8 +27,8 @@ go_library(
"//internal/errcode",
"//internal/gitserver",
"//internal/lazyregexp",
"//internal/limiter",
"//internal/metrics",
"//internal/mutablelimiter",
"//internal/observation",
"//internal/search",
"//internal/search/backend",
@ -93,11 +93,11 @@ go_test(
"//internal/search/backend",
"//internal/search/searcher",
"//lib/errors",
"//lib/group",
"//schema",
"@com_github_google_go_cmp//cmp",
"@com_github_grafana_regexp//:regexp",
"@com_github_roaringbitmap_roaring//:roaring",
"@com_github_sourcegraph_conc//pool",
"@com_github_sourcegraph_log//logtest",
"@com_github_sourcegraph_zoekt//:zoekt",
"@com_github_sourcegraph_zoekt//query",

View File

@ -30,8 +30,6 @@ go_library(
"//lib/errors",
"@com_github_keegancsmith_tmpfriend//:tmpfriend",
"@com_github_sourcegraph_log//:log",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//reflection",
"@org_golang_x_sync//errgroup",
],
)

View File

@ -37,6 +37,7 @@ go_test(
"nginx_test.go",
"redis_test.go",
],
data = ["//cmd/server/shared/assets:nginx"],
embed = [":shared"],
deps = ["@com_github_google_go_cmp//cmp"],
)

View File

@ -1,5 +1,11 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
filegroup(
name = "nginx",
srcs = glob(["nginx/**"]),
visibility = ["//visibility:public"],
)
go_library(
name = "assets",
srcs = ["assets.go"],

View File

@ -32,8 +32,8 @@ go_library(
"@com_github_sourcegraph_go_ctags//:go-ctags",
"@com_github_sourcegraph_log//:log",
"@io_opentelemetry_go_otel//attribute",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//reflection",
"@org_golang_google_grpc//codes",
"@org_golang_google_grpc//status",
],
)
@ -62,6 +62,8 @@ go_test(
"//internal/symbols",
"//internal/types",
"//lib/errors",
"@com_github_google_go_cmp//cmp",
"@com_github_google_go_cmp//cmp/cmpopts",
"@com_github_sourcegraph_go_ctags//:go-ctags",
"@org_golang_x_sync//semaphore",
],

View File

@ -46,6 +46,7 @@ go_test(
"local_code_intel_test.go",
"service_test.go",
],
data = glob(["test_repos/**"]), # keep
embed = [":squirrel"],
deps = [
"//internal/search",

View File

@ -1,8 +1,11 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "migrations",
srcs = ["init.go"],
srcs = [
"init.go",
"version.go",
],
importpath = "github.com/sourcegraph/sourcegraph/cmd/worker/internal/migrations",
visibility = ["//cmd/worker:__subpackages__"],
deps = [
@ -12,6 +15,15 @@ go_library(
"//internal/goroutine",
"//internal/observation",
"//internal/oobmigration",
"//internal/version",
"//lib/errors",
"@com_github_sourcegraph_log//:log",
],
)
go_test(
name = "migrations_test",
srcs = ["init_test.go"],
embed = [":migrations"],
deps = ["//internal/oobmigration"],
)

View File

@ -30,8 +30,8 @@ go_library(
"//internal/workerutil/dbworker",
"//internal/workerutil/dbworker/store",
"//lib/errors",
"//lib/group",
"@com_github_keegancsmith_sqlf//:sqlf",
"@com_github_sourcegraph_conc//pool",
"@com_github_sourcegraph_log//:log",
],
)

View File

@ -39,7 +39,7 @@ go_test(
"//dev/team",
"@com_github_buildkite_go_buildkite_v3//buildkite",
"@com_github_gorilla_mux//:mux",
"@com_github_hexops_autogold//:autogold",
"@com_github_hexops_autogold_v2//:autogold",
"@com_github_sourcegraph_log//logtest",
"@com_github_stretchr_testify//assert",
"@com_github_stretchr_testify//require",

View File

@ -48,7 +48,7 @@ go_test(
"@com_github_buildkite_go_buildkite_v3//buildkite",
"@com_github_dnaeon_go_vcr//cassette",
"@com_github_google_go_github_v41//github",
"@com_github_hexops_autogold//:autogold",
"@com_github_hexops_autogold_v2//:autogold",
"@com_github_stretchr_testify//assert",
"@org_golang_x_oauth2//:oauth2",
],

View File

@ -0,0 +1,18 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_library(
name = "app-discover-repos_lib",
srcs = ["app-discover-repos.go"],
importpath = "github.com/sourcegraph/sourcegraph/dev/internal/cmd/app-discover-repos",
visibility = ["//visibility:private"],
deps = [
"//internal/service/servegit",
"@com_github_sourcegraph_log//:log",
],
)
go_binary(
name = "app-discover-repos",
embed = [":app-discover-repos_lib"],
visibility = ["//dev:__subpackages__"],
)

View File

@ -19,5 +19,5 @@ go_test(
srcs = ["main_test.go"],
data = glob(["testdata/**"]),
embed = [":anonymiser_lib"],
deps = ["@com_github_hexops_autogold//:autogold"],
deps = ["@com_github_hexops_autogold_v2//:autogold"],
)

View File

@ -10,10 +10,10 @@ go_library(
visibility = ["//visibility:private"],
deps = [
"//dev/scaletesting/internal/store",
"//lib/group",
"//lib/output",
"@com_github_google_go_github_v41//github",
"@com_github_mattn_go_sqlite3//:go-sqlite3",
"@com_github_sourcegraph_conc//pool",
"@com_github_sourcegraph_run//:run",
"@org_golang_x_oauth2//:oauth2",
],

View File

@ -8,9 +8,9 @@ go_library(
deps = [
"//dev/scaletesting/internal/store",
"//lib/errors",
"//lib/group",
"//lib/output",
"@com_github_google_go_github//github",
"@com_github_sourcegraph_conc//pool",
"@com_github_sourcegraph_log//:log",
"@com_github_urfave_cli_v2//:cli",
"@org_golang_x_oauth2//:oauth2",

View File

@ -18,9 +18,9 @@ go_library(
"//dev/scaletesting/codehostcopy/bitbucket",
"//dev/scaletesting/internal/store",
"//lib/errors",
"//lib/group",
"//lib/output",
"@com_github_google_go_github//github",
"@com_github_sourcegraph_conc//pool",
"@com_github_sourcegraph_log//:log",
"@com_github_sourcegraph_run//:run",
"@com_github_urfave_cli_v2//:cli",

View File

@ -14,10 +14,10 @@ go_library(
importpath = "github.com/sourcegraph/sourcegraph/dev/scaletesting/syntheticgithubdata",
visibility = ["//visibility:private"],
deps = [
"//lib/group",
"//lib/output",
"@com_github_google_go_github_v41//github",
"@com_github_mattn_go_sqlite3//:go-sqlite3",
"@com_github_sourcegraph_conc//pool",
"@org_golang_x_oauth2//:oauth2",
],
)

View File

@ -148,7 +148,7 @@ go_test(
"//dev/sg/internal/std",
"//lib/output/outputtest",
"@com_github_google_go_cmp//cmp",
"@com_github_hexops_autogold//:autogold",
"@com_github_hexops_autogold_v2//:autogold",
"@com_github_stretchr_testify//assert",
"@com_github_urfave_cli_v2//:cli",
],

View File

@ -18,10 +18,12 @@ go_library(
"//dev/sg/internal/std",
"//dev/sg/internal/usershell",
"//dev/sg/root",
"//internal/limiter",
"//lib/errors",
"//lib/group",
"//lib/output",
"@com_github_masterminds_semver//:semver",
"@com_github_sourcegraph_conc//pool",
"@com_github_sourcegraph_conc//stream",
"@io_opentelemetry_go_otel//attribute",
"@io_opentelemetry_go_otel_trace//:trace",
"@org_uber_go_atomic//:atomic",

View File

@ -10,9 +10,9 @@ go_library(
"//dev/sg/internal/std",
"//dev/sg/root",
"//lib/errors",
"//lib/group",
"//lib/output",
"@com_github_grafana_regexp//:regexp",
"@com_github_sourcegraph_conc//pool",
"@com_github_sourcegraph_run//:run",
],
)

View File

@ -12,12 +12,12 @@ go_library(
"//dev/sg/internal/std",
"//enterprise/dev/ci/images",
"//lib/errors",
"//lib/group",
"//lib/output",
"@com_github_distribution_distribution_v3//reference",
"@com_github_docker_docker_credential_helpers//credentials",
"@com_github_masterminds_semver//:semver",
"@com_github_opencontainers_go_digest//:go-digest",
"@com_github_sourcegraph_conc//pool",
"@in_gopkg_yaml_v3//:yaml_v3",
"@io_k8s_sigs_kustomize_kyaml//kio",
"@io_k8s_sigs_kustomize_kyaml//yaml",

View File

@ -38,7 +38,7 @@ go_test(
srcs = ["util_test.go"],
embed = [":migration"],
deps = [
"@com_github_hexops_autogold//:autogold",
"@com_github_hexops_autogold_v2//:autogold",
"@com_github_stretchr_testify//require",
],
)

View File

@ -0,0 +1,18 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_library(
name = "embeddings_lib",
srcs = ["main.go"],
importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/embeddings",
visibility = ["//visibility:private"],
deps = [
"//enterprise/cmd/embeddings/shared",
"//enterprise/cmd/sourcegraph/enterprisecmd",
],
)
go_binary(
name = "embeddings",
embed = [":embeddings_lib"],
visibility = ["//visibility:public"],
)

View File

@ -0,0 +1,62 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "shared",
srcs = [
"config.go",
"context_detection.go",
"context_detection_cache.go",
"download_file.go",
"main.go",
"query_embeddings_cache.go",
"repo_embedding_index_cache.go",
"search.go",
"service.go",
],
importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/embeddings/shared",
visibility = ["//visibility:public"],
deps = [
"//cmd/frontend/globals",
"//enterprise/internal/authz",
"//enterprise/internal/authz/subrepoperms",
"//enterprise/internal/database",
"//enterprise/internal/embeddings",
"//enterprise/internal/embeddings/background/repo",
"//enterprise/internal/embeddings/embed",
"//internal/actor",
"//internal/api",
"//internal/authz",
"//internal/conf",
"//internal/conf/conftypes",
"//internal/database",
"//internal/database/connections/live",
"//internal/debugserver",
"//internal/env",
"//internal/gitserver",
"//internal/goroutine",
"//internal/honey",
"//internal/httpserver",
"//internal/instrumentation",
"//internal/lazyregexp",
"//internal/observation",
"//internal/service",
"//internal/trace",
"//internal/uploadstore",
"//lib/errors",
"@com_github_hashicorp_golang_lru//:golang-lru",
"@com_github_sourcegraph_log//:log",
],
)
go_test(
name = "shared_test",
srcs = ["repo_embedding_index_cache_test.go"],
embed = [":shared"],
deps = [
"//enterprise/internal/embeddings",
"//enterprise/internal/embeddings/background/repo",
"//internal/api",
"//internal/database",
"//internal/types",
],
)

View File

@ -11,6 +11,7 @@ go_library(
deps = [
"//enterprise/cmd/executor/internal/apiclient",
"//enterprise/cmd/executor/internal/worker/workspace",
"//enterprise/internal/executor/types",
"//internal/metrics",
"//internal/observation",
"//lib/errors",
@ -25,6 +26,7 @@ go_test(
deps = [
":files",
"//enterprise/cmd/executor/internal/apiclient",
"//enterprise/internal/executor/types",
"//internal/observation",
"//lib/errors",
"@com_github_stretchr_testify//assert",

View File

@ -12,7 +12,7 @@ go_library(
deps = [
"//enterprise/cmd/executor/internal/apiclient",
"//enterprise/cmd/executor/internal/command",
"//enterprise/internal/executor",
"//enterprise/internal/executor/types",
"//internal/executor",
"//internal/metrics",
"//internal/observation",
@ -32,11 +32,14 @@ go_test(
deps = [
":queue",
"//enterprise/cmd/executor/internal/apiclient",
"//enterprise/internal/executor/types",
"//internal/executor",
"//internal/observation",
"//lib/errors",
"@com_github_google_go_cmp//cmp",
"@com_github_prometheus_client_golang//prometheus",
"@com_github_prometheus_client_model//go",
"@com_github_stretchr_testify//assert",
"@com_github_stretchr_testify//require",
],
)

View File

@ -15,7 +15,7 @@ go_library(
visibility = ["//enterprise/cmd/executor:__subpackages__"],
deps = [
"//enterprise/cmd/executor/internal/config",
"//enterprise/internal/executor",
"//enterprise/internal/executor/types",
"//internal/executor",
"//internal/lazyregexp",
"//internal/metrics",
@ -43,7 +43,7 @@ go_test(
],
embed = [":command"],
deps = [
"//enterprise/internal/executor",
"//enterprise/internal/executor/types",
"//internal/executor",
"//internal/observation",
"//lib/errors",

View File

@ -9,7 +9,7 @@ go_library(
importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/executor/internal/config",
visibility = ["//enterprise/cmd/executor:__subpackages__"],
deps = [
"//enterprise/internal/executor",
"//enterprise/internal/executor/types",
"//internal/conf/confdefaults",
"//internal/conf/deploy",
"//internal/env",

View File

@ -20,7 +20,7 @@ go_library(
"//enterprise/cmd/executor/internal/janitor",
"//enterprise/cmd/executor/internal/worker",
"//enterprise/cmd/executor/internal/worker/workspace",
"//enterprise/internal/executor",
"//enterprise/internal/executor/types",
"//internal/download",
"//internal/goroutine",
"//internal/observation",

View File

@ -18,7 +18,7 @@ go_library(
"//enterprise/cmd/executor/internal/janitor",
"//enterprise/cmd/executor/internal/metrics",
"//enterprise/cmd/executor/internal/worker/workspace",
"//enterprise/internal/executor",
"//enterprise/internal/executor/types",
"//internal/goroutine",
"//internal/honey",
"//internal/observation",
@ -44,7 +44,7 @@ go_test(
"//enterprise/cmd/executor/internal/command",
"//enterprise/cmd/executor/internal/janitor",
"//enterprise/cmd/executor/internal/worker/workspace",
"//enterprise/internal/executor",
"//enterprise/internal/executor/types",
"//internal/executor",
"//internal/observation",
"@com_github_google_go_cmp//cmp",

View File

@ -14,7 +14,7 @@ go_library(
visibility = ["//enterprise/cmd/executor:__subpackages__"],
deps = [
"//enterprise/cmd/executor/internal/command",
"//enterprise/internal/executor",
"//enterprise/internal/executor/types",
"//lib/errors",
"@com_github_c2h5oh_datasize//:datasize",
],

View File

@ -9,6 +9,7 @@ go_library(
"//cmd/frontend/auth",
"//cmd/frontend/external/app",
"//cmd/frontend/graphqlbackend",
"//enterprise/cmd/frontend/internal/auth/azureoauth",
"//enterprise/cmd/frontend/internal/auth/bitbucketcloudoauth",
"//enterprise/cmd/frontend/internal/auth/gerrit",
"//enterprise/cmd/frontend/internal/auth/githuboauth",

View File

@ -0,0 +1,49 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "azureoauth",
srcs = [
"login.go",
"middleware.go",
"provider.go",
"session.go",
],
importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend/internal/auth/azureoauth",
visibility = ["//enterprise/cmd/frontend:__subpackages__"],
deps = [
"//cmd/frontend/auth",
"//cmd/frontend/auth/providers",
"//enterprise/cmd/frontend/internal/auth/oauth",
"//enterprise/internal/licensing",
"//internal/actor",
"//internal/conf",
"//internal/conf/conftypes",
"//internal/database",
"//internal/extsvc",
"//internal/extsvc/auth",
"//internal/extsvc/azuredevops",
"//lib/errors",
"//schema",
"@com_github_dghubble_gologin//:gologin",
"@com_github_dghubble_gologin//oauth2",
"@com_github_sourcegraph_log//:log",
"@org_golang_x_oauth2//:oauth2",
],
)
go_test(
name = "azureoauth_test",
srcs = ["provider_test.go"],
embed = [":azureoauth"],
deps = [
"//enterprise/cmd/frontend/internal/auth/oauth",
"//internal/conf",
"//internal/database",
"//internal/database/dbtest",
"//internal/extsvc",
"//schema",
"@com_github_google_go_cmp//cmp",
"@com_github_sourcegraph_log//logtest",
"@org_golang_x_oauth2//:oauth2",
],
)

View File

@ -7,6 +7,7 @@ go_library(
"middleware.go",
"provider.go",
"session.go",
"utils.go",
],
importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend/internal/auth/oauth",
visibility = ["//enterprise/cmd/frontend:__subpackages__"],
@ -22,6 +23,7 @@ go_library(
"//internal/database",
"//internal/env",
"//internal/extsvc",
"//internal/extsvc/azuredevops",
"//internal/extsvc/bitbucketcloud",
"//internal/extsvc/github",
"//internal/extsvc/gitlab",

View File

@ -4,7 +4,7 @@ go_library(
name = "resolvers",
srcs = [
"bitbucket_projects_permission_jobs.go",
"permission_sync_jobs.go",
"permissions_info.go",
"permissions_sync_jobs.go",
"repositories.go",
"resolver.go",
@ -17,7 +17,6 @@ go_library(
"//cmd/frontend/globals",
"//cmd/frontend/graphqlbackend",
"//cmd/frontend/graphqlbackend/graphqlutil",
"//enterprise/internal/authz/syncjobs",
"//enterprise/internal/database",
"//enterprise/internal/licensing",
"//internal/actor",
@ -27,7 +26,6 @@ go_library(
"//internal/authz/permssync",
"//internal/database",
"//internal/errcode",
"//internal/executor",
"//internal/extsvc",
"//internal/gitserver",
"//internal/gqlutil",
@ -44,7 +42,7 @@ go_library(
go_test(
name = "resolvers_test",
srcs = [
"permission_sync_jobs_test.go",
"permissions_sync_jobs_test.go",
"resolver_test.go",
],
embed = [":resolvers"],
@ -54,7 +52,6 @@ go_test(
"//cmd/frontend/graphqlbackend",
"//cmd/frontend/graphqlbackend/graphqlutil",
"//enterprise/internal/authz/github",
"//enterprise/internal/authz/syncjobs",
"//enterprise/internal/database",
"//enterprise/internal/licensing",
"//internal/actor",

View File

@ -103,6 +103,7 @@ go_test(
"changeset_spec_connection_test.go",
"changeset_spec_test.go",
"changeset_test.go",
"changesets_stats_test.go",
"code_host_connection_test.go",
"credential_test.go",
"main_test.go",

View File

@ -0,0 +1,17 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "completions",
srcs = ["init.go"],
importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend/internal/completions",
visibility = ["//enterprise/cmd/frontend:__subpackages__"],
deps = [
"//cmd/frontend/enterprise",
"//enterprise/cmd/frontend/internal/completions/streaming",
"//enterprise/internal/codeintel",
"//internal/conf/conftypes",
"//internal/database",
"//internal/observation",
"@com_github_sourcegraph_log//:log",
],
)

View File

@ -0,0 +1,18 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "streaming",
srcs = ["stream.go"],
importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend/internal/completions/streaming",
visibility = ["//enterprise/cmd/frontend:__subpackages__"],
deps = [
"//enterprise/cmd/frontend/internal/completions/streaming/anthropic",
"//enterprise/cmd/frontend/internal/completions/types",
"//internal/conf",
"//internal/httpcli",
"//internal/search/streaming/http",
"//internal/trace",
"//lib/errors",
"@com_github_sourcegraph_log//:log",
],
)

View File

@ -0,0 +1,34 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "anthropic",
srcs = [
"anthropic.go",
"decoder.go",
"prompt.go",
],
importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend/internal/completions/streaming/anthropic",
visibility = ["//enterprise/cmd/frontend:__subpackages__"],
deps = [
"//enterprise/cmd/frontend/internal/completions/types",
"//internal/httpcli",
"//lib/errors",
],
)
go_test(
name = "anthropic_test",
srcs = [
"anthropic_test.go",
"decoder_test.go",
"prompt_test.go",
],
data = glob(["testdata/**"]),
embed = [":anthropic"],
deps = [
"//enterprise/cmd/frontend/internal/completions/types",
"@com_github_hexops_autogold_v2//:autogold",
"@com_github_stretchr_testify//assert",
"@com_github_stretchr_testify//require",
],
)

View File

@ -8,7 +8,7 @@ import (
"net/http"
"testing"
"github.com/hexops/autogold"
"github.com/hexops/autogold/v2"
"github.com/stretchr/testify/assert"
"github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend/internal/completions/types"
@ -57,7 +57,7 @@ func TestValidAnthropicStream(t *testing.T) {
if err != nil {
t.Fatal(err)
}
autogold.Equal(t, events)
autogold.ExpectFile(t, events)
}
func TestInvalidAnthropicStream(t *testing.T) {

View File

@ -0,0 +1,9 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "types",
srcs = ["types.go"],
importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend/internal/completions/types",
visibility = ["//enterprise/cmd/frontend:__subpackages__"],
deps = ["//lib/errors"],
)

View File

@ -26,6 +26,6 @@ go_test(
"//enterprise/internal/compute",
"//internal/database",
"//internal/search/result",
"@com_github_hexops_autogold//:autogold",
"@com_github_hexops_autogold_v2//:autogold",
],
)

View File

@ -23,8 +23,8 @@ go_library(
"//internal/search/streaming/http",
"//internal/trace",
"//lib/errors",
"//lib/group",
"@com_github_opentracing_opentracing_go//log",
"@com_github_sourcegraph_conc//stream",
"@com_github_sourcegraph_log//:log",
],
)

View File

@ -0,0 +1,20 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "embeddings",
srcs = ["init.go"],
importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend/internal/embeddings",
visibility = ["//enterprise/cmd/frontend:__subpackages__"],
deps = [
"//cmd/frontend/enterprise",
"//enterprise/cmd/frontend/internal/embeddings/resolvers",
"//enterprise/internal/codeintel",
"//enterprise/internal/embeddings",
"//enterprise/internal/embeddings/background/contextdetection",
"//enterprise/internal/embeddings/background/repo",
"//internal/conf/conftypes",
"//internal/database",
"//internal/gitserver",
"//internal/observation",
],
)

View File

@ -0,0 +1,19 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "resolvers",
srcs = ["resolvers.go"],
importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend/internal/embeddings/resolvers",
visibility = ["//enterprise/cmd/frontend:__subpackages__"],
deps = [
"//cmd/frontend/graphqlbackend",
"//enterprise/internal/embeddings",
"//enterprise/internal/embeddings/background/contextdetection",
"//enterprise/internal/embeddings/background/repo",
"//internal/api",
"//internal/auth",
"//internal/database",
"//internal/gitserver",
"//lib/errors",
],
)

View File

@ -14,8 +14,10 @@ go_library(
"//enterprise/cmd/frontend/internal/executorqueue/handler",
"//enterprise/cmd/frontend/internal/executorqueue/queues/batches",
"//enterprise/cmd/frontend/internal/executorqueue/queues/codeintel",
"//enterprise/internal/executor/store",
"//internal/actor",
"//internal/api",
"//internal/conf",
"//internal/conf/confdefaults",
"//internal/conf/conftypes",
"//internal/conf/deploy",
@ -24,8 +26,8 @@ go_library(
"//internal/httpcli",
"//internal/metrics/store",
"//internal/observation",
"//lib/errors",
"@com_github_gorilla_mux//:mux",
"@com_github_inconshreveable_log15//:log15",
"@com_github_sourcegraph_log//:log",
],
)
@ -39,7 +41,16 @@ go_test(
],
embed = [":executorqueue"],
deps = [
"//enterprise/internal/executor/store",
"//internal/api",
"//internal/conf",
"//internal/database",
"//internal/types",
"//lib/errors",
"//schema",
"@com_github_gorilla_mux//:mux",
"@com_github_sourcegraph_log//logtest",
"@com_github_stretchr_testify//assert",
"@com_github_stretchr_testify//require",
],
)

View File

@ -9,7 +9,8 @@ go_library(
importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend/internal/executorqueue/handler",
visibility = ["//enterprise/cmd/frontend:__subpackages__"],
deps = [
"//enterprise/internal/executor",
"//enterprise/internal/executor/store",
"//enterprise/internal/executor/types",
"//internal/database",
"//internal/executor",
"//internal/metrics/store",
@ -20,7 +21,6 @@ go_library(
"//lib/errors",
"@com_github_gorilla_mux//:mux",
"@com_github_grafana_regexp//:regexp",
"@com_github_inconshreveable_log15//:log15",
"@com_github_prometheus_client_model//go",
"@com_github_prometheus_common//expfmt",
"@com_github_sourcegraph_log//:log",
@ -29,10 +29,14 @@ go_library(
go_test(
name = "handler_test",
srcs = ["handler_test.go"],
embed = [":handler"],
srcs = [
"handler_test.go",
"routes_test.go",
],
deps = [
"//enterprise/internal/executor",
":handler",
"//enterprise/internal/executor/store",
"//enterprise/internal/executor/types",
"//internal/database",
"//internal/executor",
"//internal/metrics/store",
@ -40,6 +44,11 @@ go_test(
"//internal/workerutil/dbworker/store",
"//internal/workerutil/dbworker/store/mocks",
"//lib/errors",
"@com_github_google_go_cmp//cmp",
"@com_github_gorilla_mux//:mux",
"@com_github_prometheus_client_model//go",
"@com_github_prometheus_common//expfmt",
"@com_github_stretchr_testify//assert",
"@com_github_stretchr_testify//mock",
"@com_github_stretchr_testify//require",
],
)

View File

@ -13,7 +13,7 @@ go_library(
"//enterprise/cmd/frontend/internal/executorqueue/handler",
"//enterprise/internal/batches/store",
"//enterprise/internal/batches/types",
"//enterprise/internal/executor",
"//enterprise/internal/executor/types",
"//internal/actor",
"//internal/conf",
"//internal/database",
@ -39,7 +39,7 @@ go_test(
"//cmd/frontend/graphqlbackend",
"//enterprise/internal/batches/store",
"//enterprise/internal/batches/types",
"//enterprise/internal/executor",
"//enterprise/internal/executor/types",
"//internal/api",
"//internal/conf",
"//internal/database",

View File

@ -12,7 +12,7 @@ go_library(
"//enterprise/cmd/frontend/internal/executorqueue/handler",
"//enterprise/internal/codeintel/autoindexing",
"//enterprise/internal/codeintel/shared/types",
"//enterprise/internal/executor",
"//enterprise/internal/executor/types",
"//internal/conf",
"//internal/database",
"//internal/encryption/keyring",
@ -31,7 +31,7 @@ go_test(
deps = [
"//enterprise/cmd/frontend/internal/executorqueue/handler",
"//enterprise/internal/codeintel/shared/types",
"//enterprise/internal/executor",
"//enterprise/internal/executor/types",
"//internal/conf",
"//internal/database",
"//internal/src-cli",

View File

@ -83,7 +83,7 @@ go_test(
"//lib/errors",
"@com_github_google_go_cmp//cmp",
"@com_github_graph_gophers_graphql_go//relay",
"@com_github_hexops_autogold//:autogold",
"@com_github_hexops_autogold_v2//:autogold",
"@com_github_sourcegraph_log//logtest",
"@com_github_stretchr_testify//assert",
"@com_github_stretchr_testify//require",

View File

@ -11,6 +11,8 @@ go_library(
"//enterprise/internal/codeintel",
"//internal/conf/conftypes",
"//internal/database",
"//internal/gitserver",
"//internal/observation",
"//internal/own",
],
)

View File

@ -1,4 +1,4 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "resolvers",
@ -7,6 +7,30 @@ go_library(
visibility = ["//enterprise/cmd/frontend:__subpackages__"],
deps = [
"//cmd/frontend/graphqlbackend",
"@com_github_graph_gophers_graphql_go//:graphql-go",
"//cmd/frontend/graphqlbackend/graphqlutil",
"//internal/api",
"//internal/database",
"//internal/own",
"//internal/own/codeowners",
],
)
go_test(
name = "resolvers_test",
srcs = ["resolvers_test.go"],
deps = [
":resolvers",
"//cmd/frontend/backend",
"//cmd/frontend/graphqlbackend",
"//internal/actor",
"//internal/api",
"//internal/authz",
"//internal/database",
"//internal/database/fakedb",
"//internal/gitserver",
"//internal/own/codeowners",
"//internal/own/codeowners/v1:codeowners",
"//internal/types",
"@com_github_graph_gophers_graphql_go//relay",
],
)

View File

@ -41,13 +41,19 @@ go_test(
"//internal/extsvc/bitbucketcloud",
"//internal/extsvc/bitbucketserver",
"//internal/extsvc/gitlab/webhooks",
"//internal/grpc",
"//internal/grpc/defaults",
"//internal/httpcli",
"//internal/repos",
"//internal/repoupdater",
"//internal/repoupdater/protocol",
"//internal/repoupdater/v1:repoupdater",
"//internal/types",
"//schema",
"@com_github_sourcegraph_log//logtest",
"@com_github_stretchr_testify//assert",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//codes",
"@org_golang_google_grpc//status",
],
)

View File

@ -18,8 +18,10 @@ go_library(
"//enterprise/cmd/frontend/internal/batches",
"//enterprise/cmd/frontend/internal/codeintel",
"//enterprise/cmd/frontend/internal/codemonitors",
"//enterprise/cmd/frontend/internal/completions",
"//enterprise/cmd/frontend/internal/compute",
"//enterprise/cmd/frontend/internal/dotcom",
"//enterprise/cmd/frontend/internal/embeddings",
"//enterprise/cmd/frontend/internal/executorqueue",
"//enterprise/cmd/frontend/internal/insights",
"//enterprise/cmd/frontend/internal/licensing/init",

View File

@ -14,7 +14,6 @@ go_library(
deps = [
"//cmd/frontend/envvar",
"//cmd/frontend/globals",
"//enterprise/internal/authz/syncjobs",
"//enterprise/internal/database",
"//enterprise/internal/licensing",
"//internal/api",
@ -36,12 +35,13 @@ go_library(
"//internal/workerutil/dbworker",
"//internal/workerutil/dbworker/store",
"//lib/errors",
"//lib/group",
"@com_github_keegancsmith_sqlf//:sqlf",
"@com_github_prometheus_client_golang//prometheus",
"@com_github_prometheus_client_golang//prometheus/promauto",
"@com_github_sourcegraph_conc//pool",
"@com_github_sourcegraph_log//:log",
"@io_opentelemetry_go_otel//attribute",
"@org_golang_x_exp//maps",
],
)
@ -78,11 +78,11 @@ go_test(
"//internal/workerutil/dbworker",
"//internal/workerutil/dbworker/store",
"//lib/errors",
"//lib/group",
"@com_github_derision_test_go_mockgen//testutil/require",
"@com_github_google_go_cmp//cmp",
"@com_github_grafana_regexp//:regexp",
"@com_github_inconshreveable_log15//:log15",
"@com_github_sourcegraph_conc//pool",
"@com_github_sourcegraph_log//logtest",
"@com_github_stretchr_testify//assert",
"@com_github_stretchr_testify//require",

View File

@ -6,6 +6,7 @@ go_library(
"autoindexing_dependency_scheduler_job.go",
"autoindexing_janitor.go",
"autoindexing_scheduler_job.go",
"autoindexing_summary_builder.go",
"commitgraph_updater_job.go",
"crates_syncer.go",
"lsifuploadstore_expirer.go",

View File

@ -0,0 +1,33 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "contextdetection",
srcs = [
"dataset.go",
"handler.go",
"janitor.go",
"worker.go",
],
importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/embeddings/contextdetection",
visibility = ["//enterprise/cmd/worker:__subpackages__"],
deps = [
"//cmd/worker/job",
"//cmd/worker/shared/init/db",
"//enterprise/internal/database",
"//enterprise/internal/embeddings",
"//enterprise/internal/embeddings/background/contextdetection",
"//enterprise/internal/embeddings/embed",
"//internal/actor",
"//internal/conf",
"//internal/env",
"//internal/gitserver",
"//internal/goroutine",
"//internal/observation",
"//internal/uploadstore",
"//internal/workerutil",
"//internal/workerutil/dbworker",
"//internal/workerutil/dbworker/store",
"//lib/errors",
"@com_github_sourcegraph_log//:log",
],
)

View File

@ -0,0 +1,34 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "repo",
srcs = [
"handler.go",
"janitor.go",
"worker.go",
],
importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/embeddings/repo",
visibility = ["//enterprise/cmd/worker:__subpackages__"],
deps = [
"//cmd/worker/job",
"//cmd/worker/shared/init/db",
"//enterprise/internal/database",
"//enterprise/internal/embeddings",
"//enterprise/internal/embeddings/background/repo",
"//enterprise/internal/embeddings/embed",
"//enterprise/internal/embeddings/split",
"//internal/actor",
"//internal/conf",
"//internal/env",
"//internal/gitserver",
"//internal/goroutine",
"//internal/observation",
"//internal/uploadstore",
"//internal/workerutil",
"//internal/workerutil/dbworker",
"//internal/workerutil/dbworker/store",
"//lib/errors",
"@com_github_grafana_regexp//:regexp",
"@com_github_sourcegraph_log//:log",
],
)

View File

@ -44,7 +44,7 @@ go_test(
"//lib/errors",
"//schema",
"@com_github_google_go_cmp//cmp",
"@com_github_hexops_autogold//:autogold",
"@com_github_hexops_autogold_v2//:autogold",
"@com_github_hexops_valast//:valast",
"@com_github_keegancsmith_sqlf//:sqlf",
"@com_github_lib_pq//:pq",

View File

@ -17,6 +17,8 @@ go_library(
"//enterprise/cmd/worker/internal/batches",
"//enterprise/cmd/worker/internal/codeintel",
"//enterprise/cmd/worker/internal/codemonitors",
"//enterprise/cmd/worker/internal/embeddings/contextdetection",
"//enterprise/cmd/worker/internal/embeddings/repo",
"//enterprise/cmd/worker/internal/executors",
"//enterprise/cmd/worker/internal/insights",
"//enterprise/cmd/worker/internal/permissions",

View File

@ -20,6 +20,7 @@ go_library(
"//enterprise/dev/ci/internal/ci/changed",
"//enterprise/dev/ci/internal/ci/operations",
"//internal/lazyregexp",
"//internal/oobmigration",
"//lib/errors",
"@com_github_masterminds_semver//:semver",
"@com_github_sourcegraph_log//:log",

View File

@ -23,6 +23,7 @@ go_test(
name = "app-token_test",
srcs = ["main_test.go"],
embed = [":app-token_lib"],
env = {"BUILDKITE": "true"},
deps = [
"//internal/httptestutil",
"@com_github_dnaeon_go_vcr//cassette",

View File

@ -63,6 +63,10 @@ func newTestGitHubClient(ctx context.Context, t *testing.T) (ghc *github.Client,
}
func TestGetInstallAccessToken(t *testing.T) {
// We cannot perform external network requests in Bazel tests, it breaks the sandbox.
if os.Getenv("BAZEL_TEST") == "1" {
t.Skip("Skipping due to network request")
}
ctx := context.Background()
ghc, stop := newTestGitHubClient(ctx, t)

View File

@ -34,7 +34,7 @@ go_test(
"perforce_test.go",
"protects_test.go",
],
data = glob(["testdata/**"]),
data = ["//enterprise/internal/authz/perforce/testdata:data"],
embed = [":perforce"],
deps = [
"//enterprise/internal/authz/subrepoperms",

View File

@ -0,0 +1,5 @@
filegroup(
name = "data",
srcs = glob(["*.txt"]),
visibility = ["//enterprise/internal/authz/perforce:__subpackages__"],
)

View File

@ -7,6 +7,7 @@ go_library(
visibility = ["//enterprise:__subpackages__"],
deps = [
"//enterprise/internal/batches/global",
"//enterprise/internal/batches/graphql",
"//enterprise/internal/batches/service",
"//enterprise/internal/batches/sources",
"//enterprise/internal/batches/state",

View File

@ -11,6 +11,7 @@ go_library(
importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/batches/reconciler",
visibility = ["//enterprise:__subpackages__"],
deps = [
"//enterprise/internal/batches/graphql",
"//enterprise/internal/batches/sources",
"//enterprise/internal/batches/state",
"//enterprise/internal/batches/store",

View File

@ -13,6 +13,7 @@ go_library(
visibility = ["//enterprise:__subpackages__"],
deps = [
"//enterprise/internal/batches/global",
"//enterprise/internal/batches/graphql",
"//enterprise/internal/batches/rewirer",
"//enterprise/internal/batches/sources",
"//enterprise/internal/batches/store",
@ -44,6 +45,7 @@ go_library(
"//lib/errors",
"@com_github_gobwas_glob//:glob",
"@com_github_grafana_regexp//:regexp",
"@com_github_graph_gophers_graphql_go//:graphql-go",
"@com_github_opentracing_opentracing_go//log",
"@com_github_sourcegraph_log//:log",
"@in_gopkg_yaml_v2//:yaml_v2",

View File

@ -3,6 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "sources",
srcs = [
"azuredevops.go",
"bitbucketcloud.go",
"bitbucketserver.go",
"common.go",
@ -14,6 +15,7 @@ go_library(
importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/batches/sources",
visibility = ["//enterprise:__subpackages__"],
deps = [
"//enterprise/internal/batches/sources/azuredevops",
"//enterprise/internal/batches/sources/bitbucketcloud",
"//enterprise/internal/batches/store",
"//enterprise/internal/batches/types",
@ -21,6 +23,7 @@ go_library(
"//internal/errcode",
"//internal/extsvc",
"//internal/extsvc/auth",
"//internal/extsvc/azuredevops",
"//internal/extsvc/bitbucketcloud",
"//internal/extsvc/bitbucketserver",
"//internal/extsvc/github",
@ -42,6 +45,7 @@ go_library(
go_test(
name = "sources_test",
srcs = [
"azuredevops_test.go",
"bitbucketcloud_test.go",
"bitbucketserver_test.go",
"github_test.go",
@ -53,6 +57,7 @@ go_test(
data = glob(["testdata/**"]),
embed = [":sources"],
deps = [
"//enterprise/internal/batches/sources/azuredevops",
"//enterprise/internal/batches/sources/bitbucketcloud",
"//enterprise/internal/batches/store",
"//enterprise/internal/batches/types",
@ -61,6 +66,7 @@ go_test(
"//internal/errcode",
"//internal/extsvc",
"//internal/extsvc/auth",
"//internal/extsvc/azuredevops",
"//internal/extsvc/bitbucketcloud",
"//internal/extsvc/bitbucketserver",
"//internal/extsvc/github",

View File

@ -0,0 +1,9 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "azuredevops",
srcs = ["types.go"],
importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/batches/sources/azuredevops",
visibility = ["//enterprise:__subpackages__"],
deps = ["//internal/extsvc/azuredevops"],
)

View File

@ -11,6 +11,7 @@ go_library(
importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/batches/state",
visibility = ["//enterprise:__subpackages__"],
deps = [
"//enterprise/internal/batches/sources/azuredevops",
"//enterprise/internal/batches/sources/bitbucketcloud",
"//enterprise/internal/batches/types",
"//internal/actor",
@ -18,6 +19,7 @@ go_library(
"//internal/authz",
"//internal/database",
"//internal/extsvc",
"//internal/extsvc/azuredevops",
"//internal/extsvc/bitbucketcloud",
"//internal/extsvc/bitbucketserver",
"//internal/extsvc/github",

View File

@ -28,6 +28,7 @@ go_library(
visibility = ["//enterprise:__subpackages__"],
deps = [
"//enterprise/internal/batches/search",
"//enterprise/internal/batches/sources/azuredevops",
"//enterprise/internal/batches/sources/bitbucketcloud",
"//enterprise/internal/batches/store/author",
"//enterprise/internal/batches/types",
@ -41,6 +42,7 @@ go_library(
"//internal/executor",
"//internal/extsvc",
"//internal/extsvc/auth",
"//internal/extsvc/azuredevops",
"//internal/extsvc/bitbucketcloud",
"//internal/extsvc/bitbucketserver",
"//internal/extsvc/github",

View File

@ -26,6 +26,7 @@ go_library(
importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/batches/types",
visibility = ["//enterprise:__subpackages__"],
deps = [
"//enterprise/internal/batches/sources/azuredevops",
"//enterprise/internal/batches/sources/bitbucketcloud",
"//internal/api",
"//internal/api/internalapi",
@ -45,6 +46,7 @@ go_library(
"//lib/batches",
"//lib/batches/execution",
"//lib/errors",
"@com_github_goware_urlx//:urlx",
"@com_github_graph_gophers_graphql_go//:graphql-go",
"@com_github_graph_gophers_graphql_go//relay",
"@com_github_inconshreveable_log15//:log15",
@ -65,10 +67,12 @@ go_test(
],
embed = [":types"],
deps = [
"//enterprise/internal/batches/sources/azuredevops",
"//enterprise/internal/batches/sources/bitbucketcloud",
"//internal/database",
"//internal/executor",
"//internal/extsvc",
"//internal/extsvc/azuredevops",
"//internal/extsvc/bitbucketcloud",
"//internal/extsvc/bitbucketserver",
"//internal/extsvc/github",

View File

@ -1,4 +1,4 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "webhooks",
@ -6,21 +6,49 @@ go_library(
"batch_change.go",
"changeset.go",
"event_types.go",
"gql.go",
"util.go",
"webhooks.go",
],
importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/batches/webhooks",
visibility = ["//enterprise:__subpackages__"],
deps = [
"//enterprise/internal/batches/graphql",
"//enterprise/internal/batches/types",
"//internal/database",
"//internal/api/internalapi",
"//internal/database/basestore",
"//internal/encryption",
"//internal/encryption/keyring",
"//internal/httpcli",
"//internal/webhooks/outbound",
"//lib/errors",
"@com_github_graph_gophers_graphql_go//:graphql-go",
"@com_github_graphql_go_graphql//gqlerrors",
"@com_github_sourcegraph_log//:log",
],
)
go_test(
name = "webhooks_test",
srcs = [
"batch_change_test.go",
"changeset_test.go",
],
embed = [":webhooks"],
deps = [
"//cmd/frontend/graphqlbackend",
"//enterprise/internal/batches/graphql",
"//enterprise/internal/batches/store",
"//enterprise/internal/batches/testing",
"//enterprise/internal/batches/types",
"//internal/actor",
"//internal/database",
"//internal/database/dbtest",
"//internal/observation",
"//internal/timeutil",
"@com_github_google_go_cmp//cmp",
"@com_github_google_go_cmp//cmp/cmpopts",
"@com_github_graph_gophers_graphql_go//:graphql-go",
"@com_github_sourcegraph_log//logtest",
"@com_github_stretchr_testify//mock",
"@com_github_stretchr_testify//require",
],
)

View File

@ -9,6 +9,7 @@ go_library(
"job_dependency_sync_scheduler.go",
"job_resetters.go",
"job_scheduler.go",
"job_summary_builder.go",
"metrics_janitor.go",
"metrics_resetter.go",
"utils.go",
@ -18,6 +19,7 @@ go_library(
deps = [
"//cmd/frontend/envvar",
"//enterprise/internal/codeintel/autoindexing/internal/inference",
"//enterprise/internal/codeintel/autoindexing/internal/jobselector",
"//enterprise/internal/codeintel/autoindexing/internal/store",
"//enterprise/internal/codeintel/autoindexing/shared",
"//enterprise/internal/codeintel/policies/enterprise",

View File

@ -9,13 +9,15 @@ go_library(
importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/codeintel/autoindexing/internal/jobselector",
visibility = ["//enterprise:__subpackages__"],
deps = [
"//enterprise/internal/codeintel/autoindexing/internal/background",
"//enterprise/internal/codeintel/autoindexing/internal/store",
"//enterprise/internal/codeintel/shared/types",
"//enterprise/internal/codeintel/uploads/shared",
"//internal/api",
"//internal/env",
"//internal/gitserver/gitdomain",
"//lib/codeintel/autoindex/config",
"//lib/errors",
"@com_github_grafana_regexp//:regexp",
"@com_github_sourcegraph_log//:log",
],
)

View File

@ -45,6 +45,7 @@ go_test(
"store_expiration_test.go",
"store_indexes_test.go",
"store_language_support_test.go",
"store_repositories_test.go",
"store_sourced_commits_test.go",
],
embed = [":store"],

View File

@ -20,6 +20,7 @@ go_library(
visibility = ["//enterprise:__subpackages__"],
deps = [
"//cmd/frontend/graphqlbackend/graphqlutil",
"//enterprise/internal/codeintel/autoindexing/internal/inference",
"//enterprise/internal/codeintel/autoindexing/shared",
"//enterprise/internal/codeintel/shared/resolvers",
"//enterprise/internal/codeintel/shared/types",

View File

@ -15,7 +15,6 @@ go_library(
"observability.go",
"scan.go",
"scip_decompressor.go",
"serializer.go",
"types.go",
],
importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/codeintel/codenav/internal/lsifstore",

View File

@ -27,10 +27,10 @@ go_library(
"//internal/search",
"//internal/search/result",
"//lib/errors",
"//lib/group",
"@com_github_dcadenas_pagerank//:pagerank",
"@com_github_grafana_regexp//:regexp",
"@com_github_prometheus_client_golang//prometheus",
"@com_github_sourcegraph_conc//pool",
"@com_github_sourcegraph_log//:log",
"@com_google_cloud_go_storage//:storage",
"@org_golang_google_api//iterator",

Some files were not shown because too many files have changed in this diff Show More