Skip to content

Commit 2b19da1

Browse files
authored
Merge branch 'opensearch-project:main' into main
2 parents e9174df + 17a71a4 commit 2b19da1

36 files changed

Lines changed: 1300 additions & 731 deletions

.bazelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ build --host_cxxopt=-std=c++14
88

99
# Enable deprecated java_common.compile parameters
1010
build --incompatible_java_common_parameters=false
11+
12+
# Disabel bazelmod by default
13+
build --noenable_bzlmod

.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.4.1
1+
7.0.0
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Build OpenSearch Protobufs GO Artifacts
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
build-protobufs-go:
8+
runs-on: ubuntu-latest
9+
if: github.repository == 'opensearch-project/opensearch-protobufs'
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-java@v4
14+
with:
15+
distribution: temurin # Temurin is a distribution of adoptium
16+
java-version: 21
17+
- name: build protobufs go
18+
run: bazel build //:go_protos_all
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Build OpenSearch Protobufs PYTHON Artifacts
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
build-protobufs-python:
8+
runs-on: ubuntu-latest
9+
if: github.repository == 'opensearch-project/opensearch-protobufs'
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-java@v4
14+
with:
15+
distribution: temurin # Temurin is a distribution of adoptium
16+
java-version: 21
17+
- name: build protobufs python
18+
run: bazel build //:python_protos_all

.github/workflows/maven-publish.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,18 @@ jobs:
1919
with:
2020
distribution: temurin # Temurin is a distribution of adoptium
2121
java-version: 21
22-
- uses: aws-actions/configure-aws-credentials@v1
22+
23+
- name: Load secret
24+
uses: 1password/load-secrets-action@v2
2325
with:
24-
role-to-assume: ${{ secrets.PUBLISH_SNAPSHOTS_ROLE }}
25-
aws-region: us-east-1
26+
# Export loaded secrets as environment variables
27+
export-env: true
28+
env:
29+
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
30+
SONATYPE_USERNAME: op://opensearch-infra-secrets/maven-central-portal-credentials/username
31+
SONATYPE_PASSWORD: op://opensearch-infra-secrets/maven-central-portal-credentials/password
32+
2633
- name: publish snapshots to maven
2734
run: |
28-
export SONATYPE_USERNAME=$(aws secretsmanager get-secret-value --secret-id maven-snapshots-username --query SecretString --output text)
29-
export SONATYPE_PASSWORD=$(aws secretsmanager get-secret-value --secret-id maven-snapshots-password --query SecretString --output text)
30-
echo "::add-mask::$SONATYPE_USERNAME"
31-
echo "::add-mask::$SONATYPE_PASSWORD"
3235
./tools/java/package_proto_jar.sh -c true
3336
./gradlew publishCreatePublicationToSnapshotsRepository

BUILD.bazel

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,39 @@
1-
# protos/BUILD.bazel
2-
load("@rules_java//java:defs.bzl", "java_proto_library")
3-
load("@io_grpc_grpc_java//:java_grpc_library.bzl", "java_grpc_library")
1+
load("@io_bazel_rules_go//go:def.bzl", "go_library")
42

53
package(default_visibility = ["//visibility:public"])
64

