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: Add vendored support #411

Merged
merged 7 commits into from
Jul 21, 2023
Merged
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/generated/ diff=false
Xuanwo marked this conversation as resolved.
Show resolved Hide resolved
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, it's interesting to know why the auto rerun is disabled.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, it's interesting to know why the auto rerun is disabled.

After this change, we are running codegen in a new bin instead of build.rs, the rerun hint for cargo is not working anymore. Instead, they just print to the console.

.build_server(false)
.include_file("mod.rs")
.out_dir("src/generated")
.compile(
&glob::glob("proto/*.proto")
.unwrap()
Expand Down
Loading