mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 19:21:50 +00:00
bazel: include zoekt version stamp in github.com/sourcegraph/zoekt.Version (#61464)
As we were including the `go_binary`'s directly in the images, we couldn't set the x_defs attr in order to stamp. Given this, we patch each of the `go_binary` rules to include the x_defs. ## Test plan ```sh $ VERSION=6.9.50 bazel build @com_github_sourcegraph_zoekt//cmd/zoekt-webserver --stamp --workspace_status_command=./dev/bazel_stamp_vars.sh ... $ strings bazel-bin/external/com_github_sourcegraph_zoekt/cmd/zoekt-webserver/zoekt-webserver_/zoekt-webserver | grep 8cf8 v0.0.0-20240327102325-8cf8887a903a ```
This commit is contained in:
parent
8993700092
commit
ceaa22ab84
4
deps.bzl
4
deps.bzl
@ -5339,6 +5339,10 @@ def go_dependencies():
|
||||
name = "com_github_sourcegraph_zoekt",
|
||||
build_file_proto_mode = "disable_global",
|
||||
importpath = "github.com/sourcegraph/zoekt",
|
||||
patch_args = ["-p1"],
|
||||
patches = [
|
||||
"//third_party/com_github_sourcegraph_zoekt:x_defs_version.patch",
|
||||
],
|
||||
sum = "h1:tMqptvT8zd2xD1Yl11zDd42fBHxlT40zJoPU+Vl8REI=",
|
||||
version = "v0.0.0-20240402071238-c39011a14191",
|
||||
)
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
echo STABLE_VERSION "$VERSION"
|
||||
echo VERSION_TIMESTAMP "$(date +%s)"
|
||||
echo ZOEKT_VERSION "$(grep sourcegraph/zoekt go.mod | awk '{ print $2 }')"
|
||||
|
||||
# Unstable Buildkite env vars
|
||||
echo "BUILDKITE $BUILDKITE"
|
||||
|
||||
@ -1 +1,38 @@
|
||||
load("@bazel_skylib//rules:build_test.bzl", "build_test")
|
||||
|
||||
exports_files(glob(["*.patch"]))
|
||||
|
||||
genrule(
|
||||
name = "golist_grep",
|
||||
testonly = True,
|
||||
srcs = [
|
||||
"//:go.mod",
|
||||
],
|
||||
outs = [
|
||||
"diff.patch",
|
||||
],
|
||||
cmd = """
|
||||
$(location @go_sdk//:bin/go) list -m github.com/sourcegraph/zoekt | awk '{print $$2}' > golist.txt
|
||||
# implicit binary dependencies ooooh :ghost:
|
||||
grep sourcegraph/zoekt go.mod | awk '{ print $$2 }' > grep.txt
|
||||
set +e
|
||||
diff --unified=0 golist.txt grep.txt > $(@D)/diff.patch
|
||||
RESULT=$$?
|
||||
set -e
|
||||
if [ $$RESULT -ne 0 ]; then
|
||||
>&2 echo "Difference in 'go list' and grepping go.mod"
|
||||
>&2 cat $(@D)/diff.patch
|
||||
exit $$RESULT
|
||||
fi
|
||||
exit 0
|
||||
""",
|
||||
tags = ["requires-network"],
|
||||
tools = [
|
||||
"@go_sdk//:bin/go",
|
||||
],
|
||||
)
|
||||
|
||||
build_test(
|
||||
name = "test_golist_grep",
|
||||
targets = [":golist_grep"],
|
||||
)
|
||||
|
||||
76
third_party/com_github_sourcegraph_zoekt/x_defs_version.patch
vendored
Normal file
76
third_party/com_github_sourcegraph_zoekt/x_defs_version.patch
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
diff --git a/cmd/zoekt-archive-index/BUILD.bazel b/cmd/zoekt-archive-index/BUILD.bazel
|
||||
index f5553ff..81b0b8f 100644
|
||||
--- a/cmd/zoekt-archive-index/BUILD.bazel
|
||||
+++ b/cmd/zoekt-archive-index/BUILD.bazel
|
||||
@@ -20,4 +20,7 @@ go_binary(
|
||||
name = "zoekt-archive-index",
|
||||
embed = [":zoekt-archive-index_lib"],
|
||||
visibility = ["//visibility:public"],
|
||||
+ x_defs = {
|
||||
+ "github.com/sourcegraph/zoekt.Version": "{ZOEKT_VERSION}",
|
||||
+ },
|
||||
)
|
||||
diff --git a/cmd/zoekt-git-index/BUILD.bazel b/cmd/zoekt-git-index/BUILD.bazel
|
||||
index d924f9e..ca53c74 100644
|
||||
--- a/cmd/zoekt-git-index/BUILD.bazel
|
||||
+++ b/cmd/zoekt-git-index/BUILD.bazel
|
||||
@@ -17,4 +17,7 @@ go_binary(
|
||||
name = "zoekt-git-index",
|
||||
embed = [":zoekt-git-index_lib"],
|
||||
visibility = ["//visibility:public"],
|
||||
+ x_defs = {
|
||||
+ "github.com/sourcegraph/zoekt.Version": "{ZOEKT_VERSION}",
|
||||
+ },
|
||||
)
|
||||
diff --git a/cmd/zoekt-indexserver/BUILD.bazel b/cmd/zoekt-indexserver/BUILD.bazel
|
||||
index 761009d..9bd68b6 100644
|
||||
--- a/cmd/zoekt-indexserver/BUILD.bazel
|
||||
+++ b/cmd/zoekt-indexserver/BUILD.bazel
|
||||
@@ -19,4 +19,7 @@ go_binary(
|
||||
name = "zoekt-indexserver",
|
||||
embed = [":zoekt-indexserver_lib"],
|
||||
visibility = ["//visibility:public"],
|
||||
+ x_defs = {
|
||||
+ "github.com/sourcegraph/zoekt.Version": "{ZOEKT_VERSION}",
|
||||
+ },
|
||||
)
|
||||
diff --git a/cmd/zoekt-merge-index/BUILD.bazel b/cmd/zoekt-merge-index/BUILD.bazel
|
||||
index 7ce9022..11d2cc5 100644
|
||||
--- a/cmd/zoekt-merge-index/BUILD.bazel
|
||||
+++ b/cmd/zoekt-merge-index/BUILD.bazel
|
||||
@@ -12,6 +12,9 @@ go_binary(
|
||||
name = "zoekt-merge-index",
|
||||
embed = [":zoekt-merge-index_lib"],
|
||||
visibility = ["//visibility:public"],
|
||||
+ x_defs = {
|
||||
+ "github.com/sourcegraph/zoekt.Version": "{ZOEKT_VERSION}",
|
||||
+ },
|
||||
)
|
||||
|
||||
go_test(
|
||||
diff --git a/cmd/zoekt-sourcegraph-indexserver/BUILD.bazel b/cmd/zoekt-sourcegraph-indexserver/BUILD.bazel
|
||||
index 0e817fe..4b2e50c 100644
|
||||
--- a/cmd/zoekt-sourcegraph-indexserver/BUILD.bazel
|
||||
+++ b/cmd/zoekt-sourcegraph-indexserver/BUILD.bazel
|
||||
@@ -53,6 +53,9 @@ go_binary(
|
||||
name = "zoekt-sourcegraph-indexserver",
|
||||
embed = [":zoekt-sourcegraph-indexserver_lib"],
|
||||
visibility = ["//visibility:public"],
|
||||
+ x_defs = {
|
||||
+ "github.com/sourcegraph/zoekt.Version": "{ZOEKT_VERSION}",
|
||||
+ },
|
||||
)
|
||||
|
||||
go_test(
|
||||
diff --git a/cmd/zoekt-webserver/BUILD.bazel b/cmd/zoekt-webserver/BUILD.bazel
|
||||
index c826c9a..912a7f7 100644
|
||||
--- a/cmd/zoekt-webserver/BUILD.bazel
|
||||
+++ b/cmd/zoekt-webserver/BUILD.bazel
|
||||
@@ -93,4 +93,7 @@ go_binary(
|
||||
name = "zoekt-webserver",
|
||||
embed = [":zoekt-webserver_lib"],
|
||||
visibility = ["//visibility:public"],
|
||||
+ x_defs = {
|
||||
+ "github.com/sourcegraph/zoekt.Version": "{ZOEKT_VERSION}",
|
||||
+ },
|
||||
)
|
||||
@ -1,13 +0,0 @@
|
||||
diff --git a/cmd/zoekt-archive-index/BUILD.bazel b/cmd/zoekt-archive-index/BUILD.bazel
|
||||
index e62a8d2..4b045f7 100644
|
||||
--- a/cmd/zoekt-archive-index/BUILD.bazel
|
||||
+++ b/cmd/zoekt-archive-index/BUILD.bazel
|
||||
@@ -22,6 +22,8 @@ go_binary(
|
||||
name = "zoekt-archive-index",
|
||||
embed = [":zoekt-archive-index_lib"],
|
||||
visibility = ["//visibility:public"],
|
||||
+ pure = "on",
|
||||
+ static = "on",
|
||||
)
|
||||
|
||||
go_test(
|
||||
@ -1,12 +0,0 @@
|
||||
diff --git a/cmd/zoekt-git-index/BUILD.bazel b/cmd/zoekt-git-index/BUILD.bazel
|
||||
index 0606281..0ce27ff 100644
|
||||
--- a/cmd/zoekt-git-index/BUILD.bazel
|
||||
+++ b/cmd/zoekt-git-index/BUILD.bazel
|
||||
@@ -16,4 +16,6 @@ go_binary(
|
||||
name = "zoekt-git-index",
|
||||
embed = [":zoekt-git-index_lib"],
|
||||
visibility = ["//visibility:public"],
|
||||
-)
|
||||
+ pure = "on",
|
||||
+ static = "on",
|
||||
+ )
|
||||
@ -1,13 +0,0 @@
|
||||
diff --git a/cmd/zoekt-sourcegraph-indexserver/BUILD.bazel b/cmd/zoekt-sourcegraph-indexserver/BUILD.bazel
|
||||
index 503fd67..6989a2d 100644
|
||||
--- a/cmd/zoekt-sourcegraph-indexserver/BUILD.bazel
|
||||
+++ b/cmd/zoekt-sourcegraph-indexserver/BUILD.bazel
|
||||
@@ -50,6 +50,8 @@ go_binary(
|
||||
name = "zoekt-sourcegraph-indexserver",
|
||||
embed = [":zoekt-sourcegraph-indexserver_lib"],
|
||||
visibility = ["//visibility:public"],
|
||||
+ pure = "on",
|
||||
+ static = "on",
|
||||
)
|
||||
|
||||
go_test(
|
||||
@ -1,11 +0,0 @@
|
||||
diff --git a/cmd/zoekt-webserver/BUILD.bazel b/cmd/zoekt-webserver/BUILD.bazel
|
||||
index 705d454..abb4446 100644
|
||||
--- a/cmd/zoekt-webserver/BUILD.bazel
|
||||
+++ b/cmd/zoekt-webserver/BUILD.bazel
|
||||
@@ -83,4 +83,6 @@ go_binary(
|
||||
name = "zoekt-webserver",
|
||||
embed = [":zoekt-webserver_lib"],
|
||||
visibility = ["//visibility:public"],
|
||||
+ pure = "on",
|
||||
+ static = "on",
|
||||
)
|
||||
@ -1 +0,0 @@
|
||||
exports_files(glob(["*"]))
|
||||
Loading…
Reference in New Issue
Block a user