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)
This commit is contained in:
Noah S-C 2024-02-16 13:26:48 +00:00 committed by GitHub
parent 235781a3e7
commit 19d9cfc73b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
97 changed files with 1763 additions and 25 deletions

View File

@ -23,7 +23,7 @@ load("@buildifier_prebuilt//:rules.bzl", "buildifier")
# gazelle:js_npm_package_target_name {dirname}_pkg
# Enable: Aspect javascript, standard go
# gazelle:lang js,go,proto
# gazelle:lang js,go,proto,gomockgen
# Enable race detection for all go_test rules.
# gazelle:map_kind go_test go_test //dev:go_defs.bzl
@ -212,6 +212,7 @@ gazelle_binary(
# Gazelle-buf does not include the Go plugin by default, so we have to add it
# ourselves.
"@bazel_gazelle//language/go:go_default_library",
"//dev/go-mockgen-gazelle:go-mockgen-gazelle",
# Bundled with aspect-cli, but we're missing out on buf that way
"@aspect_cli//gazelle/js:js",
# Loads the Buf extension
@ -335,7 +336,7 @@ exports_files([
# under certain conditions. See //ui/assets/...
"CONTRIBUTING.md",
".swcrc",
])
] + glob(["mockgen*.yaml"]))
# sg msp settings

View File

@ -151,6 +151,13 @@ http_archive(
url = "https://github.com/aspect-build/aspect-cli/archive/5.8.20.tar.gz",
)
http_archive(
name = "rules_multirun",
sha256 = "9cd384e42b2da00104f0e18f25e66285aa21f64b573c667638a7a213206885ab",
strip_prefix = "rules_multirun-0.6.1",
url = "https://github.com/keith/rules_multirun/archive/refs/tags/0.6.1.tar.gz",
)
# hermetic_cc_toolchain setup ================================
HERMETIC_CC_TOOLCHAIN_VERSION = "v2.2.1"

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -44,3 +45,14 @@ go_test(
"@com_github_vektah_gqlparser_v2//gqlerror",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = ["@com_github_gregjones_httpcache//:httpcache"],
)

View File

