From ed4f187ed9db9119a76669c28fb29190f84ff5d8 Mon Sep 17 00:00:00 2001 From: EdJoPaTo Date: Mon, 27 Nov 2023 15:21:26 +0100 Subject: [PATCH 1/3] build(rust): update to edition 2021 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 83d40c9..ccad505 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "frankenstein" version = "0.29.1" authors = ["Ayrat Badykov ", "Pepe Márquez "] description = "Telegram bot API client for Rust" -edition = "2018" +edition = "2021" license = "WTFPL" repository = "https://github.com/ayrat555/frankenstein" readme = "README.md" From cef6e04079c902a189fb8ad47da522fb65d3dc24 Mon Sep 17 00:00:00 2001 From: EdJoPaTo Date: Mon, 27 Nov 2023 15:25:25 +0100 Subject: [PATCH 2/3] ci(rust): improve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use action to install rust toolchain which also does some workarounds / enables color. Dont use old unmaintained action-rs actions, use in manually. Downside: warnings get lost → deny everything and get a hard error. With ring 0.17 out test platforms like risc-v or arm64 on windows. --- .github/workflows/rust.yml | 78 ++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 41 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 465130b..8d09210 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -8,23 +8,25 @@ on: # Check if it works with current dependencies - cron: "32 2 * * 3" # weekly on Wednesday 2:32 UTC +env: + RUSTFLAGS: --deny warnings + jobs: rustfmt: runs-on: ubuntu-latest steps: - name: Setup Rust - shell: bash -eux {0} - run: | - rm ~/.cargo/bin/{rustfmt,cargo-fmt} - rustup toolchain install stable --profile minimal --component rustfmt - rustup default stable + uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + components: rustfmt - uses: actions/checkout@v4 - run: cargo fmt --check --verbose test: name: Test ${{ matrix.toolchain }} ${{ matrix.os }} ${{ matrix.features }} runs-on: ${{ matrix.os }} - continue-on-error: ${{ matrix.toolchain == 'nightly' }} + continue-on-error: ${{ (matrix.toolchain == 'beta') || (matrix.toolchain == 'nightly') }} strategy: fail-fast: false matrix: @@ -35,7 +37,7 @@ jobs: - macos-latest - windows-latest clippyargs: - - -D clippy::pedantic -D warnings + - -D clippy::pedantic features: - --no-default-features - "" # default features @@ -45,43 +47,34 @@ jobs: - toolchain: beta os: ubuntu-latest features: --all-features - clippyargs: -W clippy::pedantic -W clippy::cargo + clippyargs: -D clippy::pedantic - toolchain: nightly os: ubuntu-latest features: --all-features - clippyargs: -W clippy::pedantic + clippyargs: -D clippy::pedantic steps: - name: Setup Rust - shell: bash -eux {0} - run: | - rustup toolchain install ${{ matrix.toolchain }} --profile minimal --component clippy - rustup default ${{ matrix.toolchain }} + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.toolchain }} + components: clippy - uses: actions/checkout@v4 - name: Fetch dependencies - uses: actions-rs/cargo@v1 - with: - command: fetch - args: --verbose + run: cargo fetch --verbose - name: Check clippy - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --verbose --all-targets ${{ matrix.features }} -- ${{ matrix.clippyargs }} + run: cargo clippy --verbose --all-targets ${{ matrix.features }} -- ${{ matrix.clippyargs }} - name: Check docs - uses: actions-rs/cargo@v1 - with: - command: doc - args: --verbose --no-deps ${{ matrix.features }} + run: cargo doc --verbose --no-deps ${{ matrix.features }} + + - name: Build + run: cargo build --verbose --all-targets ${{ matrix.features }} - name: Run tests - uses: actions-rs/cargo@v1 - with: - command: test - args: --verbose ${{ matrix.features }} + run: cargo test --verbose ${{ matrix.features }} release: name: Release ${{ matrix.triple }} @@ -99,6 +92,8 @@ jobs: os: ubuntu-latest - triple: arm-unknown-linux-gnueabihf os: ubuntu-latest + - triple: riscv64gc-unknown-linux-gnu + os: ubuntu-latest - triple: x86_64-apple-darwin os: macos-latest @@ -107,15 +102,20 @@ jobs: - triple: x86_64-pc-windows-msvc os: windows-latest - # https://github.com/briansmith/ring/issues/1167 - # - triple: aarch64-pc-windows-msvc - # os: windows-latest + - triple: aarch64-pc-windows-msvc + os: windows-latest steps: - name: Setup Rust - shell: bash -eux {0} - run: | - rustup toolchain install stable --profile minimal --target ${{ matrix.triple }} - rustup default stable + uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + targets: ${{ matrix.triple }} + + - name: Install cargo tools + if: runner.os == 'Linux' + uses: taiki-e/install-action@v2 + with: + tool: cross - uses: actions/checkout@v4 @@ -123,8 +123,4 @@ jobs: run: cargo fetch --verbose - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - args: --release --verbose --all-features --target ${{ matrix.triple }} - use-cross: ${{ runner.os == 'Linux' }} + run: ${{ runner.os == 'Linux' && 'cross' || 'cargo' }} build --release --verbose --target ${{ matrix.triple }} From 762da2db095f1f71ca3c91c1553176c02230b1d9 Mon Sep 17 00:00:00 2001 From: EdJoPaTo Date: Mon, 27 Nov 2023 15:29:16 +0100 Subject: [PATCH 3/3] build(clippy): enable pedantic lints from code When this is forgotten locally only the CI will notice this. Now these lints are always performed with clippy. Also cleanup the list of allowed lints and add future ones from the nursery which could also already be implemented. --- src/lib.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 5b799cd..97374dd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,19 +1,18 @@ +#![forbid(unsafe_code)] +#![warn(clippy::pedantic)] // TODO: remove and fix (or allow explicitly on the specific problem) #![allow( - clippy::large_enum_variant, - clippy::missing_const_for_fn, clippy::missing_errors_doc, - clippy::module_name_repetitions, clippy::must_use_candidate, - clippy::needless_collect, - clippy::new_without_default, - clippy::non_ascii_literal, clippy::single_match_else, clippy::struct_excessive_bools, - clippy::too_many_arguments, clippy::unreadable_literal, - clippy::use_self, - clippy::wildcard_imports + + // from clippy::nursery + // clippy::derive_partial_eq_without_eq, + // clippy::option_if_let_else, + // clippy::significant_drop_tightening, + // clippy::use_self, )] #[cfg(any(feature = "http-client", feature = "async-http-client"))]