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

feat: Upgrade buf to v2 #179

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 0 additions & 4 deletions .github/workflows/README.md

This file was deleted.

18 changes: 18 additions & 0 deletions .github/workflows/buf-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Buf CI
on:
push:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
delete:
permissions:
contents: read
pull-requests: write
jobs:
buf:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bufbuild/buf-action@v1
with:
token: ${{ secrets.BUF_TOKEN }}
breaking_against: ${{ github.event.repository.clone_url }}#format=git,commit=${{ github.event.pull_request.base.sha }},subdir=protobuf
51 changes: 3 additions & 48 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,69 +6,24 @@ on:
permissions:
contents: read

env:
GO_VERSION: 1.22

jobs:
lint-protos:
runs-on: ubuntu-latest
steps:
# Install the `buf` CLI
- uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ github.token }}
- name: Checkout repository
uses: actions/checkout@v4
# Lint your Protobuf sources
- uses: bufbuild/buf-lint-action@v1
with:
input: protobuf

buf-format:
runs-on: ubuntu-latest
steps:
# Install the `buf` CLI
- uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ github.token }}
- name: Checkout repository
uses: actions/checkout@v4
- name: Buf format check
run: buf format -d --exit-code

buf-breaking-changes:
runs-on: ubuntu-latest
steps:
# Install the `buf` CLI
- uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ github.token }}
- name: Checkout repository
uses: actions/checkout@v4
# Run breaking change detection against the last commit
- uses: bufbuild/buf-breaking-action@v1
with:
input: protobuf
against: 'https://github.com/open-feature/schemas.git#branch=main,ref=HEAD~1,subdir=protobuf'


validate-schema:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

# Use ajv to validate schema
- name: Setup node
uses: actions/setup-node@v4.0.1
uses: actions/setup-node@v4.1.0

- name: Validate schema
run: make ajv-validate-flagd-schema

# Run go test suite to validate the json schema against positive and/or negative validations in /json/test
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
go-version-file: 'go.mod'
- name: Validate Schema
run: make test

Expand Down
18 changes: 0 additions & 18 deletions .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,8 @@ jobs:
signoff: "OpenFeature Bot <[email protected]>"
outputs:
releases_created: ${{ steps.release.outputs.releases_created }}
# these are generated by release-please b/c this is in a manifest repo.
buf_release_tag: ${{ steps.release.outputs.protobuf--tag_name }}
json_release_tag: ${{ steps.release.outputs.json--tag_name }}

push-module:
needs: release-please
name: push schema to buf registry
runs-on: ubuntu-latest
if: ${{ needs.release-please.outputs.releases_created && needs.release-please.outputs.buf_release_tag }}
steps:
# Run `git checkout`
- uses: actions/checkout@v4
with:
ref: ${{ needs.release-please.outputs.buf_release_tag }}
# Install the `buf` CLI
- uses: bufbuild/buf-setup-action@v1
# Push module to the BSR
- name: bsr-push
run: BUF_TOKEN="${{ secrets.BUF_TOKEN }}" buf push --tag "${{ needs.release-please.outputs.buf_release_tag }}" protobuf

create-schema-store-issue:
needs: release-please
name: create schema release reminder issue
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BUF_VERSION=v1.26.1
BUF_VERSION=v1.50.0

guard-%:
@ if [ "${${*}}" = "" ]; then \
Expand Down
9 changes: 9 additions & 0 deletions buf.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Generated by buf. DO NOT EDIT.
version: v2
deps:
- name: buf.build/googleapis/googleapis
commit: e9fcfb66f77242e5b8fd4564d7a01033
digest: b5:88319861f1e8014c4ca02b9fcc08c0cfe5a08ba518e9f66ce8b8c115895165e2bb579e84c3b8fd18b440c4217e8c426bc25f7edc60d00352924fbbbe871ead01
- name: buf.build/grpc-ecosystem/grpc-gateway
commit: bc28b723cd774c32b6fbc77621518765
digest: b5:a613f827fa6ff35a4f5e87e80e35ac6b35e5792cc9c5a658351072777d88c6d4df785a0c14889090db11667cf5463d122c7193b3719c7861d3e5747c22ce1381
26 changes: 12 additions & 14 deletions protobuf/buf.md → buf.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# Flagd build spec

