diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 259d42e16..93a07beea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -110,7 +110,7 @@ jobs: - uses: taiki-e/install-action@v2 with: - tool: just,fd-find,cargo-machete,cargo-udeps + tool: just,fd-find,cargo-machete,cargo-udeps,cargo-sort - name: restore build & cargo cache uses: Swatinem/rust-cache@v2 diff --git a/Cargo.toml b/Cargo.toml index dcc271b0b..e18b1d650 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,16 +1,13 @@ [workspace] resolver = "2" -members = [ - "crates/bin/*", - "crates/lib/*", -] +members = ["crates/bin/*", "crates/lib/*"] default-members = [ - "crates/bin/docs_rs_admin", - "crates/bin/docs_rs_builder", - "crates/bin/docs_rs_watcher", - "crates/bin/docs_rs_web", + "crates/bin/docs_rs_admin", + "crates/bin/docs_rs_builder", + "crates/bin/docs_rs_watcher", + "crates/bin/docs_rs_web", ] exclude = [ @@ -23,7 +20,7 @@ exclude = [ ] [workspace.dependencies] -anyhow = { version = "1.0.42", features = ["backtrace"]} +anyhow = { version = "1.0.42", features = ["backtrace"] } askama = "0.15.1" async-stream = "0.3.5" axum-extra = { version = "0.12.0", features = ["typed-header", "routing", "middleware"] } diff --git a/crates/bin/docs_rs_builder/Cargo.toml b/crates/bin/docs_rs_builder/Cargo.toml index e63e6bb59..e7a703b5a 100644 --- a/crates/bin/docs_rs_builder/Cargo.toml +++ b/crates/bin/docs_rs_builder/Cargo.toml @@ -16,7 +16,7 @@ docs_rs_config = { path = "../../lib/docs_rs_config" } docs_rs_context = { path = "../../lib/docs_rs_context" } docs_rs_database = { path = "../../lib/docs_rs_database" } docs_rs_env_vars = { path = "../../lib/docs_rs_env_vars" } -docs_rs_fastly= { path = "../../lib/docs_rs_fastly" } +docs_rs_fastly = { path = "../../lib/docs_rs_fastly" } docs_rs_logging = { path = "../../lib/docs_rs_logging" } docs_rs_opentelemetry = { path = "../../lib/docs_rs_opentelemetry" } docs_rs_registry_api = { path = "../../lib/docs_rs_registry_api" } @@ -45,7 +45,7 @@ docs_rs_build_queue = { path = "../../lib/docs_rs_build_queue", features = ["tes docs_rs_config = { path = "../../lib/docs_rs_config", features = ["testing"] } docs_rs_context = { path = "../../lib/docs_rs_context", features = ["testing"] } docs_rs_database = { path = "../../lib/docs_rs_database", features = ["testing"] } -docs_rs_fastly= { path = "../../lib/docs_rs_fastly", features = ["testing"] } +docs_rs_fastly = { path = "../../lib/docs_rs_fastly", features = ["testing"] } docs_rs_headers = { path = "../../lib/docs_rs_headers", features = ["testing"] } docs_rs_storage = { path = "../../lib/docs_rs_storage", features = ["testing"] } docs_rs_types = { path = "../../lib/docs_rs_types", features = ["testing"] } diff --git a/crates/bin/docs_rs_watcher/Cargo.toml b/crates/bin/docs_rs_watcher/Cargo.toml index 488eb0084..4a1fbc13d 100644 --- a/crates/bin/docs_rs_watcher/Cargo.toml +++ b/crates/bin/docs_rs_watcher/Cargo.toml @@ -10,7 +10,7 @@ edition = "2024" anyhow = { workspace = true } clap = { workspace = true } crates-index = { version = "3.0.0", default-features = false, features = ["git", "git-https", "git-performance", "parallel"] } -crates-index-diff = { version = "29.0.0", features = [ "max-performance" ]} +crates-index-diff = { version = "29.0.0", features = [ "max-performance" ] } docs_rs_build_queue = { path = "../../lib/docs_rs_build_queue" } docs_rs_config = { path = "../../lib/docs_rs_config" } docs_rs_context = { path = "../../lib/docs_rs_context" } diff --git a/crates/bin/docs_rs_web/Cargo.toml b/crates/bin/docs_rs_web/Cargo.toml index d210beb18..e016f9295 100644 --- a/crates/bin/docs_rs_web/Cargo.toml +++ b/crates/bin/docs_rs_web/Cargo.toml @@ -7,6 +7,13 @@ repository = "https://github.com/rust-lang/docs.rs" edition = "2024" build = "build.rs" +[package.metadata.cargo-machete] +ignored = [ + "phf", + # used in build script output + "slug", # used in askama templates, can be moved to web binary +] + [dependencies] anyhow = { workspace = true } askama = { workspace = true } @@ -64,7 +71,7 @@ toml = { workspace = true } tower = "0.5.1" tower-http = { version = "0.6.0", features = ["fs", "trace", "timeout", "catch-panic"] } tracing = { workspace = true } -tracing-futures= { version = "0.2.5", features = ["std-future", "futures-03"] } +tracing-futures = { version = "0.2.5", features = ["std-future", "futures-03"] } url = { workspace = true } [build-dependencies] @@ -93,9 +100,3 @@ pretty_assertions = { workspace = true } test-case = { workspace = true } walkdir = { workspace = true } -[package.metadata.cargo-machete] -ignored = [ - "phf", # used in build script output - "slug", # used in askama templates, can be moved to web binary -] - diff --git a/crates/lib/docs_rs_build_limits/Cargo.toml b/crates/lib/docs_rs_build_limits/Cargo.toml index d05f2db5b..a185e61e2 100644 --- a/crates/lib/docs_rs_build_limits/Cargo.toml +++ b/crates/lib/docs_rs_build_limits/Cargo.toml @@ -11,10 +11,10 @@ docs_rs_config = { path = "../docs_rs_config" } docs_rs_env_vars = { path = "../docs_rs_env_vars" } docs_rs_types = { path = "../docs_rs_types" } futures-util = { workspace = true } -serde = { workspace = true} +serde = { workspace = true } sqlx = { workspace = true } -tracing = { workspace = true } thiserror = { workspace = true } +tracing = { workspace = true } [dev-dependencies] docs_rs_database = { path = "../docs_rs_database", features = ["testing"] } diff --git a/crates/lib/docs_rs_build_queue/Cargo.toml b/crates/lib/docs_rs_build_queue/Cargo.toml index 5e33623e6..9f07e1232 100644 --- a/crates/lib/docs_rs_build_queue/Cargo.toml +++ b/crates/lib/docs_rs_build_queue/Cargo.toml @@ -5,6 +5,14 @@ license = "MIT" repository = "https://github.com/rust-lang/docs.rs" edition = "2024" +[features] +testing = [ + "docs_rs_config/testing", + "docs_rs_database/testing", + "docs_rs_opentelemetry/testing", + "docs_rs_types/testing", +] + [dependencies] anyhow = { workspace = true } chrono = { workspace = true } @@ -20,16 +28,8 @@ tokio = { workspace = true } tracing = { workspace = true } [dev-dependencies] -docs_rs_opentelemetry = { path = "../docs_rs_opentelemetry", features = ["testing"] } docs_rs_database = { path = "../docs_rs_database", features = ["testing"] } -docs_rs_utils = { path = "../../lib/docs_rs_utils", features = ["testing"] } +docs_rs_opentelemetry = { path = "../docs_rs_opentelemetry", features = ["testing"] } docs_rs_types = { path = "../docs_rs_types", features = ["testing"] } +docs_rs_utils = { path = "../../lib/docs_rs_utils", features = ["testing"] } pretty_assertions = { workspace = true } - -[features] -testing = [ - "docs_rs_config/testing", - "docs_rs_database/testing", - "docs_rs_opentelemetry/testing", - "docs_rs_types/testing", -] diff --git a/crates/lib/docs_rs_cargo_metadata/Cargo.toml b/crates/lib/docs_rs_cargo_metadata/Cargo.toml index 657b487ef..394ae2cb0 100644 --- a/crates/lib/docs_rs_cargo_metadata/Cargo.toml +++ b/crates/lib/docs_rs_cargo_metadata/Cargo.toml @@ -5,6 +5,9 @@ license = "MIT" repository = "https://github.com/rust-lang/docs.rs" edition = "2024" +[features] +testing = [] + [dependencies] anyhow = { workspace = true } derive_more = { workspace = true } @@ -14,6 +17,3 @@ serde_json = { workspace = true } [dev-dependencies] test-case = { workspace = true } - -[features] -testing = [] diff --git a/crates/lib/docs_rs_config/Cargo.toml b/crates/lib/docs_rs_config/Cargo.toml index 753249bff..264a721f2 100644 --- a/crates/lib/docs_rs_config/Cargo.toml +++ b/crates/lib/docs_rs_config/Cargo.toml @@ -3,9 +3,9 @@ name = "docs_rs_config" version = "0.1.0" edition = "2024" -[dependencies] -anyhow = { workspace = true } - [features] testing = [] +[dependencies] +anyhow = { workspace = true } + diff --git a/crates/lib/docs_rs_context/Cargo.toml b/crates/lib/docs_rs_context/Cargo.toml index f2a8346a6..021d9d5d4 100644 --- a/crates/lib/docs_rs_context/Cargo.toml +++ b/crates/lib/docs_rs_context/Cargo.toml @@ -5,6 +5,16 @@ license = "MIT" repository = "https://github.com/rust-lang/docs.rs" edition = "2024" +[features] +testing = [ + "dep:docs_rs_logging", + "dep:docs_rs_test_fakes", + "docs_rs_database/testing", + "docs_rs_fastly/testing", + "docs_rs_logging/testing", + "docs_rs_storage/testing", +] + [dependencies] anyhow = { workspace = true } bon = { workspace = true } @@ -20,13 +30,3 @@ docs_rs_repository_stats = { path = "../docs_rs_repository_stats" } docs_rs_storage = { path = "../docs_rs_storage" } docs_rs_test_fakes = { path = "../docs_rs_test_fakes", optional = true } tokio = { workspace = true } - -[features] -testing = [ - "dep:docs_rs_logging", - "dep:docs_rs_test_fakes", - "docs_rs_database/testing", - "docs_rs_fastly/testing", - "docs_rs_logging/testing", - "docs_rs_storage/testing", -] diff --git a/crates/lib/docs_rs_database/Cargo.toml b/crates/lib/docs_rs_database/Cargo.toml index cf6782390..be1025c11 100644 --- a/crates/lib/docs_rs_database/Cargo.toml +++ b/crates/lib/docs_rs_database/Cargo.toml @@ -6,14 +6,21 @@ repository = "https://github.com/rust-lang/docs.rs" edition = "2024" build = "build.rs" +[features] +testing = [ + "dep:rand", + "docs_rs_config/testing", + "docs_rs_opentelemetry/testing", +] + [dependencies] anyhow = { workspace = true } chrono = { workspace = true } -docs_rs_config = { path = "../docs_rs_config" } docs_rs_cargo_metadata = { path = "../docs_rs_cargo_metadata" } +docs_rs_config = { path = "../docs_rs_config" } docs_rs_env_vars = { path = "../docs_rs_env_vars" } docs_rs_opentelemetry = { path = "../docs_rs_opentelemetry" } -docs_rs_registry_api= { path = "../docs_rs_registry_api" } +docs_rs_registry_api = { path = "../docs_rs_registry_api" } docs_rs_types = { path = "../docs_rs_types" } docs_rs_utils = { path = "../docs_rs_utils" } futures-util = { workspace = true } @@ -31,17 +38,10 @@ tokio = { workspace = true } tracing = { workspace = true } [dev-dependencies] -docs_rs_config = { path = "../docs_rs_config", features = ["testing"] } docs_rs_cargo_metadata = { path = "../docs_rs_cargo_metadata", features = ["testing"] } +docs_rs_config = { path = "../docs_rs_config", features = ["testing"] } docs_rs_opentelemetry = { path = "../docs_rs_opentelemetry", features = ["testing"] } docs_rs_types = { path = "../docs_rs_types", features = ["testing"] } rand = { workspace = true } tempfile = { workspace = true } test-case = { workspace = true } - -[features] -testing = [ - "dep:rand", - "docs_rs_config/testing", - "docs_rs_opentelemetry/testing", -] diff --git a/crates/lib/docs_rs_fastly/Cargo.toml b/crates/lib/docs_rs_fastly/Cargo.toml index 70e667479..ab6b6a164 100644 --- a/crates/lib/docs_rs_fastly/Cargo.toml +++ b/crates/lib/docs_rs_fastly/Cargo.toml @@ -5,6 +5,9 @@ license = "MIT" repository = "https://github.com/rust-lang/docs.rs" edition = "2024" +[features] +testing = ["dep:tokio"] + [dependencies] anyhow = { workspace = true } chrono = { workspace = true } @@ -28,6 +31,3 @@ docs_rs_headers = { path = "../docs_rs_headers", features = ["testing"] } docs_rs_opentelemetry = { path = "../docs_rs_opentelemetry", features = ["testing"] } mockito = { workspace = true } tokio = { workspace = true } - -[features] -testing = ["dep:tokio"] diff --git a/crates/lib/docs_rs_headers/Cargo.toml b/crates/lib/docs_rs_headers/Cargo.toml index 7f004c263..94286326c 100644 --- a/crates/lib/docs_rs_headers/Cargo.toml +++ b/crates/lib/docs_rs_headers/Cargo.toml @@ -5,6 +5,9 @@ license = "MIT" repository = "https://github.com/rust-lang/docs.rs" edition = "2024" +[features] +testing = [] + [dependencies] anyhow = { workspace = true } askama = { workspace = true } @@ -23,6 +26,3 @@ axum-extra = { workspace = true } serde_json = { workspace = true } test-case = { workspace = true } tokio = { workspace = true } - -[features] -testing = [] diff --git a/crates/lib/docs_rs_logging/Cargo.toml b/crates/lib/docs_rs_logging/Cargo.toml index e7015227b..efebe695d 100644 --- a/crates/lib/docs_rs_logging/Cargo.toml +++ b/crates/lib/docs_rs_logging/Cargo.toml @@ -5,12 +5,12 @@ license = "MIT" repository = "https://github.com/rust-lang/docs.rs" edition = "2024" +[features] +testing = [] + [dependencies] anyhow = { workspace = true } docs_rs_utils = { path = "../docs_rs_utils" } sentry = { workspace = true } tracing = { workspace = true } tracing-subscriber = { version = "0.3.20", default-features = false, features = ["ansi", "fmt", "json", "env-filter", "tracing-log"] } - -[features] -testing = [] diff --git a/crates/lib/docs_rs_mimes/Cargo.toml b/crates/lib/docs_rs_mimes/Cargo.toml index 3f66bc023..efb1ef924 100644 --- a/crates/lib/docs_rs_mimes/Cargo.toml +++ b/crates/lib/docs_rs_mimes/Cargo.toml @@ -6,8 +6,8 @@ repository = "https://github.com/rust-lang/docs.rs" edition = "2024" [dependencies] -mime_guess = "2" mime = { workspace = true } +mime_guess = "2" [dev-dependencies] test-case = { workspace = true } diff --git a/crates/lib/docs_rs_opentelemetry/Cargo.toml b/crates/lib/docs_rs_opentelemetry/Cargo.toml index 32c968a1c..134f70eba 100644 --- a/crates/lib/docs_rs_opentelemetry/Cargo.toml +++ b/crates/lib/docs_rs_opentelemetry/Cargo.toml @@ -5,6 +5,13 @@ license = "MIT" repository = "https://github.com/rust-lang/docs.rs" edition = "2024" +[features] +testing = [ + "dep:derive_more", + "docs_rs_config/testing", + "opentelemetry_sdk/testing", +] + [dependencies] anyhow = { workspace = true } derive_more = { workspace = true, optional = true } @@ -16,10 +23,3 @@ opentelemetry-resource-detectors = "0.10.0" opentelemetry_sdk = { workspace = true } tracing = { workspace = true } url = { workspace = true } - -[features] -testing = [ - "dep:derive_more", - "docs_rs_config/testing", - "opentelemetry_sdk/testing", -] diff --git a/crates/lib/docs_rs_repository_stats/Cargo.toml b/crates/lib/docs_rs_repository_stats/Cargo.toml index ef3580c83..d53bb3520 100644 --- a/crates/lib/docs_rs_repository_stats/Cargo.toml +++ b/crates/lib/docs_rs_repository_stats/Cargo.toml @@ -9,8 +9,8 @@ edition = "2024" anyhow = { workspace = true } async-trait = "0.1.89" chrono = { workspace = true } -docs_rs_config = { path = "../docs_rs_config" } docs_rs_cargo_metadata = { path = "../docs_rs_cargo_metadata" } +docs_rs_config = { path = "../docs_rs_config" } docs_rs_database = { path = "../docs_rs_database" } docs_rs_env_vars = { path = "../docs_rs_env_vars" } docs_rs_utils = { path = "../docs_rs_utils" } diff --git a/crates/lib/docs_rs_storage/Cargo.toml b/crates/lib/docs_rs_storage/Cargo.toml index fed84a5a4..615176145 100644 --- a/crates/lib/docs_rs_storage/Cargo.toml +++ b/crates/lib/docs_rs_storage/Cargo.toml @@ -5,6 +5,15 @@ license = "MIT" repository = "https://github.com/rust-lang/docs.rs" edition = "2024" +[features] +testing = [ + "dep:rand", + "dep:docs_rs_logging", + "docs_rs_config/testing", + "docs_rs_logging/testing", + "docs_rs_opentelemetry/testing", +] + [dependencies] anyhow = { workspace = true } async-compression = { version = "0.4.32", features = ["tokio", "bzip2", "zstd", "gzip"] } @@ -39,7 +48,7 @@ thiserror = { workspace = true } tokio = { workspace = true } tracing = { workspace = true } walkdir = { workspace = true } -zip = {version = "7.0.0", default-features = false, features = ["bzip2"]} +zip = { version = "7.0.0", default-features = false, features = ["bzip2"] } zstd = "0.13.0" [dev-dependencies] @@ -50,15 +59,6 @@ docs_rs_opentelemetry = { path = "../docs_rs_opentelemetry", features = ["testin rand = { workspace = true } test-case = { workspace = true } -[features] -testing = [ - "dep:rand", - "dep:docs_rs_logging", - "docs_rs_config/testing", - "docs_rs_logging/testing", - "docs_rs_opentelemetry/testing", -] - [[bench]] name = "compression" harness = false diff --git a/crates/lib/docs_rs_types/Cargo.toml b/crates/lib/docs_rs_types/Cargo.toml index a5e4f4b25..eb4949b45 100644 --- a/crates/lib/docs_rs_types/Cargo.toml +++ b/crates/lib/docs_rs_types/Cargo.toml @@ -5,6 +5,11 @@ license = "MIT" repository = "https://github.com/rust-lang/docs.rs" edition = "2024" +[features] +# NOTE: we could make serde & sqlx optional features, some +# of the subcrates don't need one or both of them. +testing = [] + [dependencies] anyhow = { workspace = true } crates_io_validation = { path = "../crates_io_validation" } @@ -17,11 +22,6 @@ sqlx = { workspace = true } strum = { workspace = true } [dev-dependencies] +pretty_assertions = { workspace = true } test-case = { workspace = true } tokio = { workspace = true } -pretty_assertions = { workspace = true } - -[features] -# NOTE: we could make serde & sqlx optional features, some -# of the subcrates don't need one or both of them. -testing = [] diff --git a/crates/lib/docs_rs_uri/Cargo.toml b/crates/lib/docs_rs_uri/Cargo.toml index 30e21a1d4..a019de886 100644 --- a/crates/lib/docs_rs_uri/Cargo.toml +++ b/crates/lib/docs_rs_uri/Cargo.toml @@ -10,8 +10,8 @@ askama = { workspace = true } http = { workspace = true } percent-encoding = "2.2.0" serde_with = { workspace = true } -url = { workspace = true } thiserror = { workspace = true } +url = { workspace = true } [dev-dependencies] test-case = { workspace = true } diff --git a/crates/lib/docs_rs_utils/Cargo.toml b/crates/lib/docs_rs_utils/Cargo.toml index 220795ba1..e216a3e10 100644 --- a/crates/lib/docs_rs_utils/Cargo.toml +++ b/crates/lib/docs_rs_utils/Cargo.toml @@ -6,6 +6,9 @@ repository = "https://github.com/rust-lang/docs.rs" edition = "2024" build = "build.rs" +[features] +testing = [] + [dependencies] anyhow = { workspace = true } chrono = { workspace = true } @@ -18,6 +21,3 @@ anyhow = { workspace = true } chrono = { workspace = true } time = "0.3" tokio = { workspace = true } - -[features] -testing = [] diff --git a/crates/lib/metadata/Cargo.toml b/crates/lib/metadata/Cargo.toml index f5942d426..5dfd3136b 100644 --- a/crates/lib/metadata/Cargo.toml +++ b/crates/lib/metadata/Cargo.toml @@ -14,5 +14,5 @@ path = "lib.rs" [dependencies] serde = { version = "1.0", features = ["derive"] } -toml = "0.9" thiserror = "2" +toml = "0.9" diff --git a/justfiles/testing.just b/justfiles/testing.just index 7d83bf8e1..4b183eef7 100644 --- a/justfiles/testing.just +++ b/justfiles/testing.just @@ -86,11 +86,23 @@ lint: format lint-dependencies set -euo pipefail if [ "${GITHUB_ACTIONS:-}" = "true" ]; then + just sort-cargo-toml --check just clippy else + just sort-cargo-toml just clippy-fix fi +[group('testing')] +sort-cargo-toml *args: + # for now manually, `cargo sort --workspace` is broken right now for docs.rs + # https://github.com/DevinR528/cargo-sort/pull/121 + cargo sort {{ args }} \ + ./Cargo.toml \ + ./crates/bin/* \ + ./crates/lib/* + + [group('testing')] [arg("udeps", long="udeps")] lint-dependencies udeps="false":