From 6bfa21a02e2c94d072390cc5e1c0abb90924636a Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Sun, 3 Jul 2022 14:24:42 +0400 Subject: [PATCH 1/5] Update pinned nightly version Former-commit-id: 004837016908691b71112f0d84aa1c35da503cec --- .github/workflows/ci.yml | 6 +++--- rust-toolchain.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e990ad6a..8db7d963 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: nightly-2022-05-06 + toolchain: nightly-2022-07-01 override: true components: rustfmt @@ -37,7 +37,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: nightly-2022-05-06 + toolchain: nightly-2022-07-01 override: true components: clippy @@ -65,7 +65,7 @@ jobs: toolchain: beta features: "--features full" - rust: nightly - toolchain: nightly-2022-05-06 + toolchain: nightly-2022-07-01 features: "--all-features" - rust: msrv toolchain: "1.58.0" diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 43d17c19..ea79a434 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2022-05-06" +channel = "nightly-2022-07-01" components = ["rustfmt", "clippy"] profile = "minimal" From 41197bf515c59e9723a894abb43e1a3d0d8aa461 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Sun, 3 Jul 2022 14:33:46 +0400 Subject: [PATCH 2/5] Change recommended way to build docs Former-commit-id: a4ad44fae96b8bf5858d673ff875fb7a46d4e126 --- .cargo/config.toml | 12 ++++++++++++ src/lib.rs | 8 ++------ 2 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 00000000..d6e070ff --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,12 @@ +[alias] +# We pass "--cfg docsrs" when building docs to turn on nightly-only rustdoc features like +# `This is supported on feature="..." only.` +# +# "--cfg dep_docsrs" is used for the same reason, but for `teloxide-core`. +docs = """ +doc + --all-features + --config build.rustflags=["--cfg=dep_docsrs"] + --config build.rustdocflags=["--cfg=docsrs","-Znormalize-docs"] + -Zrustdoc-scrape-examples=examples +""" diff --git a/src/lib.rs b/src/lib.rs index f53ed5c5..e43af26c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -44,15 +44,11 @@ html_logo_url = "https://github.com/teloxide/teloxide/raw/master/ICON.png", html_favicon_url = "https://github.com/teloxide/teloxide/raw/master/ICON.png" )] -// We pass "--cfg docsrs" when building docs to add `This is supported on -// feature="..." only.` -// -// "--cfg dep_docsrs" is used for the same reason, but for `teloxide-core`. -// // To properly build docs of this crate run // ```console -// $ RUSTFLAGS="--cfg dep_docsrs" RUSTDOCFLAGS="--cfg docsrs -Znormalize-docs" cargo +nightly doc --open --all-features +// $ cargo docs --open // ``` +// (docs is an alias from `.cargo/config.toml`) #![cfg_attr(all(docsrs, feature = "nightly"), feature(doc_cfg, doc_auto_cfg))] #![forbid(unsafe_code)] #![warn(rustdoc::broken_intra_doc_links)] From 21cd47dcfd117c18026d2df6fb4bf6e4180bfa32 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Sun, 3 Jul 2022 14:35:56 +0400 Subject: [PATCH 3/5] Improve CI Former-commit-id: a9886d841967215af550b74b9eaca0a5356b0148 --- .github/workflows/ci.yml | 167 +++++++++++++++++++++++++++++---------- 1 file changed, 124 insertions(+), 43 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8db7d963..7a1ab60b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,47 +7,64 @@ on: name: Continuous integration env: - RUSTFLAGS: "--cfg CI_REDIS" + RUSTFLAGS: "--cfg CI_REDIS -Dwarnings" + RUSTDOCFLAGS: -Dwarnings + RUST_BACKTRACE: short + + CARGO_INCREMENTAL: 0 + CARGO_NET_RETRY: 10 + RUSTUP_MAX_RETRIES: 10 + + rust_nightly: nightly-2022-07-01 + # When updating this, also update: + # - README.md + # - src/lib.rs + # - down below in a matrix + rust_msrv: 1.58.0 jobs: - style: + # Depends on all action that are required for a "successful" CI run. + ci-pass: + name: CI succeeded + runs-on: ubuntu-latest + + needs: + - fmt + - test + - check-examples + - clippy + - doc + + steps: + - run: exit 0 + + fmt: + name: fmt runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Rust ${{ env.rust_nightly }} + uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: nightly-2022-07-01 + toolchain: ${{ env.rust_nightly }} override: true components: rustfmt - - name: fmt + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + + - name: Check formatting uses: actions-rs/cargo@v1 with: command: fmt - args: --all -- --check - - clippy: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly-2022-07-01 - override: true - components: clippy - - - name: clippy - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --all-targets --all-features -- -D warnings + args: --all -- --check test: + name: Test runs-on: ubuntu-latest strategy: matrix: @@ -68,45 +85,109 @@ jobs: toolchain: nightly-2022-07-01 features: "--all-features" - rust: msrv - toolchain: "1.58.0" + toolchain: 1.58.0 features: "--features full" - steps: - - uses: actions/checkout@v2 - - - uses: actions-rs/toolchain@v1 + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Rust ${{ matrix.toolchain }} + uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: ${{ matrix.toolchain }} override: true - - - name: build + + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + + - name: Compile uses: actions-rs/cargo@v1 with: - command: build - args: --verbose ${{ matrix.features }} - + command: test + args: --no-run --verbose ${{ matrix.features }} + - name: Setup redis run: | sudo apt install redis-server redis-server --port 7777 > /dev/null & redis-server --port 7778 > /dev/null & redis-server --port 7779 > /dev/null & - - - name: test + + - name: Test uses: actions-rs/cargo@v1 with: command: test args: --verbose ${{ matrix.features }} - build-example: + check-examples: runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Rust stable + uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable override: true - - name: Check the examples - run: cargo check --examples --features="full" + + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + + - name: Check examples + uses: actions-rs/cargo@v1 + with: + command: check + args: --examples --features full + + clippy: + name: Run linter + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Rust ${{ env.rust_nightly }} + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ env.rust_nightly }} + override: true + components: clippy + + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + + - name: clippy + uses: actions-rs/cargo@v1 + with: + command: clippy + args: --all-targets --all-features + + doc: + name: check docs + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Rust ${{ env.rust_nightly }} + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ env.rust_nightly }} + override: true + + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + + - name: rustdoc + uses: actions-rs/cargo@v1 + with: + command: docs # from .cargo/config.toml From 82ff78b5f637eebab36ae8acd2e5cbde830abcee Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Sun, 3 Jul 2022 14:38:14 +0400 Subject: [PATCH 4/5] Don't build examples when testing on CI Former-commit-id: 77d1c4524d60a6a2979636957d93cfb7e880bdc3 --- .github/workflows/ci.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a1ab60b..65b4c62f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -115,11 +115,18 @@ jobs: redis-server --port 7778 > /dev/null & redis-server --port 7779 > /dev/null & - - name: Test + # NB. Don't test (build) examples so we can use non-msrv features in them + - name: Test unit & integration tests uses: actions-rs/cargo@v1 with: command: test - args: --verbose ${{ matrix.features }} + args: --tests --verbose ${{ matrix.features }} + + - name: Test documentation tests + uses: actions-rs/cargo@v1 + with: + command: test + args: --doc --verbose ${{ matrix.features }} check-examples: runs-on: ubuntu-latest From 074b991189e4745c66108e74541429d4d6cadd02 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Sun, 3 Jul 2022 15:21:17 +0400 Subject: [PATCH 5/5] fix doctest Former-commit-id: cabc045c06b8118bd244810d2986de77138d4a3e --- src/dispatching.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dispatching.rs b/src/dispatching.rs index 6b05d88c..1c093048 100644 --- a/src/dispatching.rs +++ b/src/dispatching.rs @@ -30,6 +30,7 @@ //! //! ```no_run //! // TODO: examples/purchase.rs +//! fn main() {} //! ``` //! //! 1. First, we create the bot: `let bot = Bot::from_env().auto_send()`.