From 341c2698a74a953765aa1e862a411fe1912fddef Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Mon, 12 Feb 2024 10:18:58 +0100 Subject: [PATCH] Run doctests as part of CI pipeline (#9939) --- .config/nextest.toml | 8 ++++++++ .github/workflows/ci.yaml | 13 +++++++++++-- crates/ruff_benchmark/Cargo.toml | 1 + crates/ruff_diagnostics/Cargo.toml | 1 + crates/ruff_index/Cargo.toml | 1 + crates/ruff_macros/src/lib.rs | 4 +++- crates/ruff_notebook/Cargo.toml | 1 + crates/ruff_python_codegen/Cargo.toml | 1 + crates/ruff_python_formatter/Cargo.toml | 3 +++ crates/ruff_python_index/Cargo.toml | 1 + crates/ruff_python_literal/Cargo.toml | 3 +++ crates/ruff_python_resolver/Cargo.toml | 1 + crates/ruff_python_semantic/Cargo.toml | 1 + crates/ruff_wasm/Cargo.toml | 1 + 14 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 .config/nextest.toml diff --git a/.config/nextest.toml b/.config/nextest.toml new file mode 100644 index 0000000000..e86fea2b36 --- /dev/null +++ b/.config/nextest.toml @@ -0,0 +1,8 @@ +[profile.ci] +# Print out output for failing tests as soon as they fail, and also at the end +# of the run (for easy scrollability). +failure-output = "immediate-final" +# Do not cancel the test run on the first failure. +fail-fast = false + +status-level = "skip" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 895ab3a58a..e26b52ca18 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -117,10 +117,17 @@ jobs: uses: taiki-e/install-action@v2 with: tool: cargo-nextest + - name: "Install cargo insta" + uses: taiki-e/install-action@v2 + with: + tool: cargo-insta - uses: Swatinem/rust-cache@v2 - name: "Run tests" shell: bash - run: cargo nextest run --workspace --status-level skip --failure-output immediate-final --no-fail-fast -j 12 + env: + NEXTEST_PROFILE: "ci" + run: cargo insta test --all-features --unreferenced reject --test-runner nextest + # Check for broken links in the documentation. - run: cargo doc --all --no-deps env: @@ -148,7 +155,9 @@ jobs: - uses: Swatinem/rust-cache@v2 - name: "Run tests" shell: bash - run: cargo nextest run --workspace --status-level skip --failure-output immediate-final --no-fail-fast -j 12 + run: | + cargo nextest run --all-features --profile ci + cargo test --all-features --doc cargo-test-wasm: name: "cargo test (wasm)" diff --git a/crates/ruff_benchmark/Cargo.toml b/crates/ruff_benchmark/Cargo.toml index 02f907e3d2..db70977c50 100644 --- a/crates/ruff_benchmark/Cargo.toml +++ b/crates/ruff_benchmark/Cargo.toml @@ -13,6 +13,7 @@ license = { workspace = true } [lib] bench = false +doctest = false [[bench]] name = "linter" diff --git a/crates/ruff_diagnostics/Cargo.toml b/crates/ruff_diagnostics/Cargo.toml index 9a2e22e234..754b35b5fb 100644 --- a/crates/ruff_diagnostics/Cargo.toml +++ b/crates/ruff_diagnostics/Cargo.toml @@ -11,6 +11,7 @@ repository = { workspace = true } license = { workspace = true } [lib] +doctest = false [dependencies] ruff_text_size = { path = "../ruff_text_size" } diff --git a/crates/ruff_index/Cargo.toml b/crates/ruff_index/Cargo.toml index d07ae78de9..d0fd5df8ac 100644 --- a/crates/ruff_index/Cargo.toml +++ b/crates/ruff_index/Cargo.toml @@ -11,6 +11,7 @@ repository = { workspace = true } license = { workspace = true } [lib] +doctest = false [dependencies] ruff_macros = { path = "../ruff_macros" } diff --git a/crates/ruff_macros/src/lib.rs b/crates/ruff_macros/src/lib.rs index ed9e77508f..ab0e0db842 100644 --- a/crates/ruff_macros/src/lib.rs +++ b/crates/ruff_macros/src/lib.rs @@ -92,7 +92,9 @@ pub fn derive_message_formats(_attr: TokenStream, item: TokenStream) -> TokenStr /// /// Good: /// -/// ```rust +/// ```ignroe +/// use ruff_macros::newtype_index; +/// /// #[newtype_index] /// #[derive(Ord, PartialOrd)] /// struct MyIndex; diff --git a/crates/ruff_notebook/Cargo.toml b/crates/ruff_notebook/Cargo.toml index 524cfb4eb9..6fc9a5150e 100644 --- a/crates/ruff_notebook/Cargo.toml +++ b/crates/ruff_notebook/Cargo.toml @@ -11,6 +11,7 @@ repository = { workspace = true } license = { workspace = true } [lib] +doctest = false [dependencies] ruff_diagnostics = { path = "../ruff_diagnostics" } diff --git a/crates/ruff_python_codegen/Cargo.toml b/crates/ruff_python_codegen/Cargo.toml index 6c55754be3..769983969d 100644 --- a/crates/ruff_python_codegen/Cargo.toml +++ b/crates/ruff_python_codegen/Cargo.toml @@ -11,6 +11,7 @@ repository = { workspace = true } license = { workspace = true } [lib] +doctest = false [dependencies] ruff_python_ast = { path = "../ruff_python_ast" } diff --git a/crates/ruff_python_formatter/Cargo.toml b/crates/ruff_python_formatter/Cargo.toml index 4073ab71e8..ca9c300880 100644 --- a/crates/ruff_python_formatter/Cargo.toml +++ b/crates/ruff_python_formatter/Cargo.toml @@ -10,6 +10,9 @@ documentation = { workspace = true } repository = { workspace = true } license = { workspace = true } +[lib] +doctest= false + [dependencies] ruff_cache = { path = "../ruff_cache" } ruff_formatter = { path = "../ruff_formatter" } diff --git a/crates/ruff_python_index/Cargo.toml b/crates/ruff_python_index/Cargo.toml index 77aacbc2ea..5ca34af5df 100644 --- a/crates/ruff_python_index/Cargo.toml +++ b/crates/ruff_python_index/Cargo.toml @@ -11,6 +11,7 @@ repository = { workspace = true } license = { workspace = true } [lib] +doctest = false [dependencies] ruff_python_ast = { path = "../ruff_python_ast" } diff --git a/crates/ruff_python_literal/Cargo.toml b/crates/ruff_python_literal/Cargo.toml index 0d3709887d..155ac57bbe 100644 --- a/crates/ruff_python_literal/Cargo.toml +++ b/crates/ruff_python_literal/Cargo.toml @@ -11,6 +11,9 @@ documentation = { workspace = true } repository = { workspace = true } license = { workspace = true } +[lib] +doctest = false + [dependencies] bitflags = { workspace = true } hexf-parse = { workspace = true } diff --git a/crates/ruff_python_resolver/Cargo.toml b/crates/ruff_python_resolver/Cargo.toml index 964510795d..65d9847c9d 100644 --- a/crates/ruff_python_resolver/Cargo.toml +++ b/crates/ruff_python_resolver/Cargo.toml @@ -12,6 +12,7 @@ repository = { workspace = true } license = { workspace = true } [lib] +doctest = false [dependencies] log = { workspace = true } diff --git a/crates/ruff_python_semantic/Cargo.toml b/crates/ruff_python_semantic/Cargo.toml index 696643e09c..5e6080c5fc 100644 --- a/crates/ruff_python_semantic/Cargo.toml +++ b/crates/ruff_python_semantic/Cargo.toml @@ -11,6 +11,7 @@ repository = { workspace = true } license = { workspace = true } [lib] +doctest = false [dependencies] ruff_index = { path = "../ruff_index" } diff --git a/crates/ruff_wasm/Cargo.toml b/crates/ruff_wasm/Cargo.toml index 6d02a17d00..6dc15336ef 100644 --- a/crates/ruff_wasm/Cargo.toml +++ b/crates/ruff_wasm/Cargo.toml @@ -13,6 +13,7 @@ description = "WebAssembly bindings for Ruff" [lib] crate-type = ["cdylib", "rlib"] +doctest = false [features] default = ["console_error_panic_hook"]