Skip to content

Commit

Permalink
feat: Add vendored support (#411)
Browse files Browse the repository at this point in the history
* feat: Add vendored support

Signed-off-by: Xuanwo <[email protected]>

* Use diff=false instead

Signed-off-by: Xuanwo <[email protected]>

* try fix

Signed-off-by: Xuanwo <[email protected]>

* Fix typo

Signed-off-by: Xuanwo <[email protected]>

* Use vendor by default

Signed-off-by: Xuanwo <[email protected]>

* Add check

Signed-off-by: Xuanwo <[email protected]>

---------

Signed-off-by: Xuanwo <[email protected]>
  • Loading branch information
Xuanwo authored Jul 21, 2023
1 parent 2761270 commit 8b3ada2
Show file tree
Hide file tree
Showing 34 changed files with 12,722 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/generated/ diff=false
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ jobs:
uses: Swatinem/[email protected]
- name: make check
run: make check
- name: Catch unexpected changes in the generated code
run: |
git diff --exit-code
unit-test:
name: unit test
Expand Down
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ integration-tests = []
[lib]
name = "tikv_client"

[workspace]
members = [
".",
"proto-build",
]

[dependencies]
async-recursion = "0.3"
async-trait = "0.1"
Expand All @@ -39,7 +45,6 @@ tokio = { version = "1", features = ["sync", "rt-multi-thread", "macros"] }
tonic = { version = "0.9", features = ["tls"] }

[dev-dependencies]
tempfile = "3.6"
clap = "2"
env_logger = "0.10"
fail = { version = "0.4", features = ["failpoints"] }
Expand All @@ -51,14 +56,9 @@ reqwest = { version = "0.11", default-features = false, features = [
serde_json = "1"
serial_test = "0.5.0"
simple_logger = "1"
tempfile = "3.6"
tokio = { version = "1", features = ["sync", "rt-multi-thread", "macros"] }

[build-dependencies]
glob = "0.3"
tonic-build = "0.9"
# Suppress doctest bug (https://stackoverflow.com/questions/66074003/how-to-turn-off-cargo-doc-test-and-compile-for-a-specific-module-in-rust)
tonic-disable-doctest = "0.1.0"

[[test]]
name = "failpoint_tests"
path = "tests/failpoint_tests.rs"
Expand Down
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ INTEGRATION_TEST_ARGS := --features "integration-tests"

default: check

check:
generate:
cargo run -p tikv-client-proto-build

check: generate
cargo check --all --all-targets --features "${ALL_FEATURES}"
cargo fmt -- --check
cargo clippy --all-targets --features "${ALL_FEATURES}" -- -D clippy::all

unit-test:
unit-test: generate
cargo test --all --no-default-features

integration-test:
integration-test: generate
cargo test txn_ --all ${INTEGRATION_TEST_ARGS} -- --nocapture
cargo test raw_ --all ${INTEGRATION_TEST_ARGS} -- --nocapture
cargo test misc_ --all ${INTEGRATION_TEST_ARGS} -- --nocapture
Expand All @@ -32,7 +35,7 @@ doc:
tiup:
tiup playground nightly --mode tikv-slim --kv 3 --without-monitor --kv.config $(shell pwd)/config/tikv.toml --pd.config $(shell pwd)/config/pd.toml &

all: check doc test
all: generate check doc test

clean:
cargo clean
Expand Down
17 changes: 17 additions & 0 deletions proto-build/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "tikv-client-proto-build"
version = "0.0.0"
publish = false

keywords = ["TiKV", "KV", "distributed-systems"]
license = "Apache-2.0"
authors = ["The TiKV Project Authors"]
repository = "https://github.com/tikv/client-rust"
description = "The Rust language implementation of TiKV client."
edition = "2021"

[dependencies]
glob = "0.3"
tonic-build = "0.9"
# Suppress doctest bug (https://stackoverflow.com/questions/66074003/how-to-turn-off-cargo-doc-test-and-compile-for-a-specific-module-in-rust)
tonic-disable-doctest = "0.1.0"
8 changes: 5 additions & 3 deletions build.rs → proto-build/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0.

use tonic_disable_doctest::BuilderEx;
// Copyright 2023 TiKV Project Authors. Licensed under Apache-2.0.

fn main() {
use tonic_disable_doctest::BuilderEx;

tonic_build::configure()
.disable_doctests_for_types([".google.api.HttpRule"])
.emit_rerun_if_changed(false)
.build_server(false)
.include_file("mod.rs")
.out_dir("src/generated")
.compile(
&glob::glob("proto/*.proto")
.unwrap()
Expand Down
Loading

0 comments on commit 8b3ada2

Please sign in to comment.