Skip to content

Commit f3812db

Browse files
authored
build src-cli w/ bazel (#979)
1 parent 165b945 commit f3812db

File tree

33 files changed

+4225
-0
lines changed

33 files changed

+4225
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ release
77
.env
88
.envrc
99
src-snapshot/
10+
bazel-bin
11+
bazel-out
12+
bazel-testlogs
13+
bazel-zoekt
14+
bazel-src-cli

BUILD.bazel

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# gazelle:prefix github.com/sourcegraph/src-cli
2+
# gazelle:build_file_name BUILD.bazel
3+
load("@bazel_gazelle//:def.bzl", "gazelle")
4+
5+
gazelle(name = "gazelle")
6+
7+
gazelle(
8+
name = "gazelle-update-repos",
9+
args = [
10+
"-from_file=go.mod",
11+
"-to_macro=deps.bzl%go_dependencies",
12+
"-prune",
13+
"-build_file_proto_mode=disable_global",
14+
],
15+
command = "update-repos",
16+
)

WORKSPACE

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
2+
3+
http_archive(
4+
name = "bazel_skylib",
5+
sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
6+
urls = [
7+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
8+
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
9+
],
10+
)
11+
12+
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
13+
14+
bazel_skylib_workspace()
15+
16+
http_archive(
17+
name = "aspect_bazel_lib",
18+
sha256 = "2518c757715d4f5fc7cc7e0a68742dd1155eaafc78fb9196b8a18e13a738cea2",
19+
strip_prefix = "bazel-lib-1.28.0",
20+
url = "https://github.com/aspect-build/bazel-lib/releases/download/v1.28.0/bazel-lib-v1.28.0.tar.gz",
21+
)
22+
23+
http_archive(
24+
name = "io_bazel_rules_go",
25+
sha256 = "dd926a88a564a9246713a9c00b35315f54cbd46b31a26d5d8fb264c07045f05d",
26+
urls = [
27+
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.38.1/rules_go-v0.38.1.zip",
28+
"https://github.com/bazelbuild/rules_go/releases/download/v0.38.1/rules_go-v0.38.1.zip",
29+
],
30+
)
31+
32+
http_archive(
33+
name = "bazel_gazelle",
34+
sha256 = "ecba0f04f96b4960a5b250c8e8eeec42281035970aa8852dda73098274d14a1d",
35+
urls = [
36+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz",
37+
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz",
38+
],
39+
)
40+
41+
# Go toolchain setup
42+
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
43+
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies","go_repository")
44+
load("//:deps.bzl", "go_dependencies")
45+
46+
# gazelle:repository_macro deps.bzl%go_dependencies
47+
go_dependencies()
48+
49+
go_rules_dependencies()
50+
51+
go_register_toolchains(
52+
version = "1.19.6",
53+
)
54+
55+
gazelle_dependencies()
56+
57+
go_repository(
58+
name = "com_github_aws_aws_sdk_go_v2_service_eks",
59+
importpath = "github.com/aws/aws-sdk-go-v2/service/eks",
60+
version = "v1.27.3",
61+
sum = "h1:jlh0AJVhauqSGaiwRJx4j0LNBGEAaGn46sA1XJyTj0E=",
62+
)

cmd/src/BUILD.bazel

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
2+
3+
go_library(
4+
name = "src_lib",
5+
srcs = [
6+
"admin.go",
7+
"admin_create.go",
8+
"api.go",
9+
"batch.go",
10+
"batch_apply.go",
11+
"batch_common.go",
12+
"batch_exec.go",
13+
"batch_new.go",
14+
"batch_preview.go",
15+
"batch_remote.go",
16+
"batch_repositories.go",
17+
"batch_validate.go",
18+
"cmd.go",
19+
"code_intel.go",
20+
"code_intel_upload.go",
21+
"code_intel_upload_flags.go",
22+
"codeowners.go",
23+
"codeowners_create.go",
24+
"codeowners_delete.go",
25+
"codeowners_get.go",
26+
"codeowners_update.go",
27+
"colors.go",
28+
"config.go",
29+
"config_edit.go",
30+
"config_get.go",
31+
"config_list.go",
32+
"debug.go",
33+
"debug_common.go",
34+
"debug_compose.go",
35+
"debug_kube.go",
36+
"debug_server.go",
37+
"doc.go",
38+
"extensions.go",
39+
"extensions_copy.go",
40+
"extensions_delete.go",
41+
"extensions_get.go",
42+
"extensions_list.go",
43+
"extensions_publish.go",
44+
"extsvc.go",
45+
"extsvc_create.go",
46+
"extsvc_edit.go",
47+
"extsvc_list.go",
48+
"format.go",
49+
"headers.go",
50+
"login.go",
51+
"lsif.go",
52+
"main.go",
53+
"orgs.go",
54+
"orgs_create.go",
55+
"orgs_delete.go",
56+
"orgs_get.go",
57+
"orgs_list.go",
58+
"orgs_members.go",
59+
"orgs_members_add.go",
60+
"orgs_members_remove.go",
61+
"repos.go",
62+
"repos_add_metadata.go",
63+
"repos_delete.go",
64+
"repos_delete_metadata.go",
65+
"repos_get.go",
66+
"repos_list.go",
67+
"repos_update_metadata.go",
68+
"search.go",
69+
"search_alert.go",
70+
"search_stream.go",
71+
"servegit.go",
72+
"snapshot.go",
73+
"snapshot_databases.go",
74+
"snapshot_restore.go",
75+
"snapshot_summary.go",
76+
"snapshot_testcmd.go",
77+
"snapshot_upload.go",
78+
"team_members_list.go",
79+
"teams.go",
80+
"teams_create.go",
81+
"teams_delete.go",
82+
"teams_list.go",
83+
"teams_members.go",
84+
"teams_members_add.go",
85+
"teams_members_remove.go",
86+
"teams_update.go",
87+
"users.go",
88+
"users_create.go",
89+
"users_delete.go",
90+
"users_get.go",
91+
"users_list.go",
92+
"users_prune.go",
93+
"users_tag.go",
94+
"validate.go",
95+
"validate_install.go",
96+
"validate_kube.go",
97+
"version.go",
98+
],
99+
importpath = "github.com/sourcegraph/src-cli/cmd/src",
100+
visibility = ["//visibility:private"],
101+
deps = [
102+
"//internal/api",
103+
"//internal/batches",
104+
"//internal/batches/docker",
105+
"//internal/batches/executor",
106+
"//internal/batches/graphql",
107+
"//internal/batches/log",
108+
"//internal/batches/repozip",
109+
"//internal/batches/service",
110+
"//internal/batches/ui",
111+
"//internal/batches/watchdog",
112+
"//internal/batches/workspace",
113+
"//internal/cmderrors",
114+
"//internal/codeintel",
115+
"//internal/exec",
116+
"//internal/instancehealth",
117+
"//internal/pgdump",
118+
"//internal/servegit",
119+
"//internal/streaming",
120+
"//internal/users",
121+
"//internal/validate/install",
122+
"//internal/validate/kube",
123+
"//internal/version",
124+
"@com_github_dustin_go_humanize//:go-humanize",
125+
"@com_github_google_go_cmp//cmp",
126+
"@com_github_grafana_regexp//:regexp",
127+
"@com_github_jedib0t_go_pretty_v6//table",
128+
"@com_github_mattn_go_isatty//:go-isatty",
129+
"@com_github_pkg_browser//:browser",
130+
"@com_github_sourcegraph_conc//pool",
131+
"@com_github_sourcegraph_jsonx//:jsonx",
132+
"@com_github_sourcegraph_scip//bindings/go/scip",
133+
"@com_github_sourcegraph_sourcegraph_lib//batches",
134+
"@com_github_sourcegraph_sourcegraph_lib//batches/template",
135+
"@com_github_sourcegraph_sourcegraph_lib//codeintel/lsif/scip",
136+
"@com_github_sourcegraph_sourcegraph_lib//codeintel/upload",
137+
"@com_github_sourcegraph_sourcegraph_lib//errors",
138+
"@com_github_sourcegraph_sourcegraph_lib//output",
139+
"@com_google_cloud_go_storage//:storage",
140+
"@com_jaytaylor_html2text//:html2text",
141+
"@in_gopkg_yaml_v3//:yaml_v3",
142+
"@io_k8s_client_go//kubernetes",
143+
"@io_k8s_client_go//plugin/pkg/client/auth/azure",
144+
"@io_k8s_client_go//plugin/pkg/client/auth/gcp",
145+
"@io_k8s_client_go//tools/clientcmd",
146+
"@io_k8s_client_go//util/homedir",
147+
"@org_golang_google_api//option",
148+
"@org_golang_google_protobuf//proto",
149+
"@org_golang_x_net//context",
150+
"@org_golang_x_sync//errgroup",
151+
"@org_golang_x_sync//semaphore",
152+
],
153+
)
154+
155+
go_binary(
156+
name = "src",
157+
embed = [":src_lib"],
158+
visibility = ["//visibility:public"],
159+
)
160+
161+
go_test(
162+
name = "src_test",
163+
srcs = [
164+
"code_intel_upload_flags_test.go",
165+
"extensions_publish_test.go",
166+
"headers_test.go",
167+
"login_test.go",
168+
"main_test.go",
169+
"search_alert_test.go",
170+
"search_stream_test.go",
171+
"search_test.go",
172+
],
173+
data = glob(["testdata/**"]),
174+
embed = [":src_lib"],
175+
deps = [
176+
"//internal/api",
177+
"//internal/cmderrors",
178+
"//internal/streaming",
179+
"@com_github_google_go_cmp//cmp",
180+
"@com_github_grafana_regexp//:regexp",
181+
"@com_github_hexops_autogold//:autogold",
182+
"@com_github_sourcegraph_scip//bindings/go/scip",
183+
"@com_github_stretchr_testify//require",
184+
"@org_golang_google_protobuf//proto",
185+
],
186+
)

0 commit comments

Comments
 (0)