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

chore: centralize proto files #88

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 10 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
30 changes: 18 additions & 12 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,20 @@ on:
branches: [ main ]

jobs:
build:
name: Unit Tests
proto:
name: Proto Generation
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.17

go-version: ^1.20
- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Get dependencies
run: go mod download

- name: Install protoc
run: |
set -eux -o pipefail
PROTOC_VERSION=3.19.4
PROTOC_VERSION=24.3
PROTOC_ZIP=protoc-$PROTOC_VERSION-linux-x86_64.zip
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/$PROTOC_ZIP
sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
Expand All @@ -36,10 +30,22 @@ jobs:
sudo find /usr/local/include -type d | xargs sudo chmod a+rx
rm -f $PROTOC_ZIP
ls /usr/local/include/google/protobuf/

- name: Proto Gen
run: make proto
build:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.20
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get dependencies
run: go mod download
- name: Install mockgen
run: |
go install github.com/golang/mock/[email protected]

- name: Test
run: make all
18 changes: 14 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
SHELL:=/bin/bash

CURRENT_DIR=$(shell pwd)

ORG?=numaproj
PROJECT?=numaflow
BRANCH?=main

.PHONY: all
all: proto generate test
all: generate test

clean:
-rm -rf ${CURRENT_DIR}/dist

.PHONY: test
test:
go test -race -v ./...

.PHONY: proto
proto:
proto: clean
go mod vendor
./hack/protogen.sh
ORG=$(ORG) PROJECT=$(PROJECT) BRANCH=$(BRANCH) ./hack/protogen.sh
rm -rf ./vendor
go mod tidy

.PHONY: generate
generate:
go generate ./...


11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@

This SDK provides the interfaces to implement [Numaflow](https://github.com/numaproj/numaflow) User Defined Sources,
Source Transformer, Functions, Sinks or SideInputs in Golang.

- Implement [User Defined Sources](https://pkg.go.dev/github.com/numaproj/numaflow-go/pkg/sourcer)
- Implement [User Defined Source Transformers](https://pkg.go.dev/github.com/numaproj/numaflow-go/pkg/sourcetransformer)
- Implement [User Defined Functions](https://pkg.go.dev/github.com/numaproj/numaflow-go/pkg/function)
- Implement [User Defined Sinks](https://pkg.go.dev/github.com/numaproj/numaflow-go/pkg/sink)
- Implement [User Defined SideInputs](https://pkg.go.dev/github.com/numaproj/numaflow-go/pkg/sideinput)
- Implement [User Defined SideInputs](https://pkg.go.dev/github.com/numaproj/numaflow-go/pkg/sideinput)

## Development

### Useful Commands

`make test` - Run the tests.
`make proto`- Regenerate the protobuf files from the [proto files](https://github.com/numaproj/numaflow/tree/main/pkg/apis/proto) defined in [numaproj/numaflow](https://github.com/numaproj/numaflow) repository.
`make proto ORG=xxx PROJECT=xxx BRANCH=xxx` - Regenerate the protobuf files from specified github repository.
21 changes: 20 additions & 1 deletion hack/protogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ set -o errexit
set -o nounset
set -o pipefail

readonly REPO_ROOT="$(git rev-parse --show-toplevel)"

if [ "`command -v protoc`" = "" ]; then
echo "Please install protobuf with - brew install protobuf"
exit 1
Expand All @@ -19,4 +21,21 @@ if [ "`command -v protoc-gen-go-grpc`" = "" ]; then
go install -mod=vendor ./vendor/google.golang.org/grpc/cmd/protoc-gen-go-grpc
fi

protoc --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. -I. $(find pkg/apis/proto -name '*.proto')
mkdir -p ${REPO_ROOT}/dist

ORG=${ORG:-numaproj}
PROJECT=${PROJECT:-numaflow}
BRANCH=${BRANCH:-main}

REMOTE_URL_PRE="https://raw.githubusercontent.com/${ORG}/${PROJECT}/${BRANCH}/pkg/apis/proto"
echo "Remote URL prefix: $REMOTE_URL_PRE"

curl -Ls -o ${REPO_ROOT}/dist/map.proto ${REMOTE_URL_PRE}/map/v1/map.proto
curl -Ls -o ${REPO_ROOT}/dist/reduce.proto ${REMOTE_URL_PRE}/reduce/v1/reduce.proto
curl -Ls -o ${REPO_ROOT}/dist/mapstream.proto ${REMOTE_URL_PRE}/mapstream/v1/mapstream.proto
curl -Ls -o ${REPO_ROOT}/dist/sideinput.proto ${REMOTE_URL_PRE}/sideinput/v1/sideinput.proto
curl -Ls -o ${REPO_ROOT}/dist/sink.proto ${REMOTE_URL_PRE}/sink/v1/sink.proto
curl -Ls -o ${REPO_ROOT}/dist/source.proto ${REMOTE_URL_PRE}/source/v1/source.proto
curl -Ls -o ${REPO_ROOT}/dist/transform.proto ${REMOTE_URL_PRE}/sourcetransform/v1/transform.proto

protoc --go_out=module=github.com/numaproj/numaflow-go:. --go-grpc_out=module=github.com/numaproj/numaflow-go:. -I ${REPO_ROOT}/dist $(find ${REPO_ROOT}/dist -name '*.proto')
Loading