7-
# Java proto library
8-
java_proto_library(
9-
name = "protos_java",
10-
deps = [
11-
"//protos/services:document_service_proto",
12-
"//protos/services:search_service_proto"
13-
],
5+
java_library(
6+
name = "java_protos_all",
147
visibility = ["//visibility:public"],
8+
exports = [
9+
"//protos/schemas:common_java_proto",
10+
"//protos/schemas:document_java_proto",
11+
"//protos/schemas:search_java_proto",
12+
"//protos/services:document_service_java_proto",
13+
"//protos/services:search_service_java_proto",
14+
],
1515
)
1616

17-
# Java gRPC library
18-
java_grpc_library(
19-
name = "document_service_grpc_java",
20-
srcs = ["//protos/services:document_service_proto"],
21-
deps = [":protos_java"],
17+
py_library(
18+
name = "python_protos_all",
2219
visibility = ["//visibility:public"],
20+
deps = [
21+
"//protos/schemas:common_python_proto",
22+
"//protos/schemas:document_python_proto",
23+
"//protos/schemas:search_python_proto",
24+
"//protos/services:document_service_python_proto",
25+
"//protos/services:search_service_python_proto",
26+
],
2327
)
2428

25-
java_grpc_library(
26-
name = "search_service_grpc_java",
27-
srcs = ["//protos/services:search_service_proto"],
28-
deps = [":protos_java"],
29+
go_library(
30+
name = "go_protos_all",
2931
visibility = ["//visibility:public"],
32+
deps = [
33+
"//protos/schemas:common_go_proto",
34+
"//protos/schemas:document_go_proto",
35+
"//protos/schemas:search_go_proto",
36+
"//protos/services:document_service_go_proto",
37+
"//protos/services:search_service_go_proto",
38+
],
3039
)

CHANGELOG.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
44

55
## [Unreleased]
66
### Added
7-
- Add search API to generated proto ([#82](https://github.com/opensearch-project/opensearch-protobufs/pull/82))
8-
- Replace required property name from _* to underscore_* and remove duplicate __ from modified title ([#88](https://github.com/opensearch-project/opensearch-protobufs/pull/88))
9-
- Preprocessing spec for collapse oneOf if childComplexOneOf property contains child SimpleOneOf. ([#89](https://github.com/opensearch-project/opensearch-protobufs/pull/89))
10-
- Preprocessing spec for reconstructing a standard schema from single-key map. ([#90](https://github.com/opensearch-project/opensearch-protobufs/pull/90))
11-
- Using official protobuf generator. ([#91](https://github.com/opensearch-project/opensearch-protobufs/pull/91))
12-
- Preprocessing spec for deduplicating enum values. ([#93](https://github.com/opensearch-project/opensearch-protobufs/pull/93))
13-
- Address Generator Build Failure. ([#95](https://github.com/opensearch-project/opensearch-protobufs/pull/95))
14-
- Add http code at the end of response. ([#97](https://github.com/opensearch-project/opensearch-protobufs/pull/97))
15-
- Add GRPC Search server-side streaming endpoint ([#98](https://github.com/opensearch-project/opensearch-protobufs/pull/98))
16-
- Add bi-directional streaming Bulk GRPC endpoint ([#101](https://github.com/opensearch-project/opensearch-protobufs/pull/101))
7+
- Add Go protobuf generation support ([#131](https://github.com/opensearch-project/opensearch-protobufs/pull/131))
178

189
### Removed
1910

DEVELOPER_GUIDE.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,27 @@
22
Install bazel, using the version in .bazelversion.
33

44
# Compile protos and grpc
5+
6+
## All artifacts
57
```
68
bazel build //...
79
```
10+
11+
## Java
12+
```
13+
bazel build //:java_protos_all
14+
```
15+
16+
## Python
17+
```
18+
bazel build //:python_protos_all
19+
```
20+
21+
## Go
22+
```
23+
bazel build //:go_protos_all
24+
```
25+
826
# Proto generated code
927
## Java
1028
### Generate Java Code and packaging as a Maven/Gradle dependency
@@ -14,7 +32,7 @@ To package the generated Java files into a Maven-compatible JAR that can be used
1432
#optional
1533
rm -rf bazel*
1634

17-
rm -rf generated && bazel build //... && ./tools/java/package_proto_jar.sh
35+
rm -rf generated && bazel build //:java_protos_all && ./tools/java/package_proto_jar.sh
1836
```
1937

2038
This script will:
@@ -47,7 +65,7 @@ If using snapshot jar uploaded to sonatype:
4765
```
4866
repositories {
4967
maven {
50-
url = 'https://aws.oss.sonatype.org/content/repositories/snapshots'
68+
url = 'https://central.sonatype.com/repository/maven-snapshots/'
5169
}
5270
}
5371

Dockerfile

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
FROM ubuntu:22.04 AS base-bazel
2+
3+
ENV BAZEL_VERSION=7.0.0
4+
ENV DEBIAN_FRONTEND=noninteractive
5+
6+
RUN apt-get update && apt-get install -y \
7+
curl \
8+
git \
9+
zip \
10+
unzip \
11+
openjdk-21-jdk \
12+
maven \
13+
g++ \
14+
gcc \
15+
golang-go \
16+
&& apt-get clean
17+
18+
RUN apt-get install software-properties-common -y
19+
RUN add-apt-repository ppa:deadsnakes/ppa -y
20+
RUN apt-get install python3.10 python3.10-dev -y
21+
22+
RUN curl -fsSL https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh -o bazel-installer.sh \
23+
&& chmod +x bazel-installer.sh \
24+
&& ./bazel-installer.sh \
25+
&& rm bazel-installer.sh
26+
27+
RUN bazel --version
28+
29+
FROM base-bazel AS build-bazel
30+
31+
# Run as non-root - Required for rules_python
32+
# See: https://github.com/bazelbuild/rules_python/pull/713
33+
# Create group and user
34+
RUN groupadd -r bazeluser && useradd -r -m -g bazeluser bazeluser
35+
RUN mkdir -p /build && \
36+
chown -R bazeluser:bazeluser /build && \
37+
chmod -R 777 /build
38+
39+
USER bazeluser
40+
WORKDIR /build
41+
42+
# Copy entire repository for convenience
43+
# Invalidate cache to ensure updates are captured
44+
ARG CACHEBUST=1
45+
COPY --chown=bazeluser:bazeluser . .
46+
47+
#################################################
48+
##### JAVA STAGES ###############################
49+
#################################################
50+
51+
FROM build-bazel AS build-bazel-java
52+
53+
RUN bazel build //:java_protos_all
54+
55+
FROM build-bazel-java AS package-bazel-java
56+
57+
RUN /build/tools/java/package_proto_jar.sh
58+
59+
FROM package-bazel-java AS test-bazel-java
60+
61+
ARG OPENSEARCH_BRANCH=main
62+
ARG PROTO_SNAPSHOT_VERSION=0.4.0
63+
64+
ENV JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
65+
ENV PATH=$PATH:$JAVA_HOME/bin
66+
ENV PUB_ARTIFACTS=/build/generated/maven/publish/
67+
68+
RUN mvn install:install-file \
69+
-Dfile=${PUB_ARTIFACTS}protobufs-${PROTO_SNAPSHOT_VERSION}-SNAPSHOT.jar \
70+
-DpomFile=${PUB_ARTIFACTS}protobufs-${PROTO_SNAPSHOT_VERSION}-SNAPSHOT.pom \
71+
-Dsources=${PUB_ARTIFACTS}protobufs-${PROTO_SNAPSHOT_VERSION}-SNAPSHOT-sources.jar \
72+
-Djavadoc=${PUB_ARTIFACTS}protobufs-${PROTO_SNAPSHOT_VERSION}-SNAPSHOT-javadoc.jar
73+
74+
RUN git clone --branch ${OPENSEARCH_BRANCH} https://github.com/opensearch-project/OpenSearch.git /build/opensearch
75+
76+
WORKDIR /build/opensearch
77+
78+
# Update transport-grpc/build.gradle to use PROTO_SNAPSHOT_VERSION
79+
RUN sed -i 's/org\.opensearch:protobufs:[0-9]\+\.[0-9]\+\.[0-9]\+/org.opensearch:protobufs:'"${PROTO_SNAPSHOT_VERSION}"'/' /build/opensearch/plugins/transport-grpc/build.gradle
80+
81+
RUN ./gradlew :plugins:transport-grpc:test -Drepos.mavenLocal
82+
RUN ./gradlew :plugins:transport-grpc:internalClusterTest -Drepos.mavenLocal
83+
84+
#################################################
85+
##### PYTHON STAGES #############################
86+
#################################################
87+
88+
FROM build-bazel AS build-bazel-python
89+
90+
RUN bazel build //:python_protos_all
91+
92+
#################################################
93+
##### GO STAGES ##################################
94+
#################################################
95+
96+
FROM build-bazel AS build-bazel-go
97+
98+
RUN bazel build //:go_protos_all
99+
100+
FROM build-bazel-go AS package-bazel-go
101+
102+
# Create a clean directory structure for Go protobuf files
103+
RUN mkdir -p /build/generated/go/opensearchpb && \
104+
mkdir -p /build/generated/go/services
105+
106+
# Copy generated Go protobuf files
107+
RUN find bazel-bin/protos/schemas -name "*.pb.go" -path "*_go_proto_pb*" -exec cp {} /build/generated/go/opensearchpb/ \; && \
108+
find bazel-bin/protos/services -name "*.pb.go" -path "*_go_proto_pb*" -exec cp {} /build/generated/go/services/ \; && \
109+
find bazel-bin/protos/services -name "*_grpc.pb.go" -path "*_go_proto_pb*" -exec cp {} /build/generated/go/services/ \;
110+
111+
FROM package-bazel-go AS test-bazel-go
112+
113+
# Set up Go module and validate generated code
114+
WORKDIR /build/generated/go
115+
116+
# Create go.mod with proper module path
117+
RUN echo 'module github.com/opensearch-project/opensearch-protobufs/go' > go.mod && \
118+
echo '' >> go.mod && \
119+
echo 'go 1.19' >> go.mod && \
120+
echo '' >> go.mod && \
121+
echo 'require (' >> go.mod && \
122+
echo ' google.golang.org/protobuf v1.31.0' >> go.mod && \
123+
echo ' google.golang.org/grpc v1.58.0' >> go.mod && \
124+
echo ')' >> go.mod
125+
126+
# Test that Go code compiles successfully
127+
RUN go mod tidy && \
128+
go build ./...

0 commit comments

Comments
 (0)