Skip to content

Commit

Permalink
chore: remove external submodule and use BUF for code gen. (#470)
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Bühler <cbuehler@rootd.ch>
  • Loading branch information
buehler committed Jun 19, 2023
1 parent 1a7f8b6 commit 31318a8
Show file tree
Hide file tree
Showing 18 changed files with 68 additions and 258 deletions.
33 changes: 9 additions & 24 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,24 @@ on:
- main

jobs:
lint_and_test:
name: Testing
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: arduino/setup-protoc@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions-rs/cargo@v1
with:
command: test
args: --all-features

package_and_publish:
name: Package and Publish
needs:
- lint_and_test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- uses: extractions/setup-just@v1
with:
submodules: true
github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: arduino/setup-protoc@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- run: cargo install protoc-gen-prost protoc-gen-prost-crate protoc-gen-tonic
- name: generated grpc code
run: just
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/security-check.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Security audit
name: Security Audit

on:
push:
paths:
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
schedule:
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
submodules: true
- uses: arduino/setup-protoc@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- run: rustup component add clippy
- uses: actions-rs/clippy-check@v1
components: rustfmt, clippy
- uses: bufbuild/buf-setup-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features --no-deps
- uses: actions-rs/toolchain@v1
github_token: ${{ secrets.GITHUB_TOKEN }}
- uses: extractions/setup-just@v1
with:
toolchain: stable
- uses: actions-rs/cargo@v1
github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: arduino/setup-protoc@v1
with:
command: test
args: --all-features
repo-token: ${{ secrets.GITHUB_TOKEN }}
- run: cargo install protoc-gen-prost protoc-gen-prost-crate protoc-gen-tonic
- name: generated grpc code
run: just
- run: cargo clippy --all-features --no-deps
- run: cargo test --all-features
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target
Cargo.lock
temp*
src/api/generated
12 changes: 0 additions & 12 deletions .gitmodules

This file was deleted.

23 changes: 4 additions & 19 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,22 @@ repository = "https://github.com/buehler/zitadel-rust"
keywords = ["ZITADEL", "gRPC", "clients", "authentication", "oidc"]
categories = ["authentication", "api-bindings"]
include = [
"build.rs",
"src/**/*.rs",
"Cargo.toml",
"LICENSE*",
"README.md",
"external/zitadel/proto/**/*.proto",
"external/protoc-gen-validate/validate/**/*.proto",
"external/googleapis/google/**/*.proto",
"external/grpc-gateway/protoc-gen-openapiv2/**/*.proto",
]

[features]
default = []

## The API feature enables the gRPC service clients to access the ZITADEL API.
api = ["dep:prost", "dep:prost-types", "dep:tonic", "dep:tonic-types"]
api = ["dep:prost", "dep:prost-types", "dep:tonic", "dep:tonic-types", "dep:pbjson-types"]

## The credentials feature enables special credentials helpers for ZITADEL.
## For example, it allows the user to create a ZITADEL service account and
## authenticate against ZITADEL.
credentials = [
"dep:jsonwebtoken",
"dep:openidconnect",
"dep:reqwest",
"dep:serde",
"dep:serde_json",
"dep:serde_urlencoded",
"dep:time",
]
credentials = ["dep:jsonwebtoken", "dep:openidconnect", "dep:reqwest", "dep:serde", "dep:serde_json", "dep:serde_urlencoded", "dep:time"]

## The interceptors feature enables specific gRPC interceptors and
## new convenience functions to create a gRPC client with interceptors.
Expand All @@ -48,10 +35,7 @@ interceptors = ["api", "credentials", "dep:time", "dep:tokio"]
## The OIDC module enables basic OIDC (OpenID Connect) features to communicate
## with ZITADEL. Two examples are the `discover` and `introspect` functions.
## The OIDC features are required for some of the web framework features.
oidc = [
"credentials",
"dep:base64-compat",
]
oidc = ["credentials", "dep:base64-compat"]

## Feature that enables support for the [rocket framework](https://rocket.rs/).
## It enables authentication features for rocket in the form of route guards.
Expand All @@ -68,6 +52,7 @@ custom_error = "1.9.2"
document-features = { version = "0.2", optional = true }
jsonwebtoken = { version = "8.3.0", optional = true }
openidconnect = { version = "3.2.0", optional = true }
pbjson-types = { version = "0.5.1", optional = true }
prost = { version = "0.11", optional = true }
prost-types = { version = "0.11", optional = true }
reqwest = { version = "0.11.18", features = ["json", "rustls-tls"], default-features = false, optional = true }
Expand Down
22 changes: 22 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# buf.gen.yaml
version: v1
managed:
enabled: true
plugins:
- plugin: prost
out: src/api/generated
opt:
- compile_well_known_types
- extern_path=.google.protobuf=::pbjson_types
- plugin: tonic
out: src/api/generated
opt:
- compile_well_known_types
- extern_path=.google.protobuf=::pbjson_types
- no_server
- name: prost-crate
out: src/api/generated
strategy: all
opt:
- no_features
- include_file=mod.rs
62 changes: 0 additions & 62 deletions build.rs

This file was deleted.

1 change: 0 additions & 1 deletion external/googleapis
Submodule googleapis deleted from 3f11cd
1 change: 0 additions & 1 deletion external/grpc-gateway
Submodule grpc-gateway deleted from 40ee80
1 change: 0 additions & 1 deletion external/protoc-gen-validate
Submodule protoc-gen-validate deleted from 6f0b74
1 change: 0 additions & 1 deletion external/zitadel
Submodule zitadel deleted from 4378eb
9 changes: 9 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
proto_dir := "./src/api/generated"

default: clean generate-grpc

clean:
@rm -rf {{proto_dir}}

generate-grpc:
buf generate https://github.com/zitadel/zitadel.git --path ./proto/zitadel
115 changes: 0 additions & 115 deletions src/api/api.rs

This file was deleted.

Loading

0 comments on commit 31318a8

Please sign in to comment.