@ -1,6 +1,7 @@
load("//dev:go_defs.bzl", "go_test")
load("//dev:write_generated_to_source_files.bzl", "write_generated_to_source_files")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("//dev:go_mockgen.bzl", "go_mockgen")
go_library(
name = "dotcom",
@ -47,3 +48,14 @@ go_test(
embed = [":dotcom"],
deps = ["@com_github_stretchr_testify//assert"],
)
go_mockgen(
name = "generate_mocks",
out = "mocks.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = ["@com_github_khan_genqlient//graphql"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -64,3 +65,22 @@ go_test(
"@com_github_stretchr_testify//require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [
"//cmd/executor/internal/util",
"//cmd/executor/internal/worker/cmdlogger",
"//cmd/executor/internal/worker/command",
"//cmd/executor/internal/worker/files",
"//cmd/executor/internal/worker/runner",
"//cmd/executor/internal/worker/runtime",
"//cmd/executor/internal/worker/workspace",
],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("//dev:go_defs.bzl", "go_test")
@ -28,3 +29,14 @@ go_test(
"@com_github_sourcegraph_log//logtest",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":cmdlogger"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -72,3 +73,17 @@ go_test(
"@io_k8s_utils//pointer",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [
":command",
"//cmd/executor/internal/worker/cmdlogger",
],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -26,3 +27,14 @@ go_test(
"@com_github_stretchr_testify//require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":files"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -60,3 +61,18 @@ go_test(
"@io_k8s_client_go//testing",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [
"//cmd/executor/internal/worker/cmdlogger",
"//cmd/executor/internal/worker/command",
"//cmd/executor/internal/worker/files",
],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -56,3 +57,20 @@ go_test(
"@com_github_stretchr_testify//require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [
"//cmd/executor/internal/util",
"//cmd/executor/internal/worker/cmdlogger",
"//cmd/executor/internal/worker/command",
"//cmd/executor/internal/worker/files",
"//cmd/executor/internal/worker/workspace",
],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -49,3 +50,19 @@ go_test(
"@com_github_stretchr_testify//require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [
"//cmd/executor/internal/util",
"//cmd/executor/internal/worker/cmdlogger",
"//cmd/executor/internal/worker/command",
"//cmd/executor/internal/worker/files",
],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -133,3 +134,14 @@ go_test(
"@com_github_stretchr_testify//require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_temp.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":backend"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -54,3 +55,14 @@ go_test(
"@com_github_stretchr_testify//require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":executorqueue"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -58,3 +59,14 @@ go_test(
"@in_gopkg_yaml_v2//:yaml_v2",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":batches"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -141,3 +142,14 @@ go_test(
"@org_golang_google_protobuf//testing/protocmp",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = ["//internal/httpcli"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -58,3 +59,14 @@ go_test(
"@com_github_stretchr_testify//require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":releasecache"],
)

View File

@ -1,5 +1,6 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("//dev:go_defs.bzl", "go_test")
load("//dev:go_mockgen.bzl", "go_mockgen")
go_library(
name = "internal",
@ -22,7 +23,8 @@ go_library(
],
embedsrcs = ["sg_maintenance.sh"],
importpath = "github.com/sourcegraph/sourcegraph/cmd/gitserver/internal",
visibility = ["//cmd/gitserver:__subpackages__"],
# visibility = ["//cmd/gitserver:__subpackages__"],
visibility = ["//visibility:public"],
deps = [
"//cmd/frontend/envvar",
"//cmd/gitserver/internal/accesslog",
@ -149,3 +151,14 @@ go_test(
"@org_golang_x_time//rate",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":internal"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("//dev:go_defs.bzl", "go_test")
@ -39,3 +40,14 @@ go_test(
"@com_github_stretchr_testify//require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mock.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":git"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("//dev:go_defs.bzl", "go_test")
@ -80,3 +81,14 @@ go_test(
"@org_golang_x_time//rate",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = ["//cmd/gitserver/internal"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("//dev:go_defs.bzl", "go_test")
@ -110,3 +111,14 @@ go_test(
"@org_golang_x_mod//module",
],
)
go_mockgen(
name = "generate_mocks",
out = "mock.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":vcssyncer"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -38,3 +39,14 @@ go_test(
"@com_github_google_go_cmp//cmp",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = ["//cmd/symbols/gitserver"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -70,3 +71,14 @@ go_test(
"@org_golang_x_sync//semaphore",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = ["//cmd/symbols/gitserver"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -59,3 +60,14 @@ go_test(
"@com_github_sourcegraph_log//logtest",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":telemetry"],
)

View File

@ -611,6 +611,27 @@ def go_dependencies():
sum = "h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=",
version = "v0.2.0",
)
go_repository(
name = "com_github_bazelbuild_bazel_gazelle",
build_file_proto_mode = "disable_global",
importpath = "github.com/bazelbuild/bazel-gazelle",
sum = "h1:Bvg+zEHWYwWrhJT4WxyvcU3y1DEJpT/XlPYEfIn9lUI=",
version = "v0.35.0",
)
go_repository(
name = "com_github_bazelbuild_buildtools",
build_file_proto_mode = "disable_global",
importpath = "github.com/bazelbuild/buildtools",
sum = "h1:2Gc2Q6hVR1SJ8bBI9Ybzoggp8u/ED2WkM4MfvEIn9+c=",
version = "v0.0.0-20231115204819-d4c9dccdfbb1",
)
go_repository(
name = "com_github_bazelbuild_rules_go",
build_file_proto_mode = "disable_global",
importpath = "github.com/bazelbuild/rules_go",
sum = "h1:uJStI9o5obVWSwquy9WxKNWfZxf2sKA2rpEsX6x5RVM=",
version = "v0.44.0",
)
go_repository(
name = "com_github_becheran_wildmatch_go",
build_file_proto_mode = "disable_global",
@ -674,6 +695,13 @@ def go_dependencies():
sum = "h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0=",
version = "v1.3.4",
)
go_repository(
name = "com_github_bmatcuk_doublestar_v4",
build_file_proto_mode = "disable_global",
importpath = "github.com/bmatcuk/doublestar/v4",
sum = "h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwNy7PA4I=",
version = "v4.6.1",
)
go_repository(
name = "com_github_boj_redistore",
build_file_proto_mode = "disable_global",
@ -1243,8 +1271,13 @@ def go_dependencies():
name = "com_github_derision_test_go_mockgen",
build_file_proto_mode = "disable_global",
importpath = "github.com/derision-test/go-mockgen",
sum = "h1:Wo7vx8f7QdBT4jxfgTvs2t9VpyFlvvqzjXoE3m7MQBU=",
version = "v1.3.8-0.20240105000756-fb9effb23d90",
patch_args = ["-p1"],
patches = [
"//third_party/com_github_strum355_gomockgen:debug.patch",
],
replace = "github.com/strum355/go-mockgen",
sum = "h1:OqSMnVsZVdlzf2H7ZLZ7pHs5iGrkAK2CitRUVO/GUPs=",
version = "v0.0.0-20240212213912-87f69a62e0d3",
)
go_repository(
name = "com_github_dghubble_go_twitter",
@ -7334,8 +7367,8 @@ def go_dependencies():
name = "net_starlark_go",
build_file_proto_mode = "disable_global",
importpath = "go.starlark.net",
sum = "h1:+FNtrFTmVw0YZGpBGX56XDee331t6JAXeK2bcyhLOOc=",
version = "v0.0.0-20200306205701-8dd3e2ee1dd5",
sum = "h1:xwwDQW5We85NaTk2APgoN9202w/l0DVGp+GZMfsrh7s=",
version = "v0.0.0-20210223155950-e043a3d3c984",
)
go_repository(
name = "org_bitbucket_creachadair_shell",
@ -7512,6 +7545,13 @@ def go_dependencies():
sum = "h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc=",
version = "v0.17.0",
)
go_repository(
name = "org_golang_x_tools_go_vcs",
build_file_proto_mode = "disable_global",
importpath = "golang.org/x/tools/go/vcs",
sum = "h1:cOIJqWBl99H1dH5LWizPa+0ImeeJq3t3cJjaeOWUAL4=",
version = "v0.1.0-deprecated",
)
go_repository(
name = "org_golang_x_xerrors",
build_file_proto_mode = "disable_global",

View File

@ -1,6 +1,10 @@
load("@rules_multirun//:defs.bzl", "multirun")
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
exports_files(srcs = ["eslint-report-test.sh"])
exports_files(srcs = [
"eslint-report-test.sh",
"go-mockgen.tpl",
])
write_source_files(
name = "write_all_generated",
@ -28,3 +32,85 @@ write_source_files(
"//schema:write_generated_schema",
],
)
multirun(
name = "go_mockgen",
commands = [
"//cmd/cody-gateway/internal/auth:generate_mocks",
"//cmd/cody-gateway/internal/dotcom:generate_mocks",
"//cmd/executor/internal/worker/cmdlogger:generate_mocks",
"//cmd/executor/internal/worker/command:generate_mocks",
"//cmd/executor/internal/worker/files:generate_mocks",
"//cmd/executor/internal/worker/runner:generate_mocks",
"//cmd/executor/internal/worker/runtime:generate_mocks",
"//cmd/executor/internal/worker/workspace:generate_mocks",
"//cmd/executor/internal/worker:generate_mocks",
"//cmd/frontend/backend:generate_mocks",
"//cmd/frontend/internal/executorqueue/queues/batches:generate_mocks",
"//cmd/frontend/internal/executorqueue:generate_mocks",
"//cmd/frontend/internal/httpapi/releasecache:generate_mocks",
"//cmd/frontend/internal/httpapi:generate_mocks",
"//cmd/gitserver/internal/git:generate_mocks",
"//cmd/gitserver/internal/integration_tests:generate_mocks",
"//cmd/gitserver/internal/vcssyncer:generate_mocks",
"//cmd/gitserver/internal:generate_mocks",
"//cmd/symbols/fetcher:generate_mocks",
"//cmd/symbols/internal/api:generate_mocks",
"//cmd/worker/internal/telemetry:generate_mocks",
"//dev/team:generate_mocks",
"//internal/auth/userpasswd:generate_mocks",
"//internal/authz/providers/gerrit:generate_mocks",
"//internal/authz/providers/github:generate_mocks",
"//internal/authz/subrepoperms:generate_mocks",
"//internal/authz:generate_mocks",
"//internal/batches/sources:generate_mocks",
"//internal/batches/syncer:generate_mocks",
"//internal/codeintel/autoindexing/internal/background/dependencies:generate_mocks",
"//internal/codeintel/autoindexing/internal/inference:generate_mocks",
"//internal/codeintel/autoindexing:generate_mocks",
"//internal/codeintel/codenav/transport/graphql:generate_mocks",
"//internal/codeintel/codenav:generate_mocks",
"//internal/codeintel/dependencies/internal/background:generate_mocks",
"//internal/codeintel/policies:generate_mocks",
"//internal/codeintel/ranking:generate_mocks",
"//internal/codeintel/uploads/internal/background/backfiller:generate_mocks",
"//internal/codeintel/uploads/internal/background/expirer:generate_mocks",
"//internal/codeintel/uploads/internal/background/processor:generate_mocks",
"//internal/codeintel/uploads/transport/graphql:generate_mocks",
"//internal/codeintel/uploads/transport/http/auth:generate_mocks",
"//internal/codeintel/uploads/transport/http:generate_mocks",
"//internal/codeintel/uploads:generate_mocks",
"//internal/conf:generate_mocks",
"//internal/database/basestore:generate_mocks",
"//internal/database/dbmocks:generate_mocks",
"//internal/database/migration/runner:generate_mocks",
"//internal/embeddings/background/repo:generate_mocks",
"//internal/embeddings/embed:generate_mocks",
"//internal/embeddings:generate_mocks",
"//internal/executor/store:generate_mocks",
"//internal/featureflag:generate_mocks",
"//internal/github_apps/store:generate_mocks",
"//internal/gitserver:generate_mocks",
"//internal/goroutine:generate_mocks",
"//internal/insights/background:generate_mocks",
"//internal/insights/discovery:generate_mocks",
"//internal/insights/scheduler:generate_mocks",
"//internal/insights/store:generate_mocks",
"//internal/metrics/store:generate_mocks",
"//internal/oobmigration:generate_mocks",
"//internal/redispool:generate_mocks",
"//internal/repos:generate_mocks",
"//internal/search/client:generate_mocks",
"//internal/search/job/mockjob:generate_mocks",
"//internal/search/repos:generate_mocks",
"//internal/search/symbol:generate_mocks",
"//internal/telemetry/telemetrytest:generate_mocks",
"//internal/uploadhandler:generate_mocks",
"//internal/uploadstore/mocks:generate_mocks",
"//internal/uploadstore:generate_mocks",
"//internal/workerutil/dbworker/store/mocks:generate_mocks",
"//internal/workerutil:generate_mocks",
"//lib/background:generate_mocks",
], # TODO: this list doesn't get smaller, why
jobs = 1,
)

View File

@ -0,0 +1,19 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go-mockgen-gazelle",
srcs = ["go-mockgen.go"],
importpath = "github.com/sourcegraph/sourcegraph/dev/go-mockgen-gazelle",
visibility = ["//visibility:public"],
deps = [
"//dev/go-mockgen-transformer/config",
"@bazel_gazelle//config:go_default_library",
"@bazel_gazelle//label:go_default_library",
"@bazel_gazelle//language:go_default_library",
"@bazel_gazelle//language/go:go_default_library",
"@bazel_gazelle//repo:go_default_library",
"@bazel_gazelle//resolve:go_default_library",
"@bazel_gazelle//rule:go_default_library",
"@org_golang_x_exp//maps",
],
)

View File

@ -0,0 +1,238 @@
package gomockgengazelle
import (
"log"
"path/filepath"
"slices"
"strings"
"sync"
"github.com/bazelbuild/bazel-gazelle/config"
"github.com/bazelbuild/bazel-gazelle/label"
"github.com/bazelbuild/bazel-gazelle/language"
golang "github.com/bazelbuild/bazel-gazelle/language/go"
"github.com/bazelbuild/bazel-gazelle/repo"
"github.com/bazelbuild/bazel-gazelle/resolve"
"github.com/bazelbuild/bazel-gazelle/rule"
"golang.org/x/exp/maps"
mockgenc "github.com/sourcegraph/sourcegraph/dev/go-mockgen-transformer/config"
)
type gomockgen struct {
language.BaseLang
language.BaseLifecycleManager
}
var (
_ (language.Language) = (*gomockgen)(nil)
_ (language.LifecycleManager) = (*gomockgen)(nil)
_ (language.ModuleAwareLanguage) = (*gomockgen)(nil)
)
var (
logger = log.New(log.Writer(), log.Prefix(), log.Flags())
yamlPayload mockgenc.YamlPayload
// Keep track of all output directories mentioned in go-mockgen config, so that
// we can notify if any where not visited & therefore no mocks were generated/updated
// for them. Unlike with go-mockgen, we currently don't (or can't?) create new directories
// as part of sg bazel configure, so we give the user a bash command to run to prepare the
// missing directories (+ shell Go files) before re-running sg bazel configure.
unvisitedDirs = make(map[string]bool)
allOutputDirs = make(map[string]mockgenc.YamlMock)
// Haven't discovered a way to get the workspace root dir yet (the cwd is deep in the Bazel output base somewhere),
// so to read the go-mockgen files we set this value once we start traversing the workspace root.
rootDir string
// Currently, the go_mockgen rule extracts the required go-mockgen config at build time, so their labels
// need to be passed as inputs.
manifests []string
// We want to load the mockgen.yaml (and related) config file(s) only once, so we use a sync.OnceValue.
loadConfig = sync.OnceValue[error](func() (err error) {
yamlPayload, err = mockgenc.ReadManifest(filepath.Join(rootDir, "mockgen.yaml"))
if err != nil {
return err
}
for _, mock := range yamlPayload.Mocks {
allOutputDirs[filepath.Dir(mock.Filename)] = mock
unvisitedDirs[filepath.Dir(mock.Filename)] = true
}
manifests = []string{"//:mockgen.yaml"}
for _, manifest := range yamlPayload.IncludeConfigPaths {
manifests = append(manifests, "//:"+manifest)
}
return nil
})
)
func NewLanguage() language.Language {
return &gomockgen{}
}
func (*gomockgen) Name() string { return "gomockgen" }
func (*gomockgen) Kinds() map[string]rule.KindInfo {
return map[string]rule.KindInfo{
"go_mockgen": {
MatchAny: true,
// I cant tell if these work or not...
MergeableAttrs: map[string]bool{
"deps": true,
"out": true,
"manifests": true,
},
},
"multirun": {
MatchAttrs: []string{"name"},
MergeableAttrs: map[string]bool{
"commands": true,
},
},
}
}
// From ModuleAwareLanguage.ApparentLoads:
//
// ApparentLoads returns .bzl files and symbols they define. Every rule
// generated by GenerateRules, now or in the past, should be loadable from
// one of these files.
//
// https://sourcegraph.com/github.com/bazelbuild/bazel-gazelle@ec1591cb193591b9544b52b98b8ce52833b34c58/-/blob/language/lang.go?L137:2-137:15
func (*gomockgen) ApparentLoads(moduleToApparentName func(string) string) []rule.LoadInfo {
return []rule.LoadInfo{
{
Name: "//dev:go_mockgen.bzl",
Symbols: []string{"go_mockgen"},
},
{
Name: "@rules_multirun//:defs.bzl",
Symbols: []string{"multirun"},
},
}
}
func (g *gomockgen) GenerateRules(args language.GenerateArgs) language.GenerateResult {
rootDir = args.Config.RepoRoot
if err := loadConfig(); err != nil {
log.Fatalf("failed to load go-mockgen config: %v", err)
}
// if we're in the ./dev folder, we want to generate an "all" multirun.
if args.Rel == "dev" {
var targets []string
for _, mock := range yamlPayload.Mocks {
targets = append(targets, "//"+filepath.Dir(mock.Filename)+":generate_mocks")
}
slices.Sort(targets)
targets = slices.Compact(targets)
multirunRule := rule.NewRule("multirun", "go_mockgen")
multirunRule.SetAttr("commands", targets)
multirunRule.SetAttr("jobs", 1)
return language.GenerateResult{
Gen: []*rule.Rule{multirunRule},
Imports: []interface{}{nil},
}
}
// is this a directory we care about? if not, we don't want to generate any rules.
mock, ok := allOutputDirs[args.Rel]
if !ok {
return language.GenerateResult{}
}
delete(unvisitedDirs, args.Rel)
outputFilename := filepath.Base(mock.Filename)
r := rule.NewRule("go_mockgen", "generate_mocks")
r.SetAttr("out", outputFilename)
r.SetAttr("manifests", manifests)
// we want to add the generated file to either the go_library rule or the go_test rule, depending
// on whether the file is a _test.go file or not.
goRuleIndex := slices.IndexFunc(args.OtherGen, func(r *rule.Rule) bool {
if strings.HasSuffix(outputFilename, "_test.go") {
return r.Kind() == "go_test"
} else {
return r.Kind() == "go_library"
}
})
if goRuleIndex == -1 {
// We can revisit this output if it's something we hit in practice.
log.Fatalf("couldn't find a go_{library,test} rule in \"%s/BUILD.bazel\"", args.Rel)
}
goRule := args.OtherGen[goRuleIndex]
goRule.SetAttr("srcs", append(goRule.AttrStrings("srcs"), filepath.Base(mock.Filename)))
imports := gatherDependencies(mock)
return language.GenerateResult{
Gen: []*rule.Rule{r, goRule},
// Gen and Imports correspond per-index aka 'r' above is associated with 'imports' below.
// This value gets passed as 'rawImports' in 'Resolve' below.
Imports: []interface{}{imports, nil},
}
}
func (g *gomockgen) DoneGeneratingRules() {
if len(unvisitedDirs) > 0 {
var b strings.Builder
for _, dir := range maps.Keys(unvisitedDirs) {
b.WriteString("mkdir -p ")
b.WriteString(dir)
b.WriteString(" && ")
b.WriteString("echo 'package ")
if allOutputDirs[dir].Package != "" {
b.WriteString(allOutputDirs[dir].Package)
} else {
b.WriteString(filepath.Base(dir))
}
b.WriteString("' > ")
b.WriteString(allOutputDirs[dir].Filename)
b.WriteString(" \\\n && ")
}
b.WriteString("echo 'Done preparing! Re-running `sg bazel configure`' && sg bazel configure")
logger.Fatalf("Some declared go-mockgen output files were not created due to their output directory missing. Please run the following to resolve this:\n%s", b.String())
}
}
// Here we translate the Go import paths into Bazel labels for the go_mockgen rules.
func (g *gomockgen) Resolve(c *config.Config, ix *resolve.RuleIndex, rc *repo.RemoteCache, r *rule.Rule, rawImports interface{}, from label.Label) {
if r.Kind() != "go_mockgen" {
return
}
imports := rawImports.([]string)
r.DelAttr("deps")
labels := make([]string, 0, len(imports))
for _, i := range imports {
result, err := golang.ResolveGo(c, ix, rc, i, from)
if err != nil {
log.Fatalf("failed to resolve Go import path (%s) to Bazel label: %v", i, err)
}
labels = append(labels, result.Rel(from.Repo, from.Pkg).String())
}
r.SetAttr("deps", labels)
}
func gatherDependencies(mock mockgenc.YamlMock) (deps []string) {
if mock.Path != "" {
deps = append(deps, mock.Path)
}
for _, source := range mock.Sources {
deps = append(deps, source.Path)
}
return
}

View File

@ -0,0 +1,18 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_library(
name = "go-mockgen-transformer_lib",
srcs = ["main.go"],
importpath = "github.com/sourcegraph/sourcegraph/dev/go-mockgen-transformer",
visibility = ["//visibility:private"],
deps = [
"//dev/go-mockgen-transformer/config",
"@in_gopkg_yaml_v3//:yaml_v3",
],
)
go_binary(
name = "go-mockgen-transformer",
embed = [":go-mockgen-transformer_lib"],
visibility = ["//visibility:public"],
)

View File

@ -0,0 +1,9 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "config",
srcs = ["load.go"],
importpath = "github.com/sourcegraph/sourcegraph/dev/go-mockgen-transformer/config",
visibility = ["//visibility:public"],
deps = ["@in_gopkg_yaml_v3//:yaml_v3"],
)

View File

@ -0,0 +1,97 @@
package config
//
// TODO: expose this directly in go-mockgen
//
import (
"os"
"path/filepath"
"gopkg.in/yaml.v3"
)
type YamlPayload struct {
// Meta options
IncludeConfigPaths []string `yaml:"include-config-paths,omitempty"`
// Global options
Exclude []string `yaml:"exclude,omitempty"`
Prefix string `yaml:"prefix,omitempty"`
ConstructorPrefix string `yaml:"constructor-prefix,omitempty"`
Force bool `yaml:"force,omitempty"`
DisableFormatting bool `yaml:"disable-formatting,omitempty"`
Goimports string `yaml:"goimports,omitempty"`
ForTest bool `yaml:"for-test,omitempty"`
FilePrefix string `yaml:"file-prefix,omitempty"`
StdlibRoot string `yaml:"stdlib-root,omitempty"`
Mocks []YamlMock `yaml:"mocks,omitempty"`
}
type YamlMock struct {
Path string `yaml:"path,omitempty"`
Paths []string `yaml:"paths,omitempty"`
Sources []YamlSource `yaml:"sources,omitempty"`
SourceFiles []string `yaml:"source-files,omitempty"`
Archives []string `yaml:"archives,omitempty"`
Package string `yaml:"package,omitempty"`
Interfaces []string `yaml:"interfaces,omitempty"`
Exclude []string `yaml:"exclude,omitempty"`
Dirname string `yaml:"dirname,omitempty"`
Filename string `yaml:"filename,omitempty"`
ImportPath string `yaml:"import-path,omitempty"`
Prefix string `yaml:"prefix,omitempty"`
ConstructorPrefix string `yaml:"constructor-prefix,omitempty"`
Force bool `yaml:"force,omitempty"`
DisableFormatting bool `yaml:"disable-formatting,omitempty"`
Goimports string `yaml:"goimports,omitempty"`
ForTest bool `yaml:"for-test,omitempty"`
FilePrefix string `yaml:"file-prefix,omitempty"`
}
type YamlSource struct {
Path string `yaml:"path,omitempty"`
Paths []string `yaml:"paths,omitempty"`
Interfaces []string `yaml:"interfaces,omitempty"`
Exclude []string `yaml:"exclude,omitempty"`
Prefix string `yaml:"prefix,omitempty"`
SourceFiles []string `yaml:"source-files,omitempty"`
}
func ReadManifest(configPath string) (YamlPayload, error) {
contents, err := os.ReadFile(configPath)
if err != nil {
return YamlPayload{}, err
}
var payload YamlPayload
if err := yaml.Unmarshal(contents, &payload); err != nil {
return YamlPayload{}, err
}
for _, path := range payload.IncludeConfigPaths {
payload, err = readIncludeConfig(payload, filepath.Join(filepath.Dir(configPath), path))
if err != nil {
return YamlPayload{}, err
}
}
return payload, nil
}
func readIncludeConfig(payload YamlPayload, path string) (YamlPayload, error) {
contents, err := os.ReadFile(path)
if err != nil {
return YamlPayload{}, err
}
var mocks []YamlMock
if err := yaml.Unmarshal(contents, &mocks); err != nil {
return YamlPayload{}, err
}
payload.Mocks = append(payload.Mocks, mocks...)
return payload, nil
}

View File

@ -0,0 +1,103 @@
package main
import (
"flag"
"fmt"
"os"
"strings"
"gopkg.in/yaml.v3"
"github.com/sourcegraph/sourcegraph/dev/go-mockgen-transformer/config"
)
type sliceFlag []string
func (i *sliceFlag) String() string {
return strings.Join(*i, ",")
}
func (i *sliceFlag) Set(value string) error {
*i = append(*i, value)
return nil
}
func main() {
payload, err := config.ReadManifest("mockgen.yaml")
if err != nil {
panic(err)
}
var sourceFiles sliceFlag
var archives sliceFlag
outfile := flag.String("outfile", "mockgen.yaml", "File to write the transformed config to")
intermediaryGeneratedFile := flag.String("intermediary-generated-file", "", "Path to the intermediary generated file (before being copied to source tree)")
finalGeneratedFile := flag.String("final-generated-file", "", "Path to the final generated file (in the source tree)")
outputImportPath := flag.String("output-importpath", "", "The import path of the generated mock file")
flag.StringVar(&payload.Goimports, "goimports", "./bin/.goimports", "Path to goimports binary")
flag.StringVar(&payload.StdlibRoot, "stdlibroot", "", "Path to the root of the Go compiled stdlib")
flag.Var(&sourceFiles, "source-files", "Values of the format IMPORTPATH=FILE, where IMPORTPATH is the import path for FILE")
flag.Var(&archives, "archives", "Values of the format IMPORTPATH=ARCHIVE, where ARCHIVE is the path to the archive for the given IMPORTPATH")
flag.Parse()
payload.IncludeConfigPaths = []string{}
f, err := os.Create(*outfile)
if err != nil {
panic(err)
}
defer f.Close()
// source files need to be grouped by their import path, so that when we process each (import path, source files)
// tuple in go-mockgen, the packages declared at the top of the source files are all equal part import path grouping.
importpathToSources := make(map[string][]string)
for _, arg := range sourceFiles {
split := strings.Split(arg, "=")
importpathToSources[split[0]] = append(importpathToSources[split[0]], split[1])
}
outputPayload := payload
outputPayload.Mocks = []config.YamlMock{}
// extract the mock configuration for the specific file we want to generate mocks for.
for _, mock := range payload.Mocks {
if mock.Filename == *finalGeneratedFile {
// the config declares the filepath for the _final_ generated file,
// but we prefix the filename with _ so we can copy from the output base
// into the source tree.
mock.Filename = *intermediaryGeneratedFile
outputPayload.Mocks = []config.YamlMock{mock}
break
}
}
if len(outputPayload.Mocks) == 0 {
panic(fmt.Sprintf("Could not find mock for file %s", *finalGeneratedFile))
}
// TODO: why does this need to be set explicitly again?
outputPayload.Mocks[0].ImportPath = *outputImportPath
// now we have the right config section, we want to attach the right sources for each
// import path that we're mocking interfaces from. For each dep in the go_mockgen rule,
// there should be a corresponding section in the config extract.
// Archive files are set globally, they don't need grouping.
if len(outputPayload.Mocks[0].Sources) > 0 {
newSources := outputPayload.Mocks[0].Sources[:0]
for _, source := range outputPayload.Mocks[0].Sources {
source.SourceFiles = importpathToSources[source.Path]
outputPayload.Mocks[0].Archives = archives
newSources = append(newSources, source)
}
} else {
outputPayload.Mocks[0].Archives = archives
outputPayload.Mocks[0].SourceFiles = importpathToSources[outputPayload.Mocks[0].Path]
}
out, err := yaml.Marshal(outputPayload)
if err != nil {
panic(err)
}
if _, err := f.Write(out); err != nil {
panic(err)
}
}

18
dev/go_mockgen.bzl Normal file
View File

@ -0,0 +1,18 @@
load("//dev:go_mockgen_rule.bzl", "go_mockgen_generate")
load("//dev:write_generated_to_source_files.bzl", "write_generated_to_source_files")
def go_mockgen(name, manifests, deps, out):
gen_file = "_" + out
go_mockgen_generate(
name = name + "_generate",
deps = deps,
out = gen_file,
manifests = manifests,
)
write_generated_to_source_files(
name = name,
output_files = {out: gen_file},
target = ":" + name + "_generate",
)

118
dev/go_mockgen_rule.bzl Normal file
View File

@ -0,0 +1,118 @@
load("@io_bazel_rules_go//go:def.bzl", "GoArchive", "GoSource")
def _go_mockgen_run(ctx):
dst = ctx.actions.declare_file(ctx.attr.out)
config_dst = ctx.actions.declare_file("mockgen.yaml")
stdlib_root = "{path}/{os}_{arch}".format(
path = ctx.attr._go_stdlib[GoSource].stdlib.libs[0].path,
os = ctx.attr._go_stdlib[GoSource].mode.goos,
arch = ctx.attr._go_stdlib[GoSource].mode.goarch,
)
transformer_args = [
"--outfile",
config_dst.path,
"--final-generated-file",
ctx.label.package + "/" + ctx.attr.out[1:],
"--intermediary-generated-file",
dst.path,
"--stdlibroot",
stdlib_root,
"--goimports",
ctx.executable._goimports.path,
"--output-importpath",
"github.com/sourcegraph/sourcegraph/" + ctx.label.package,
]
deps = []
for dep in ctx.attr.deps:
for a in dep[GoArchive].direct:
transformer_args.append("--archives=%s=%s" % (
a.data.importmap,
# (anecdotaly) export_file is a .x file and file is a .a file. See here for more info on this
# https://github.com/bazelbuild/rules_go/issues/1803
# and here for further reading on the compiler side of things
# https://groups.google.com/g/golang-codereviews/c/UXJeeuTS7oQ
a.data.export_file.path if a.data.export_file else a.data.file.path,
))
deps.append(depset(direct = [a.data.export_file if a.data.export_file else a.data.file]))
for dep in ctx.attr.deps:
for src in dep[GoArchive].data.srcs:
transformer_args.append("--source-files=%s=%s" % (dep[GoArchive].data.importpath, src.path))
deps.append(depset(direct = [src]))
manifests = []
for f in ctx.attr.manifests:
manifests.extend(f.files.to_list())
ctx.actions.run(
mnemonic = "GoMockgenConfigTransform",
executable = ctx.executable._gomockgen_transformer,
arguments = transformer_args,
outputs = [config_dst],
tools = [ctx.executable._goimports],
inputs = depset(direct = manifests),
progress_message = "Transforming go-mockgen config for %s" % str(ctx.label), # TODO: figure out what we wanna put here
)
action_direct_deps = [config_dst, ctx.attr._go_stdlib[GoSource].stdlib.libs[0]]
for dep in ctx.attr.deps:
action_direct_deps.append(dep[GoArchive].data.file)
ctx.actions.run(
mnemonic = "GoMockgen",
arguments = ["--manifest-dir", config_dst.dirname],
executable = ctx.executable._gomockgen,
outputs = [dst],
tools = [ctx.executable._goimports],
inputs = depset(
direct = action_direct_deps,
transitive = deps,
),
progress_message = "Running go-mockgen to generate %s" % dst.short_path,
)
return [
DefaultInfo(
files = depset([dst]),
),
]
go_mockgen_generate = rule(
implementation = _go_mockgen_run,
attrs = {
"deps": attr.label_list(
providers = [GoArchive],
allow_empty = False,
mandatory = True,
),
"out": attr.string(
mandatory = True,
),
"manifests": attr.label_list(
allow_files = True,
mandatory = False,
),
"_gomockgen_transformer": attr.label(
default = Label("//dev/go-mockgen-transformer:go-mockgen-transformer"),
executable = True,
cfg = "exec",
),
"_gomockgen": attr.label(
default = Label("@com_github_derision_test_go_mockgen//cmd/go-mockgen:go-mockgen"),
executable = True,
cfg = "exec",
),
"_goimports": attr.label(
default = Label("@org_golang_x_tools//cmd/goimports:goimports"),
executable = True,
cfg = "exec",
),
"_go_stdlib": attr.label(
providers = [GoSource],
default = Label("@io_bazel_rules_go//:stdlib"),
),
},
)

View File

@ -2,7 +2,6 @@ package linters
import (
"context"
"os"
"strings"
"github.com/sourcegraph/run"
@ -33,12 +32,7 @@ var goGenerateLinter = &linter{
if err != nil && strings.TrimSpace(diffOutput) != "" {
out.WriteWarningf("Uncommitted changes found after running go generate:")
out.Write(strings.TrimSpace(diffOutput))
// Reset repo state
if os.Getenv("CI") == "true" {
root.Run(run.Bash(ctx, "git add . && git reset HEAD --hard")).Wait()
} else {
out.WriteWarningf("Generated changes are left in the tree, skipping reseting state because not in CI")
}
out.WriteWarningf("Generated changes are left in the tree")
}
return err

View File

@ -39,7 +39,7 @@ var Targets = []Target{
Name: "go",
Description: "Check go code for linting errors, forbidden imports, generated files, etc",
Checks: []*linter{
timeCheck(goGenerateLinter),
onlyLocal(goGenerateLinter),
onlyLocal(goDBConnImport),
onlyLocal(noLocalHost),
timeCheck(lintGoDirectives()),

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
@ -16,3 +17,14 @@ go_library(
"@org_golang_x_net//context/ctxhttp",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_temp.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":team"],
)

View File

@ -1,8 +1,16 @@
load("@aspect_bazel_lib//lib:directory_path.bzl", "make_directory_path")
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")
load("@aspect_bazel_lib//lib:directory_path.bzl", "make_directory_path")
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
def write_generated_to_source_files(name, target, output_files, verbose_copy = False, **kwargs):
def write_generated_to_source_files(name, target, output_files, **kwargs):
"""Function description.
Args:
name: Name of the rule.
target: The target that generates files to copy.
output_files: A map of {dest: source} for files to copy.
**kwargs: Additional keyword arguments.
"""
for dest, orig in output_files.items():
if dest == orig:
fail("{} and {} must differ so we can detect source files needing to be regenerated".format(dest, orig))

2
gen.go
View File

@ -1,5 +1,5 @@
package sourcegraph
// Keep these versions in sync with go.mod
//go:generate env GOBIN=$PWD/.bin GO111MODULE=on go install golang.org/x/tools/cmd/goimports@v0.1.10
//go:generate env GOBIN=$PWD/.bin GO111MODULE=on go install golang.org/x/tools/cmd/goimports@v0.17.0
//go:generate go run github.com/derision-test/go-mockgen/cmd/go-mockgen@v1.3.8-0.20240105000756-fb9effb23d90

9
go.mod
View File

@ -1,6 +1,6 @@
module github.com/sourcegraph/sourcegraph
go 1.21
go 1.21.4
// Permanent replace directives
// ============================
@ -31,6 +31,8 @@ replace (
// These entries indicate temporary replace directives due to a pending pull request upstream
// or issues with specific versions.
replace (
// Pending: https://github.com/derision-test/go-mockgen/pull/50
github.com/derision-test/go-mockgen => github.com/strum355/go-mockgen v0.0.0-20240212213912-87f69a62e0d3
// Pending: https://github.com/ghodss/yaml/pull/65
github.com/ghodss/yaml => github.com/sourcegraph/yaml v1.0.1-0.20200714132230-56936252f152
// Dependency declares incorrect, old version of redigo, so we must override it: https://github.com/boj/redistore/blob/master/go.mod
@ -227,8 +229,6 @@ require (
golang.org/x/sync v0.6.0
golang.org/x/sys v0.16.0
golang.org/x/time v0.5.0
// golang.org/x/tools should not be upgraded until https://github.com/bazelbuild/bazel-gazelle/issues/1579
// is resolved.
golang.org/x/tools v0.17.0
gonum.org/v1/gonum v0.13.0
google.golang.org/api v0.156.0
@ -253,6 +253,7 @@ require (
github.com/TwiN/go-away v1.6.13
github.com/aws/constructs-go/constructs/v10 v10.2.69
github.com/aws/jsii-runtime-go v1.84.0
github.com/bazelbuild/bazel-gazelle v0.35.0
github.com/dghubble/gologin/v2 v2.4.0
github.com/edsrzf/mmap-go v1.1.0
github.com/go-json-experiment/json v0.0.0-20231102232822-2e55bd4e08b0
@ -314,6 +315,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.25 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.5 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/bazelbuild/buildtools v0.0.0-20231115204819-d4c9dccdfbb1 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/cockroachdb/apd/v2 v2.0.1 // indirect
@ -393,6 +395,7 @@ require (
go.opentelemetry.io/collector/featuregate v1.0.1 // indirect
go.uber.org/goleak v1.3.0 // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/tools/go/vcs v0.1.0-deprecated // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe // indirect
gotest.tools/v3 v3.5.1 // indirect
)

15
go.sum
View File

@ -291,6 +291,12 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
github.com/bazelbuild/bazel-gazelle v0.35.0 h1:Bvg+zEHWYwWrhJT4WxyvcU3y1DEJpT/XlPYEfIn9lUI=
github.com/bazelbuild/bazel-gazelle v0.35.0/go.mod h1:o2+s90f3w3U6jjw0gcdok0EJOfNK0AK/9RyVP7QkRDk=
github.com/bazelbuild/buildtools v0.0.0-20231115204819-d4c9dccdfbb1 h1:2Gc2Q6hVR1SJ8bBI9Ybzoggp8u/ED2WkM4MfvEIn9+c=
github.com/bazelbuild/buildtools v0.0.0-20231115204819-d4c9dccdfbb1/go.mod h1:689QdV3hBP7Vo9dJMmzhoYIyo/9iMhEmHkJcnaPRCbo=
github.com/bazelbuild/rules_go v0.44.0 h1:uJStI9o5obVWSwquy9WxKNWfZxf2sKA2rpEsX6x5RVM=
github.com/bazelbuild/rules_go v0.44.0/go.mod h1:z7Y8GZ90V4mwgYizbNbEQKmOmx93Q3Btcel4vX7pXoc=
github.com/becheran/wildmatch-go v1.0.0 h1:mE3dGGkTmpKtT4Z+88t8RStG40yN9T+kFEGj2PZFSzA=
github.com/becheran/wildmatch-go v1.0.0/go.mod h1:gbMvj0NtVdJ15Mg/mH9uxk2R1QCistMyU7d9KFzroX4=
github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A=
@ -311,6 +317,8 @@ github.com/bits-and-blooms/bitset v1.8.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a
github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM=
github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0=
github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE=
github.com/bmatcuk/doublestar/v4 v4.6.1 h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwNy7PA4I=
github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff h1:RmdPFa+slIr4SCBg4st/l/vZWVe9QJKMXGO60Bxbe04=
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff/go.mod h1:+RTT1BOk5P97fT2CiHkbFQwkK3mjsFAP6zCYV2aXtjw=
github.com/bradfitz/gomemcache v0.0.0-20170208213004-1952afaa557d/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60=
@ -423,8 +431,6 @@ github.com/dennwc/varint v1.0.0/go.mod h1:hnItb35rvZvJrbTALZtY/iQfDs48JKRG1RPpgz
github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0=
github.com/derision-test/glock v1.0.0 h1:b6sViZG+Cm6QtdpqbfWEjaBVbzNPntIS4GzsxpS+CmM=
github.com/derision-test/glock v1.0.0/go.mod h1:jKtLdBMrF+XQatqvg46wiWdDfDSSDjdhO4dOM2FX9H4=
github.com/derision-test/go-mockgen v1.3.8-0.20240105000756-fb9effb23d90 h1:Wo7vx8f7QdBT4jxfgTvs2t9VpyFlvvqzjXoE3m7MQBU=
github.com/derision-test/go-mockgen v1.3.8-0.20240105000756-fb9effb23d90/go.mod h1:/TXUePlhtHmDDCaDAi/a4g6xOHqMDz3Wf0r2NPGskB4=
github.com/dghubble/gologin/v2 v2.4.0 h1:Ga0dxZ2C/8MrMtC0qFLIg1K7cVjZQWSbTj/MIgFqMAg=
github.com/dghubble/gologin/v2 v2.4.0/go.mod h1:85FO9Je/O6n9/KdHTUtVDSaXQjR6Ducx7blL/3CUfnw=
github.com/dghubble/sling v1.4.1 h1:AxjTubpVyozMvbBCtXcsWEyGGgUZutC5YGrfxPNVOcQ=
@ -1710,6 +1716,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/strum355/go-mockgen v0.0.0-20240212213912-87f69a62e0d3 h1:OqSMnVsZVdlzf2H7ZLZ7pHs5iGrkAK2CitRUVO/GUPs=
github.com/strum355/go-mockgen v0.0.0-20240212213912-87f69a62e0d3/go.mod h1:89jHE4KrusV6kCx9JPn5nkD7kfGD+4gtvp+ApO0lc/E=
github.com/stvp/tempredis v0.0.0-20181119212430-b82af8480203 h1:QVqDTf3h2WHt08YuiTGPZLls0Wq99X9bWd0Q5ZSBesM=
github.com/stvp/tempredis v0.0.0-20181119212430-b82af8480203/go.mod h1:oqN97ltKNihBbwlX8dLpwxCl3+HnXKV/R0e+sRLd9C8=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
@ -1940,6 +1948,7 @@ go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqe
go.opentelemetry.io/proto/otlp v1.1.0 h1:2Di21piLrCqJ3U3eXGCTPHE9R8Nh+0uglSnOyxikMeI=
go.opentelemetry.io/proto/otlp v1.1.0/go.mod h1:GpBHCBWiqvVLDqmHZsoMM3C5ySeKTC7ej/RNTae6MdY=
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5/go.mod h1:nmDLcffg48OtT/PSW0Hg7FvpRQsQh5OSqIylirxKC7o=
go.starlark.net v0.0.0-20210223155950-e043a3d3c984/go.mod h1:t3mmBBPzAVvK0L0n1drDmrQsJ8FoIx4INCqVMTr/Zo0=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
@ -2358,6 +2367,8 @@ golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc=
golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps=
golang.org/x/tools/go/vcs v0.1.0-deprecated h1:cOIJqWBl99H1dH5LWizPa+0ImeeJq3t3cJjaeOWUAL4=
golang.org/x/tools/go/vcs v0.1.0-deprecated/go.mod h1:zUrvATBAvEI9535oC0yWYsLsHIV4Z7g63sNPVMtuBy8=
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -95,3 +96,14 @@ go_test(
"@com_github_stretchr_testify//require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":userpasswd"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -52,3 +53,14 @@ go_test(
"@com_github_stretchr_testify//require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_temp.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":authz"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -39,3 +40,14 @@ go_test(
"@com_github_google_go_cmp//cmp",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = ["//internal/extsvc/gerrit"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -61,3 +62,14 @@ go_test(
"@com_github_stretchr_testify//require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":github"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -38,3 +39,14 @@ go_test(
"@com_github_stretchr_testify//require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_temp.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":subrepoperms"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -126,3 +127,20 @@ go_test(
"@com_github_stretchr_testify//require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [
":sources",
"//internal/extsvc/azuredevops",
"//internal/extsvc/bitbucketcloud",
"//internal/extsvc/gerrit",
"//internal/gitserver",
],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -61,3 +62,14 @@ go_test(
"@com_github_stretchr_testify//assert",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":syncer"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -64,3 +65,17 @@ go_test(
"@com_github_google_go_cmp//cmp",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [
":autoindexing",
"//internal/codeintel/autoindexing/internal/store",
],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -85,3 +86,19 @@ go_test(
"@com_github_stretchr_testify//require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [
":dependencies",
"//internal/codeintel/autoindexing/internal/store",
"//internal/codeintel/uploads/shared",
"//internal/workerutil/dbworker/store",
],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -79,3 +80,14 @@ go_test(
"@org_golang_x_time//rate",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":inference"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -77,3 +78,17 @@ go_test(
"@com_github_sourcegraph_scip//bindings/go/scip",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [
":codenav",
"//internal/codeintel/codenav/internal/lsifstore",
],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -67,3 +68,14 @@ go_test(
"@com_github_derision_test_go_mockgen//testutil/require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":graphql"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -49,3 +50,14 @@ go_test(
"@com_github_sourcegraph_log//logtest",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":background"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -61,3 +62,17 @@ go_test(
"@com_github_google_go_cmp//cmp",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [
":policies",
"//internal/codeintel/policies/internal/store",
],
)

View File

@ -1,5 +1,6 @@
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("//dev:go_mockgen.bzl", "go_mockgen")
go_library(
name = "ranking",
@ -54,3 +55,17 @@ go_test(
"//schema",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [
"//internal/codeintel/ranking/internal/store",
"//internal/conf/conftypes",
],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -63,3 +64,19 @@ go_test(
"@com_github_keegancsmith_sqlf//:sqlf",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [
":uploads",
"//internal/codeintel/uploads/internal/lsifstore",
"//internal/codeintel/uploads/internal/store",
"//internal/workerutil/dbworker/store",
],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -41,3 +42,14 @@ go_test(
"@com_github_google_go_cmp//cmp",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = ["//internal/codeintel/uploads/internal/store"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -60,3 +61,19 @@ go_test(
"@com_github_sourcegraph_scip//bindings/go/scip",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [
":expirer",
"//internal/codeintel/uploads/internal/lsifstore",
"//internal/codeintel/uploads/internal/store",
"//internal/workerutil/dbworker/store",
],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -79,3 +80,19 @@ go_test(
"@org_golang_google_protobuf//proto",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [
":processor",
"//internal/codeintel/uploads/internal/lsifstore",
"//internal/codeintel/uploads/internal/store",
"//internal/workerutil/dbworker/store",
],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -55,3 +56,14 @@ go_test(
embed = [":graphql"],
deps = ["//internal/codeintel/uploads/shared"],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":graphql"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -65,3 +66,14 @@ go_test(
"@com_github_sourcegraph_log//logtest",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = ["//internal/uploadhandler"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -45,3 +46,14 @@ go_test(
"@com_github_tomnomnom_linkheader//:linkheader",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":auth"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -79,3 +80,14 @@ go_test(
"@com_github_stretchr_testify//require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":conf"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -50,3 +51,14 @@ go_test(
"@org_golang_x_sync//errgroup",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":basestore"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
@ -28,3 +29,14 @@ go_library(
"@com_github_sourcegraph_zoekt//:zoekt",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_temp.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = ["//internal/database"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -47,3 +48,14 @@ go_test(
"@com_github_sourcegraph_log//logtest",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":runner"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -89,3 +90,14 @@ go_test(
"@com_github_stretchr_testify//require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_temp.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":embeddings"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -50,3 +51,14 @@ go_test(
"@com_github_stretchr_testify//require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_temp.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":repo"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -55,3 +56,14 @@ go_test(
"@com_github_stretchr_testify//require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":embed"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -43,3 +44,14 @@ go_test(
"@com_github_stretchr_testify//require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_temp.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":store"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -40,3 +41,14 @@ go_test(
"@com_github_stretchr_testify//require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":featureflag"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -48,3 +49,14 @@ go_test(
"@com_github_stretchr_testify//require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_temp.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":store"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -92,3 +93,14 @@ go_test(
"@org_golang_google_protobuf//types/known/timestamppb",
],
)
go_mockgen(
name = "generate_mocks",
out = "mock.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = ["//internal/gitserver/v1:gitserver"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -38,3 +39,14 @@ go_test(
"@com_github_derision_test_glock//:glock",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":goroutine"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -80,3 +81,14 @@ go_test(
"@com_github_sourcegraph_log//logtest",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":background"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -55,3 +56,14 @@ go_test(
"@com_github_stretchr_testify//require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_temp.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":discovery"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -84,3 +85,14 @@ go_test(
"@com_github_stretchr_testify//require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":scheduler"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -68,3 +69,14 @@ go_test(
"@io_k8s_apimachinery//pkg/util/rand",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_temp.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":store"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
@ -17,3 +18,14 @@ go_library(
"@com_github_prometheus_common//expfmt",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_temp.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":store"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -73,3 +74,14 @@ go_test(
"@com_github_sourcegraph_log//logtest",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":oobmigration"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -42,3 +43,14 @@ go_test(
"@com_github_stretchr_testify//assert",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":redispool"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -199,3 +200,14 @@ go_test(
"@org_golang_x_time//rate",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_temp.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":repos"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -53,3 +54,14 @@ go_test(
"@com_github_stretchr_testify//require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_temp.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":client"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
@ -12,3 +13,14 @@ go_library(
"@io_opentelemetry_go_otel//attribute",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_temp.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = ["//internal/search/job"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -82,3 +83,14 @@ go_test(
"@com_github_stretchr_testify//require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = ["@com_github_sourcegraph_zoekt//:zoekt"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -46,3 +47,14 @@ go_test(
"@com_github_stretchr_testify//assert",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = ["@com_github_sourcegraph_zoekt//:zoekt"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -28,3 +29,14 @@ go_test(
"@com_github_stretchr_testify//require",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = ["//internal/telemetry"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -44,3 +45,14 @@ go_test(
"@com_github_sourcegraph_log//logtest",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":uploadhandler"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -64,3 +65,14 @@ go_test(
"@org_golang_google_api//iterator",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":uploadstore"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
@ -10,3 +11,14 @@ go_library(
"//lib/iterator",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_temp.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = ["//internal/uploadstore"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("//dev:go_defs.bzl", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
@ -47,3 +48,14 @@ go_test(
"@com_github_sourcegraph_log//logtest",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":workerutil"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
@ -13,3 +14,14 @@ go_library(
"@com_github_keegancsmith_sqlf//:sqlf",
],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_temp.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = ["//internal/workerutil/dbworker/store"],
)

View File

@ -1,3 +1,4 @@
load("//dev:go_mockgen.bzl", "go_mockgen")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("//dev:go_defs.bzl", "go_test")
@ -21,3 +22,14 @@ go_test(
embed = [":background"],
deps = ["@com_github_stretchr_testify//assert"],
)
go_mockgen(
name = "generate_mocks",
out = "mocks_test.go",
manifests = [
"//:mockgen.yaml",
"//:mockgen.test.yaml",
"//:mockgen.temp.yaml",
],
deps = [":background"],
)

View File

@ -228,7 +228,7 @@
- path: github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/internal/store
interfaces:
- Store
- path: internal/codeintel/uploads
- path: github.com/sourcegraph/sourcegraph/internal/codeintel/uploads
interfaces:
- RepoStore
- path: github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/internal/lsifstore

View File

@ -20,6 +20,8 @@ include-config-paths:
- mockgen.test.yaml
- mockgen.temp.yaml
# some of these values are ignored by bazel (such as force and goimports) as theyre not
# transferable or dont make sense
force: true
goimports: ./.bin/goimports
file-prefix: |

View File

@ -0,0 +1 @@
exports_files(glob(["*"]))

View File