### Managed by [OpenFeature](https://github.com/open-feature).
This repository contains grpc service definitions that developers can use for interacting with [flagd](https://flagd.dev).

This repository contains grpc service definitions that developers can use for interacting with [flagd](https://github.com/open-feature/flagd).
Below are the modules exposed through this repository:

Given below are the modules exposed through this repository,

- [Flag evaluation](#Flag-evaluation)
- [Flag sync](#Flag-sync)
- [Flag evaluation](#flag-evaluation)
- [Flag sync](#flag-sync)

## Flag evaluation

Expand All @@ -16,27 +14,27 @@ The module `schema.v1` contains a single `Service`, describing the 5 core `rpcs`
response objects (`ResolveXXXRequest` and `ResolveXXXResponse`). The final `rpc` on the `Service` is a streamed response
named `EventStream`, this is used to pass internal events to the client, such as `configuration_change` and `provider_ready`.

Internally, flagd uses the connect protocol, meaning it is compatible with grpc interfaces. If your desired language has
a supported plugin for generating connect stubs then it is recommended to use these over grpc.
Internally, flagd uses the connect protocol, meaning it is compatible with grpc interfaces.
If your desired language has a supported plugin for generating connect stubs then it is recommended to use these over grpc.

## Flag sync

The module `sync.v1` is a service definition to provide flagd with feature flag configurations.
The server exposes 2 `rpcs`.

### SyncFlags

Flagd acts as the client and initiates the streaming with `SyncFlagsRequest`.
The server implementation will then stream feature flag configurations through `SyncFlagsResponse`. The response contains
`SyncState` which can be utilized to provide flagd with flexible configuration updates.
The server implementation will then stream feature flag configurations through `SyncFlagsResponse`.
The response contains `SyncState` which can be utilized to provide flagd with flexible configuration updates.

### FetchAllFlags

Flagd acts as the client and sends the empty message `FetchAllFlagsRequest`.
The server implementation responds with the full feature flag configuration through the `FetchAllFlagsResponse`.
This `rpc` is used to re-sync flagd's internal state during configuration merge events.

## Code generation

Easiest way to generate grpc code for your language of choice is using provided [buf](https://buf.build/) templates.
For example, with required binaries in your path, java code generation can be done using
`buf generate --template buf.gen.java.yaml` command.

Easiest way to generate gRPC code for your language of choice is using provided [buf](https://buf.build/) templates.
For example, with required binaries in your path, java code generation can be done using `buf generate --template buf.gen.java.yaml` command.
23 changes: 23 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: v2
modules:
- path: protobuf
name: buf.build/open-feature/flagd
deps:
- buf.build/googleapis/googleapis
- buf.build/grpc-ecosystem/grpc-gateway
lint:
use:
- STANDARD
except:
- FIELD_NOT_REQUIRED
- PACKAGE_NO_IMPORT_CYCLE
ignore:
- protobuf/buf.build/googleapis/googleapis
- protobuf/buf.build/grpc-ecosystem/grpc-gateway
disallow_comment_ignores: true
breaking:
use:
- FILE
except:
- EXTENSION_NO_DELETE
- FIELD_SAME_DEFAULT
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/open-feature/flagd-schemas

go 1.18
go 1.23

require github.com/xeipuuv/gojsonschema v1.2.0

Expand Down
6 changes: 3 additions & 3 deletions protobuf/buf.gen.csharp.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: v1
version: v2
managed:
enabled: true
plugins:
- plugin: buf.build/protocolbuffers/csharp:v23.4
- remote: buf.build/protocolbuffers/csharp:v23.4
out: ../proto/csharp
- plugin: buf.build/grpc/csharp:v1.56.0
- remote: buf.build/grpc/csharp:v1.56.0
out: ../proto/csharp
13 changes: 6 additions & 7 deletions protobuf/buf.gen.go-server.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
version: v1
version: v2
managed:
enabled: true
plugins:
- plugin: buf.build/protocolbuffers/go:v1.31.0
- remote: buf.build/protocolbuffers/go:v1.31.0
out: ../proto/go-server
opt:
- paths=source_relative
- plugin: buf.build/grpc/go:v1.3.0
opt: paths=source_relative
- remote: buf.build/grpc/go:v1.3.0
out: ../proto/go-server
opt:
- require_unimplemented_servers=false
- paths=source_relative
- plugin: buf.build/grpc-ecosystem/gateway:v2.16.0
- remote: buf.build/grpc-ecosystem/gateway:v2.16.0
out: ../proto/go-server
opt:
- paths=source_relative
- generate_unbound_methods=true
- generate_unbound_methods=true
11 changes: 5 additions & 6 deletions protobuf/buf.gen.go.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
version: v1
version: v2
managed:
enabled: true
plugins:
- plugin: buf.build/protocolbuffers/go:v1.31.0
- remote: buf.build/protocolbuffers/go:v1.31.0
out: ../proto/go
opt:
- paths=source_relative
- plugin: buf.build/grpc/go:v1.3.0
opt: paths=source_relative
- remote: buf.build/grpc/go:v1.3.0
out: ../proto/go
opt:
- require_unimplemented_servers=false
- paths=source_relative
- paths=source_relative
8 changes: 4 additions & 4 deletions protobuf/buf.gen.java.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: v1
version: v2
managed:
enabled: true
plugins:
- plugin: buf.build/protocolbuffers/java:v23.4
- remote: buf.build/protocolbuffers/java:v23.4
out: ../proto/java
- remote: buf.build/grpc/java:v1.56.1
out: ../proto/java
- plugin: buf.build/grpc/java:v1.56.1
out: ../proto/java
6 changes: 3 additions & 3 deletions protobuf/buf.gen.php.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: v1
version: v2
plugins:
- plugin: buf.build/grpc/php:v1.56.0
- remote: buf.build/grpc/php:v1.56.0
out: ../proto/php
- plugin: buf.build/protocolbuffers/php:v23.4
- remote: buf.build/protocolbuffers/php:v23.4
out: ../proto/php
8 changes: 4 additions & 4 deletions protobuf/buf.gen.python.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: v1
version: v2
managed:
enabled: true
plugins:
- plugin: buf.build/protocolbuffers/python:v23.4
- remote: buf.build/protocolbuffers/python:v23.4
out: ../proto/python
- remote: buf.build/grpc/python:v1.56.0
out: ../proto/python
- plugin: buf.build/grpc/python:v1.56.0
out: ../proto/python
6 changes: 3 additions & 3 deletions protobuf/buf.gen.ruby.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: v1
version: v2
plugins:
- plugin: buf.build/grpc/ruby:v1.56.0
- remote: buf.build/grpc/ruby:v1.56.0
out: ./lib/openfeature/flagd/provider
- plugin: buf.build/protocolbuffers/ruby:v23.4
- remote: buf.build/protocolbuffers/ruby:v23.4
out: ./lib/openfeature/flagd/provider
8 changes: 3 additions & 5 deletions protobuf/buf.gen.rust.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# buf.gen.yaml
version: v1
version: v2
managed:
enabled: true
plugins:
# Requires protoc-gen-tonic & protoc-gen-prost to enable service client creation
- name: prost
- local: protoc-gen-prost
out: ../proto/rust
- name: tonic
- local: protoc-gen-tonic
out: ../proto/rust
12 changes: 5 additions & 7 deletions protobuf/buf.gen.ts-connect.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
version: v1
version: v2
plugins:
- plugin: buf.build/bufbuild/es:v1.2.1
- remote: buf.build/bufbuild/es:v1.2.1
out: ../proto/ts
opt:
- target=ts
- plugin: buf.build/bufbuild/connect-es:v0.11.0
opt: target=ts
- remote: buf.build/bufbuild/connect-es:v0.11.0
out: ../proto/ts
opt:
- target=ts
opt: target=ts
6 changes: 3 additions & 3 deletions protobuf/buf.gen.ts.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: v1
version: v2
plugins:
- plugin: buf.build/community/stephenh-ts-proto:v1.156.0
- remote: buf.build/community/stephenh-ts-proto:v1.156.0
out: ../proto/ts
opt:
opt:
- outputServices=grpc-js
- forceLong=string
- esModuleInterop=true
11 changes: 0 additions & 11 deletions protobuf/buf.lock

This file was deleted.

Loading
Loading