Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-48777][BUILD]Migrate build system to Bazel #23

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
ref: master
- name: Install Golang
run: |
curl -LO https://go.dev/dl/go1.21.11.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.21.11.linux-amd64.tar.gz
- name: Install Buf
run: |
# See more in "Installation" https://docs.buf.build/installation#tarball
curl -LO https://github.com/bufbuild/buf/releases/download/v1.18.0/buf-Linux-x86_64.tar.gz
mkdir -p $HOME/buf
tar -xvzf buf-Linux-x86_64.tar.gz -C $HOME/buf --strip-components 1
- name: Run Build & Test
run: |
export PATH=$PATH:$HOME/buf/bin
export PATH=$PATH:/usr/local/go/bin
pwd
go mod download -x
make gen
make
make test
ls
bazel build //...
bazel test //...
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@ coverage*

# Ignore binaries
cmd/spark-connect-example-raw-grpc-client/spark-connect-example-raw-grpc-client
cmd/spark-connect-example-spark-session/spark-connect-example-spark-session
cmd/spark-connect-example-spark-session/spark-connect-example-spark-session

# Bazel
bazel-out
bazel-bin
bazel-spark-connect-go
bazel-testlogs
38 changes: 38 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Define the dependencies:
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@gazelle//:def.bzl", "gazelle")
load("@rules_proto_grpc_go//:defs.bzl", "go_grpc_compile", "go_grpc_library", "go_proto_compile", "go_proto_library")

# gazelle:prefix github.com/apache/spark-connect-go/v1
# gazelle:exclude spark
gazelle(name = "gazelle")

# This is the proto library definition that comes directly out of Spark.
proto_library(
name = "spark_connect_protos",
srcs = glob(["spark/connector/connect/common/src/main/protobuf/**/*.proto"]),
import_prefix = "",
strip_import_prefix = "spark/connector/connect/common/src/main/protobuf/",
visibility = ["//visibility:public"],
deps = ["@protobuf//:any_proto"],
)

# Create the proto library directly.
go_proto_library(
name = "spark_connect_proto",
importpath = "github.com/apache/spark-connect-go/v1/internal/generated/spark/connect",
protos = [
":spark_connect_protos",
],
visibility = ["//visibility:public"],
)

go_grpc_library(
name = "spark_connect_proto_grpc",
compilers = ["@io_bazel_rules_go//proto:go_grpc"],
importpath = "github.com/apache/spark-connect-go/v1/internal/generated/spark/connect",
protos = [
":spark_connect_protos",
],
visibility = ["//visibility:public"],
)
31 changes: 31 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module(name = "spark-connect-go", version = "1.0")


bazel_dep(name = "rules_go", version = "0.44.2")
bazel_dep(name = "gazelle", version = "0.35.0")
bazel_dep(name = "protobuf", version = "27.2")
bazel_dep(name = "rules_proto_grpc", version = "5.0.0-alpha2")
bazel_dep(name = "rules_proto_grpc_go", version = "5.0.0-alpha2")


go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")

# Weirdness...
go_deps.gazelle_override(
path="google.golang.org/protobuf",
directives=[
"gazelle:proto disable"
]
)

# All *direct* Go dependencies of the module have to be listed explicitly.
use_repo(
go_deps,
"com_github_apache_arrow_go_v12",
"com_github_google_uuid",
"org_golang_google_grpc",
"com_github_stretchr_testify",
"org_golang_google_protobuf",
"org_golang_x_oauth2",
)
Loading