From e2d91e26d69bfbe1e64a15acce7d553e41705d1a Mon Sep 17 00:00:00 2001 From: Matthias Ahouansou Date: Mon, 6 May 2024 19:43:13 +0100 Subject: [PATCH] style: format all toml with taplo --- Cargo.toml | 140 +++++++++++++++++++++++++++-------------- book.toml | 5 +- conduit-example.toml | 4 +- engage.toml | 29 +++++---- nix/shell.nix | 10 ++- rust-toolchain.toml | 10 +-- rustfmt.toml | 2 +- taplo.toml | 24 +++++++ tests/test-config.toml | 10 +-- 9 files changed, 158 insertions(+), 76 deletions(-) create mode 100644 taplo.toml diff --git a/Cargo.toml b/Cargo.toml index 1ab0798f..3a5c2647 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,24 +1,22 @@ -# Keep alphabetically sorted [workspace.lints.rust] explicit_outlives_requirements = "warn" unused_qualifications = "warn" -# Keep alphabetically sorted [workspace.lints.clippy] cloned_instead_of_copied = "warn" dbg_macro = "warn" str_to_string = "warn" [package] -name = "conduit" -description = "A Matrix homeserver written in Rust" -license = "Apache-2.0" authors = ["timokoesters "] -homepage = "https://conduit.rs" -repository = "https://gitlab.com/famedly/conduit" -readme = "README.md" -version = "0.8.0-alpha" +description = "A Matrix homeserver written in Rust" edition = "2021" +homepage = "https://conduit.rs" +license = "Apache-2.0" +name = "conduit" +readme = "README.md" +repository = "https://gitlab.com/famedly/conduit" +version = "0.8.0-alpha" # See also `rust-toolchain.toml` rust-version = "1.78.0" @@ -30,14 +28,40 @@ workspace = true [dependencies] # Web framework -axum = { version = "0.6.18", default-features = false, features = ["form", "headers", "http1", "http2", "json", "matched-path"], optional = true } +axum = { version = "0.6.18", default-features = false, features = [ + "form", + "headers", + "http1", + "http2", + "json", + "matched-path", +], optional = true } axum-server = { version = "0.5.1", features = ["tls-rustls"] } tower = { version = "0.4.13", features = ["util"] } -tower-http = { version = "0.4.1", features = ["add-extension", "cors", "sensitive-headers", "trace", "util"] } +tower-http = { version = "0.4.1", features = [ + "add-extension", + "cors", + "sensitive-headers", + "trace", + "util", +] } # Used for matrix spec type definitions and helpers #ruma = { version = "0.4.0", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-pre-spec", "unstable-exhaustive-types"] } -ruma = { git = "https://github.com/ruma/ruma", rev = "5495b85aa311c2805302edb0a7de40399e22b397", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-msc2448", "unstable-msc3575", "unstable-exhaustive-types", "ring-compat", "unstable-unspecified" ] } +ruma = { git = "https://github.com/ruma/ruma", rev = "5495b85aa311c2805302edb0a7de40399e22b397", features = [ + "appservice-api-c", + "client-api", + "compat", + "federation-api", + "push-gateway-api-c", + "rand", + "ring-compat", + "state-res", + "unstable-exhaustive-types", + "unstable-msc2448", + "unstable-msc3575", + "unstable-unspecified", +] } #ruma = { git = "https://github.com/timokoesters/ruma", rev = "4ec9c69bb7e09391add2382b3ebac97b6e8f4c64", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-msc2448", "unstable-msc3575", "unstable-exhaustive-types", "ring-compat", "unstable-unspecified" ] } #ruma = { path = "../ruma/crates/ruma", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-msc2448", "unstable-msc3575", "unstable-exhaustive-types", "ring-compat", "unstable-unspecified" ] } @@ -65,11 +89,18 @@ rand = "0.8.5" rust-argon2 = "2" # Used to send requests hyper = "0.14.26" -reqwest = { version = "0.11.18", default-features = false, features = ["rustls-tls-native-roots", "socks"] } +reqwest = { version = "0.11.18", default-features = false, features = [ + "rustls-tls-native-roots", + "socks", +] } # Used for conduit::Error type thiserror = "1.0.40" # Used to generate thumbnails for images -image = { version = "0.25", default-features = false, features = ["jpeg", "png", "gif"] } +image = { version = "0.25", default-features = false, features = [ + "gif", + "jpeg", + "png", +] } # Used to encode server public key base64 = "0.22" # Used when hashing the state @@ -81,15 +112,17 @@ regex = "1.8.1" # jwt jsonwebtokens jsonwebtoken = "9.2.0" # Performance measurements -tracing = { version = "0.1.37", features = [] } -tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } -tracing-flame = "0.2.0" opentelemetry = { version = "0.18.0", features = ["rt-tokio"] } opentelemetry-jaeger = { version = "0.17.0", features = ["rt-tokio"] } +tracing = { version = "0.1.37", features = [] } +tracing-flame = "0.2.0" tracing-opentelemetry = "0.18.0" +tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } + lru-cache = "0.1.2" -rusqlite = { version = "0.31", optional = true, features = ["bundled"] } parking_lot = { version = "0.12.1", optional = true } +rusqlite = { version = "0.31", optional = true, features = ["bundled"] } + # crossbeam = { version = "0.8.2", optional = true } num_cpus = "1.15.0" threadpool = "1.8.1" @@ -102,7 +135,14 @@ thread_local = "1.1.7" hmac = "0.12.1" sha-1 = "0.10.1" # used for conduit's CLI and admin room command parsing -clap = { version = "4.3.0", default-features = false, features = ["std", "derive", "help", "usage", "error-context", "string"] } +clap = { version = "4.3.0", default-features = false, features = [ + "derive", + "error-context", + "help", + "std", + "string", + "usage", +] } futures-util = { version = "0.3.28", default-features = false } # Used for reading the configuration from conduit.toml & environment variables figment = { version = "0.10.8", features = ["env", "toml"] } @@ -110,34 +150,32 @@ figment = { version = "0.10.8", features = ["env", "toml"] } # Validating urls in config url = { version = "2", features = ["serde"] } -tikv-jemallocator = { version = "0.5.0", features = ["unprefixed_malloc_on_supported_platforms"], optional = true } async-trait = "0.1.68" +tikv-jemallocator = { version = "0.5.0", features = [ + "unprefixed_malloc_on_supported_platforms", +], optional = true } sd-notify = { version = "0.4.1", optional = true } [dependencies.rocksdb] +features = ["lz4", "multi-threaded-cf", "zstd"] +optional = true package = "rust-rocksdb" version = "0.25" -optional = true -features = [ - "multi-threaded-cf", - "zstd", - "lz4", -] [target.'cfg(unix)'.dependencies] nix = { version = "0.28", features = ["resource"] } [features] -default = ["conduit_bin", "backend_sqlite", "backend_rocksdb", "systemd"] +default = ["backend_rocksdb", "backend_sqlite", "conduit_bin", "systemd"] #backend_sled = ["sled"] -backend_persy = ["persy", "parking_lot"] +backend_persy = ["parking_lot", "persy"] backend_sqlite = ["sqlite"] #backend_heed = ["heed", "crossbeam"] backend_rocksdb = ["rocksdb"] -jemalloc = ["tikv-jemallocator"] -sqlite = ["rusqlite", "parking_lot", "tokio/signal"] conduit_bin = ["axum"] +jemalloc = ["tikv-jemallocator"] +sqlite = ["parking_lot", "rusqlite", "tokio/signal"] systemd = ["sd-notify"] [[bin]] @@ -150,35 +188,45 @@ name = "conduit" path = "src/lib.rs" [package.metadata.deb] -name = "matrix-conduit" -maintainer = "Paul van Tilburg " +assets = [ + [ + "README.md", + "usr/share/doc/matrix-conduit/", + "644", + ], + [ + "debian/README.md", + "usr/share/doc/matrix-conduit/README.Debian", + "644", + ], + [ + "target/release/conduit", + "usr/sbin/matrix-conduit", + "755", + ], +] +conf-files = ["/etc/matrix-conduit/conduit.toml"] copyright = "2020, Timo Kösters " -license-file = ["LICENSE", "3"] depends = "$auto, ca-certificates" extended-description = """\ A fast Matrix homeserver that is optimized for smaller, personal servers, \ instead of a server that has high scalability.""" -section = "net" -priority = "optional" -assets = [ - ["debian/README.md", "usr/share/doc/matrix-conduit/README.Debian", "644"], - ["README.md", "usr/share/doc/matrix-conduit/", "644"], - ["target/release/conduit", "usr/sbin/matrix-conduit", "755"], -] -conf-files = [ - "/etc/matrix-conduit/conduit.toml" -] +license-file = ["LICENSE", "3"] +maintainer = "Paul van Tilburg " maintainer-scripts = "debian/" +name = "matrix-conduit" +priority = "optional" +section = "net" systemd-units = { unit-name = "matrix-conduit" } [profile.dev] -lto = 'off' incremental = true +lto = 'off' [profile.release] -lto = 'thin' +codegen-units = 32 incremental = true -codegen-units=32 +lto = 'thin' # If you want to make flamegraphs, enable debug info: # debug = true diff --git a/book.toml b/book.toml index 700ecda5..a80adaba 100644 --- a/book.toml +++ b/book.toml @@ -1,22 +1,21 @@ [book] -title = "Conduit" description = "Conduit is a simple, fast and reliable chat server for the Matrix protocol" language = "en" multilingual = false src = "docs" +title = "Conduit" [build] build-dir = "public" create-missing = true [output.html] -git-repository-url = "https://gitlab.com/famedly/conduit" edit-url-template = "https://gitlab.com/famedly/conduit/-/edit/next/{path}" git-repository-icon = "fa-git-square" +git-repository-url = "https://gitlab.com/famedly/conduit" [output.html.search] limit-results = 15 [output.html.code.hidelines] json = "~" - diff --git a/conduit-example.toml b/conduit-example.toml index ef7bd182..74cbb074 100644 --- a/conduit-example.toml +++ b/conduit-example.toml @@ -22,9 +22,9 @@ # YOU NEED TO EDIT THIS #server_name = "your.server.name" +database_backend = "rocksdb" # This is the only directory where Conduit will save its data database_path = "/var/lib/matrix-conduit/" -database_backend = "rocksdb" # The port Conduit will be running on. You need to set up a reverse proxy in # your web server (e.g. apache or nginx), so all requests to /_matrix on port @@ -44,8 +44,8 @@ allow_registration = true # - Start the line with '#' to remove the condition registration_token = "" -allow_federation = true allow_check_for_updates = true +allow_federation = true # Enable the display name lightning bolt on registration. enable_lightning_bolt = true diff --git a/engage.toml b/engage.toml index cb284167..9dc2b31c 100644 --- a/engage.toml +++ b/engage.toml @@ -1,48 +1,48 @@ interpreter = ["bash", "-euo", "pipefail", "-c"] [[task]] -name = "engage" group = "versions" +name = "engage" script = "engage --version" [[task]] -name = "rustc" group = "versions" +name = "rustc" script = "rustc --version" [[task]] -name = "cargo" group = "versions" +name = "cargo" script = "cargo --version" [[task]] -name = "cargo-fmt" group = "versions" +name = "cargo-fmt" script = "cargo fmt --version" [[task]] -name = "rustdoc" group = "versions" +name = "rustdoc" script = "rustdoc --version" [[task]] -name = "cargo-clippy" group = "versions" +name = "cargo-clippy" script = "cargo clippy -- --version" [[task]] -name = "lychee" group = "versions" +name = "lychee" script = "lychee --version" [[task]] -name = "cargo-fmt" group = "lints" +name = "cargo-fmt" script = "cargo fmt --check -- --color=always" [[task]] -name = "cargo-doc" group = "lints" +name = "cargo-doc" script = """ RUSTDOCFLAGS="-D warnings" cargo doc \ --workspace \ @@ -52,18 +52,23 @@ RUSTDOCFLAGS="-D warnings" cargo doc \ """ [[task]] -name = "cargo-clippy" group = "lints" +name = "cargo-clippy" script = "cargo clippy --workspace --all-targets --color=always -- -D warnings" [[task]] -name = "lychee" group = "lints" +name = "taplo-fmt" +script = "taplo fmt --check --colors always" + +[[task]] +group = "lints" +name = "lychee" script = "lychee --offline docs" [[task]] -name = "cargo" group = "tests" +name = "cargo" script = """ cargo test \ --workspace \ diff --git a/nix/shell.nix b/nix/shell.nix index 8cfc1c44..bd070fe6 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -10,6 +10,7 @@ , mkShell , olm , system +, taplo , toolchain }: @@ -29,10 +30,15 @@ mkShell { # `$PATH` will have stable rustfmt instead. inputs.fenix.packages.${system}.latest.rustfmt - # Keep sorted - engage + # rust itself toolchain + # CI tests + engage + + # format toml files + taplo + # Needed for producing Debian packages cargo-deb diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 811d9cef..3ffd3a5e 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -12,11 +12,11 @@ [toolchain] channel = "1.78.0" components = [ - # For rust-analyzer - "rust-src", + # For rust-analyzer + "rust-src", ] targets = [ - "x86_64-unknown-linux-gnu", - "x86_64-unknown-linux-musl", - "aarch64-unknown-linux-musl", + "aarch64-unknown-linux-musl", + "x86_64-unknown-linux-gnu", + "x86_64-unknown-linux-musl", ] diff --git a/rustfmt.toml b/rustfmt.toml index 739b454f..2f990167 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,2 +1,2 @@ +imports_granularity = "Crate" unstable_features = true -imports_granularity="Crate" diff --git a/taplo.toml b/taplo.toml new file mode 100644 index 00000000..04780b4a --- /dev/null +++ b/taplo.toml @@ -0,0 +1,24 @@ +exclude = [".**/*.toml"] +include = ["**/*.toml"] +[formatting] +reorder_arrays = true +reorder_keys = true + +# Prevent breaking command and argument order +[[rule]] +include = ["engage.toml"] +# https://github.com/tamasfe/taplo/issues/608 +#keys = ["interpreter"] + +[rule.formatting] +reorder_arrays = false + +# Prevent breaking license file order +[[rule]] +include = ["Cargo.toml"] +# https://github.com/tamasfe/taplo/issues/608 +# keys = ["package.metadata.deb.license-file", "package.metadata.deb.assets"] +keys = ["package.metadata.deb", "package.metadata.deb.assets"] + +[rule.formatting] +reorder_arrays = false diff --git a/tests/test-config.toml b/tests/test-config.toml index c4666878..10db1408 100644 --- a/tests/test-config.toml +++ b/tests/test-config.toml @@ -7,9 +7,9 @@ server_name = "localhost" database_path = "/tmp" # All the other settings are left at their defaults: -port = 6167 -max_request_size = 20_000_000 -allow_registration = true -trusted_servers = ["matrix.org"] address = "127.0.0.1" -proxy = "none" \ No newline at end of file +allow_registration = true +max_request_size = 20_000_000 +port = 6167 +proxy = "none" +trusted_servers = ["matrix.org"]