ci: pre-commit configuration and hooks (#261)

* feat: adds pre-commit config and hooks

* refactor: sort all Cargo.toml by cargo-sort

* ci: adds conventional-pre-commit hook to pre-commit

* fix: remove .pre-commit-hooks.yaml

* fix: readme

* Update .pre-commit-config.yaml

Co-authored-by: Lei, Huang <6406592+v0y4g3r@users.noreply.github.com>

* ci: move clippy hook to push stage

* docs: install pre-push github hook

Co-authored-by: Lei, Huang <6406592+v0y4g3r@users.noreply.github.com>
This commit is contained in:
dennis zhuang
2022-09-15 11:30:08 +08:00
committed by GitHub
parent 8400f8dfd4
commit c8cb705d9e
30 changed files with 147 additions and 106 deletions

21
.pre-commit-config.yaml Normal file
View File

@@ -0,0 +1,21 @@
repos:
- repo: https://github.com/compilerla/conventional-pre-commit
rev: 47923ce11be4a936cd216d427d985dd342adb751
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
- repo: https://github.com/DevinR528/cargo-sort
rev: e6a795bc6b2c0958f9ef52af4863bbd7cc17238f
hooks:
- id: cargo-sort
args: ["--workspace"]
- repo: https://github.com/doublify/pre-commit-rust
rev: v1.0
hooks:
- id: fmt
- id: clippy
args: ["--workspace", "--all-targets", "--", "-D", "warnings", "-D", "clippy::print_stdout", "-D", "clippy::print_stderr"]
stages: [push]
- id: cargo-check

View File

@@ -3,6 +3,7 @@ members = [
"src/api",
"src/catalog",
"src/client",
"src/cmd",
"src/common/base",
"src/common/error",
"src/common/function",
@@ -13,7 +14,6 @@ members = [
"src/common/runtime",
"src/common/telemetry",
"src/common/time",
"src/cmd",
"src/datanode",
"src/datatypes",
"src/frontend",

View File

@@ -150,3 +150,34 @@ cargo run -- --log-dir=logs --log-level=debug frontend start -c ./config/fronten
3 rows in set (0.01 sec)
```
You can delete your data by removing `/tmp/greptimedb`.
## Contribute
1. [Install rust](https://www.rust-lang.org/tools/install)
2. [Install `pre-commit`](https://pre-commit.com/#plugins) for run hooks on every commit automatically such as `cargo fmt` etc.
```
$ pip install pre-commit
or
$ brew install pre-commit
$
```
3. Install the git hook scripts:
```
$ pre-commit install
pre-commit installed at .git/hooks/pre-commit
$ pre-commit install --hook-type commit-msg
pre-commit installed at .git/hooks/commit-msg
$ pre-commit install --hook-type pre-push
pre-commit installed at .git/hooks/pre-pus
```
now `pre-commit` will run automatically on `git commit`.
4. Check out branch from `develop` and make your contribution. Follow the [style guide](https://github.com/GreptimeTeam/docs/blob/main/style-guide/zh.md). Create a PR when you are ready, feel free and have fun!

View File

@@ -2,7 +2,6 @@
name = "api"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View File

@@ -2,12 +2,11 @@
name = "catalog"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
async-trait = "0.1"
async-stream = "0.3"
async-trait = "0.1"
common-error = { path = "../common/error" }
common-query = { path = "../common/query" }
common-recordbatch = { path = "../common/recordbatch" }

View File

@@ -2,7 +2,6 @@
name = "client"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View File

@@ -10,7 +10,7 @@ path = "src/bin/greptime.rs"
[dependencies]
clap = { version = "3.1", features = ["derive"] }
common-error = { path = "../common/error" }
common-telemetry = { path = "../common/telemetry", features = ["deadlock_detection"]}
common-telemetry = { path = "../common/telemetry", features = ["deadlock_detection"] }
datanode = { path = "../datanode" }
frontend = { path = "../frontend" }
futures = "0.3"

View File

@@ -2,7 +2,6 @@
name = "common-error"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View File

@@ -3,18 +3,13 @@ edition = "2021"
name = "common-function"
version = "0.1.0"
[dependencies.arrow]
features = ["io_csv", "io_json", "io_parquet", "io_parquet_compression", "io_ipc", "ahash", "compute", "serde_types"]
package = "arrow2"
version = "0.10"
[dependencies]
arc-swap = "1.0"
chrono-tz = "0.6"
common-error = { path = "../error" }
common-query = { path = "../query" }
common-function-macro = { path = "../function-macro" }
datafusion-common = { git = "https://github.com/apache/arrow-datafusion.git" , branch = "arrow2" }
common-query = { path = "../query" }
datafusion-common = { git = "https://github.com/apache/arrow-datafusion.git", branch = "arrow2" }
datatypes = { path = "../../datatypes" }
libc = "0.2"
num = "0.4"
@@ -24,6 +19,11 @@ paste = "1.0"
snafu = { version = "0.7", features = ["backtraces"] }
statrs = "0.15"
[dependencies.arrow]
features = ["io_csv", "io_json", "io_parquet", "io_parquet_compression", "io_ipc", "ahash", "compute", "serde_types"]
package = "arrow2"
version = "0.10"
[dev-dependencies]
ron = "0.7"
serde = {version = "1.0", features = ["derive"]}
serde = { version = "1.0", features = ["derive"] }

View File

@@ -3,10 +3,6 @@ name = "common-query"
version = "0.1.0"
edition = "2021"
[dependencies.arrow]
package = "arrow2"
version="0.10"
[dependencies]
common-error = { path = "../error" }
common-recordbatch = { path = "../recordbatch" }
@@ -18,6 +14,10 @@ datatypes = { path = "../../datatypes" }
snafu = { version = "0.7", features = ["backtraces"] }
statrs = "0.15"
[dependencies.arrow]
package = "arrow2"
version = "0.10"
[dev-dependencies]
tokio = { version = "1.0", features = ["full"] }
common-base = { path = "../base" }
tokio = { version = "1.0", features = ["full"] }

View File

@@ -5,8 +5,8 @@ edition = "2021"
[dependencies]
common-error = { path = "../error" }
datafusion = { git = "https://github.com/apache/arrow-datafusion.git" , branch = "arrow2", features = ["simd"]}
datafusion-common = { git = "https://github.com/apache/arrow-datafusion.git" , branch = "arrow2"}
datafusion = { git = "https://github.com/apache/arrow-datafusion.git", branch = "arrow2", features = ["simd"] }
datafusion-common = { git = "https://github.com/apache/arrow-datafusion.git", branch = "arrow2" }
datatypes = { path = "../../datatypes" }
futures = "0.3"
paste = "1.0"

View File

@@ -3,7 +3,6 @@ name = "common-runtime"
version = "0.1.0"
edition = "2021"
[dependencies]
common-error = { path = "../error" }
common-telemetry = { path = "../telemetry" }

View File

@@ -2,12 +2,11 @@
name = "common-telemetry"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
console = ["console-subscriber"]
deadlock_detection=["parking_lot"]
deadlock_detection =["parking_lot"]
[dependencies]
backtrace = "0.3"

View File

@@ -2,7 +2,6 @@
name = "common-time"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View File

@@ -3,13 +3,6 @@ name = "datanode"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies.arrow]
package = "arrow2"
version = "0.10"
features = ["io_csv", "io_json", "io_parquet", "io_parquet_compression", "io_ipc", "ahash", "compute", "serde_types"]
[features]
default = ["python"]
python = [
@@ -49,20 +42,26 @@ store-api = { path = "../store-api" }
table = { path = "../table" }
table-engine = { path = "../table-engine", features = ["test"] }
tokio = { version = "1.18", features = ["full"] }
tonic = "0.8"
tokio-stream = { version = "0.1.8", features = ["net"] }
tower = { version = "0.4", features = ["full"]}
tower-http = { version ="0.3", features = ["full"]}
tonic = "0.8"
tower = { version = "0.4", features = ["full"] }
tower-http = { version = "0.3", features = ["full"] }
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies.arrow]
package = "arrow2"
version = "0.10"
features = ["io_csv", "io_json", "io_parquet", "io_parquet_compression", "io_ipc", "ahash", "compute", "serde_types"]
[dev-dependencies]
axum-test-helper = "0.1"
client = { path = "../client" }
common-query = { path = "../common/query" }
datafusion = { git = "https://github.com/apache/arrow-datafusion.git" , branch = "arrow2", features = ["simd"]}
datafusion = { git = "https://github.com/apache/arrow-datafusion.git", branch = "arrow2", features = ["simd"] }
datafusion-common = { git = "https://github.com/apache/arrow-datafusion.git", branch = "arrow2" }
tempdir = "0.3"
[dev-dependencies.arrow]
package = "arrow2"
version="0.10"
version = "0.10"
features = ["io_csv", "io_json", "io_parquet", "io_parquet_compression", "io_ipc", "ahash", "compute", "serde_types"]

View File

@@ -7,15 +7,10 @@ edition = "2021"
default = []
test = []
[dependencies.arrow]
package = "arrow2"
version = "0.10"
features = ["io_csv", "io_json", "io_parquet", "io_parquet_compression", "io_ipc", "ahash", "compute", "serde_types"]
[dependencies]
common-base = { path = "../common/base" }
common-time = { path = "../common/time" }
common-error = { path = "../common/error" }
common-time = { path = "../common/time" }
datafusion-common = { git = "https://github.com/apache/arrow-datafusion.git", branch = "arrow2" }
enum_dispatch = "0.3"
num = "0.4"
@@ -25,3 +20,8 @@ paste = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
snafu = { version = "0.7", features = ["backtraces"] }
[dependencies.arrow]
package = "arrow2"
version = "0.10"
features = ["io_csv", "io_json", "io_parquet", "io_parquet_compression", "io_ipc", "ahash", "compute", "serde_types"]

View File

@@ -0,0 +1 @@

View File

@@ -3,11 +3,6 @@ name = "frontend"
version = "0.1.0"
edition = "2021"
[dependencies.arrow]
package = "arrow2"
version = "0.10"
features = ["io_csv", "io_json", "io_parquet", "io_parquet_compression", "io_ipc", "ahash", "compute", "serde_types"]
[dependencies]
api = { path = "../api" }
async-stream = "0.3"
@@ -23,17 +18,22 @@ common-telemetry = { path = "../common/telemetry" }
common-time = { path = "../common/time" }
datatypes = { path = "../datatypes" }
query = { path = "../query" }
snafu = { version = "0.7", features = ["backtraces"] }
tokio = { version = "1.18", features = ["full"] }
serde = "1.0"
servers = { path = "../servers" }
snafu = { version = "0.7", features = ["backtraces"] }
sql = { path = "../sql" }
tokio = { version = "1.18", features = ["full"] }
[dependencies.arrow]
package = "arrow2"
version = "0.10"
features = ["io_csv", "io_json", "io_parquet", "io_parquet_compression", "io_ipc", "ahash", "compute", "serde_types"]
[dev-dependencies]
datanode = { path = "../datanode" }
datafusion = { git = "https://github.com/apache/arrow-datafusion.git" , branch = "arrow2", features = ["simd"]}
datafusion = { git = "https://github.com/apache/arrow-datafusion.git", branch = "arrow2", features = ["simd"] }
datafusion-common = { git = "https://github.com/apache/arrow-datafusion.git", branch = "arrow2" }
datanode = { path = "../datanode" }
futures = "0.3"
tonic = "0.8"
tempdir = "0.3"
tonic = "0.8"
tower = "0.4"

View File

@@ -13,7 +13,7 @@ byteorder = "1.4"
bytes = "1.1"
common-base = { path = "../common/base" }
common-error = { path = "../common/error" }
common-runtime = {path = "../common/runtime"}
common-runtime = { path = "../common/runtime" }
common-telemetry = { path = "../common/telemetry" }
crc = "3.0"
futures = "0.3"

View File

@@ -2,7 +2,6 @@
name = "logical-plans"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View File

@@ -2,11 +2,10 @@
name = "object-store"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
futures = { version = "0.3"}
futures = { version = "0.3" }
opendal = "0.9"
tokio = { version = "1.0", features = ["full"] }

View File

@@ -3,11 +3,6 @@ name = "query"
version = "0.1.0"
edition = "2021"
[dependencies.arrow]
package = "arrow2"
version = "0.10"
features = ["io_csv", "io_json", "io_parquet", "io_parquet_compression", "io_ipc", "ahash", "compute", "serde_types"]
[dependencies]
arc-swap = "1.0"
async-trait = "0.1"
@@ -30,12 +25,17 @@ sql = { path = "../sql" }
table = { path = "../table" }
tokio = "1.0"
[dependencies.arrow]
package = "arrow2"
version = "0.10"
features = ["io_csv", "io_json", "io_parquet", "io_parquet_compression", "io_ipc", "ahash", "compute", "serde_types"]
[dev-dependencies]
approx_eq = "0.1"
common-function-macro = { path = "../common/function-macro" }
format_num = "0.1"
num = "0.4"
num-traits = "0.2"
format_num = "0.1"
paste = "1.0"
rand = "0.8"
statrs = "0.15"

View File

@@ -0,0 +1 @@

View File

@@ -21,37 +21,37 @@ python = [
[dependencies]
async-trait = "0.1"
catalog = { path = "../catalog" }
common-error = {path = "../common/error"}
common-error = { path = "../common/error" }
common-function = { path = "../common/function" }
common-query = {path = "../common/query"}
common-recordbatch = {path = "../common/recordbatch" }
common-query = { path = "../common/query" }
common-recordbatch = { path = "../common/recordbatch" }
common-telemetry = { path = "../common/telemetry" }
common-time = { path = "../common/time" }
console = "0.15"
datafusion = {git = "https://github.com/apache/arrow-datafusion.git", branch = "arrow2", optional = true}
datafusion-common = {git = "https://github.com/apache/arrow-datafusion.git", branch = "arrow2"}
datafusion-expr = {git = "https://github.com/apache/arrow-datafusion.git", branch = "arrow2", optional = true}
datafusion-physical-expr = {git = "https://github.com/apache/arrow-datafusion.git", branch = "arrow2", optional = true}
datatypes = {path = "../datatypes"}
futures-util = "0.3"
datafusion = { git = "https://github.com/apache/arrow-datafusion.git", branch = "arrow2", optional = true }
datafusion-common = { git = "https://github.com/apache/arrow-datafusion.git", branch = "arrow2" }
datafusion-expr = { git = "https://github.com/apache/arrow-datafusion.git", branch = "arrow2", optional = true }
datafusion-physical-expr = { git = "https://github.com/apache/arrow-datafusion.git", branch = "arrow2", optional = true }
datatypes = { path = "../datatypes" }
futures = "0.3"
futures-util = "0.3"
paste = { version = "1.0", optional = true }
query = { path = "../query" }
rustpython-ast = {git = "https://github.com/RustPython/RustPython", optional = true, rev = "02a1d1d"}
rustpython-bytecode = {git = "https://github.com/RustPython/RustPython", optional = true, rev = "02a1d1d"}
rustpython-compiler = {git = "https://github.com/RustPython/RustPython", optional = true, rev = "02a1d1d"}
rustpython-compiler-core = {git = "https://github.com/RustPython/RustPython", optional = true, rev = "02a1d1d"}
rustpython-parser = {git = "https://github.com/RustPython/RustPython", optional = true, rev = "02a1d1d"}
rustpython-vm = {git = "https://github.com/RustPython/RustPython", optional = true, rev = "02a1d1d"}
paste = { version = "1.0", optional = true}
snafu = {version = "0.7", features = ["backtraces"]}
rustpython-ast = { git = "https://github.com/RustPython/RustPython", optional = true, rev = "02a1d1d" }
rustpython-bytecode = { git = "https://github.com/RustPython/RustPython", optional = true, rev = "02a1d1d" }
rustpython-compiler = { git = "https://github.com/RustPython/RustPython", optional = true, rev = "02a1d1d" }
rustpython-compiler-core = { git = "https://github.com/RustPython/RustPython", optional = true, rev = "02a1d1d" }
rustpython-parser = { git = "https://github.com/RustPython/RustPython", optional = true, rev = "02a1d1d" }
rustpython-vm = { git = "https://github.com/RustPython/RustPython", optional = true, rev = "02a1d1d" }
snafu = { version = "0.7", features = ["backtraces"] }
sql = { path = "../sql" }
tokio = { version = "1.0", features = ["full"] }
table = { path = "../table" }
tokio = { version = "1.0", features = ["full"] }
[dev-dependencies]
log-store = { path = "../log-store" }
ron = "0.7"
serde = {version = "1.0", features = ["derive"]}
serde = { version = "1.0", features = ["derive"] }
storage = { path = "../storage" }
table-engine = { path = "../table-engine", features = ["test"] }
tempdir = "0.3"

View File

@@ -24,16 +24,16 @@ query = { path = "../query" }
serde = "1.0"
serde_json = "1.0"
snafu = { version = "0.7", features = ["backtraces"] }
tonic = "0.8"
tokio = { version = "1.20", features = ["full"] }
tokio-stream = { version = "0.1", features = ["net"] }
tower = { version = "0.4", features = ["full"]}
tower-http = { version ="0.3", features = ["full"]}
tonic = "0.8"
tower = { version = "0.4", features = ["full"] }
tower-http = { version = "0.3", features = ["full"] }
[dev-dependencies]
common-base = { path = "../common/base" }
catalog = { path = "../catalog" }
common-base = { path = "../common/base" }
mysql_async = "0.30"
rand = "0.8"
test-util = { path = "../../test-util" }
script = { path = "../script", features = ["python"] }
test-util = { path = "../../test-util" }

View File

@@ -2,7 +2,6 @@
name = "sql"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View File

@@ -2,7 +2,6 @@
name = "storage"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
@@ -25,17 +24,17 @@ object-store = { path = "../object-store" }
paste = "1.0"
planus = "0.2"
prost = "0.11"
regex = "1.5"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
snafu = { version = "0.7", features = ["backtraces"] }
store-api = { path = "../store-api" }
regex = "1.5"
tokio = { version = "1.18", features = ["full"] }
tonic = "0.8"
uuid = { version = "1.1" , features=["v4"]}
uuid = { version = "1.1", features = ["v4"] }
[dev-dependencies]
atomic_float="0.1"
atomic_float = "0.1"
criterion = "0.3"
datatypes = { path = "../datatypes", features = ["test"] }
rand = "0.8"

View File

@@ -2,7 +2,6 @@
name = "store-api"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
@@ -12,11 +11,11 @@ common-base = { path = "../common/base" }
common-error = { path = "../common/error" }
common-time = { path = "../common/time" }
datatypes = { path = "../datatypes" }
derive_builder = "0.11"
futures = "0.3"
object-store = { path = "../object-store" }
serde = { version = "1.0", features = ["derive"] }
snafu = { version = "0.7", features = ["backtraces"] }
derive_builder = "0.11"
[dev-dependencies]
async-stream = "0.3"

View File

@@ -6,11 +6,11 @@ edition = "2021"
[dependencies]
async-trait = "0.1"
chrono = { version = "0.4", features = ["serde"] }
common-error = {path = "../common/error" }
common-query = {path = "../common/query" }
common-recordbatch = {path = "../common/recordbatch" }
datafusion = { git = "https://github.com/apache/arrow-datafusion.git" , branch = "arrow2", features = ["simd"]}
datafusion-common = { git = "https://github.com/apache/arrow-datafusion.git" , branch = "arrow2"}
common-error = { path = "../common/error" }
common-query = { path = "../common/query" }
common-recordbatch = { path = "../common/recordbatch" }
datafusion = { git = "https://github.com/apache/arrow-datafusion.git", branch = "arrow2", features = ["simd"] }
datafusion-common = { git = "https://github.com/apache/arrow-datafusion.git", branch = "arrow2" }
datatypes = { path = "../datatypes" }
derive_builder = "0.11"
futures = "0.3"

View File

@@ -3,18 +3,18 @@ name = "test-util"
version = "0.1.0"
edition = "2021"
[dependencies.arrow]
package = "arrow2"
version="0.10"
features = ["io_csv", "io_json", "io_parquet", "io_parquet_compression", "io_ipc", "ahash", "compute", "serde_types"]
[dependencies]
async-trait = "0.1"
common-query = { path = "../src/common/query" }
common-recordbatch = { path = "../src/common/recordbatch" }
datafusion = { git = "https://github.com/apache/arrow-datafusion.git" , branch = "arrow2", features = ["simd"] }
datafusion = { git = "https://github.com/apache/arrow-datafusion.git", branch = "arrow2", features = ["simd"] }
datatypes = { path = "../src/datatypes" }
futures = "0.3"
snafu = { version = "0.7", features = ["backtraces"] }
table = { path = "../src/table" }
tokio = { version = "1.20", features = ["full"] }
[dependencies.arrow]
package = "arrow2"
version = "0.10"
features = ["io_csv", "io_json", "io_parquet", "io_parquet_compression", "io_ipc", "ahash", "compute", "serde_types"]