mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-11 01:59:10 +01:00
Merge pull request #672 from teloxide/improve-ci
improve ci
Former-commit-id: 2a58244ee5
This commit is contained in:
commit
3615004729
5 changed files with 149 additions and 52 deletions
12
.cargo/config.toml
Normal file
12
.cargo/config.toml
Normal file
|
@ -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
|
||||||
|
"""
|
178
.github/workflows/ci.yml
vendored
178
.github/workflows/ci.yml
vendored
|
@ -7,47 +7,64 @@ on:
|
||||||
name: Continuous integration
|
name: Continuous integration
|
||||||
|
|
||||||
env:
|
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:
|
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
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- name: Checkout
|
||||||
- uses: actions-rs/toolchain@v1
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install Rust ${{ env.rust_nightly }}
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
profile: minimal
|
||||||
toolchain: nightly-2022-05-06
|
toolchain: ${{ env.rust_nightly }}
|
||||||
override: true
|
override: true
|
||||||
components: rustfmt
|
components: rustfmt
|
||||||
|
|
||||||
- name: fmt
|
- name: Cache Dependencies
|
||||||
|
uses: Swatinem/rust-cache@v1
|
||||||
|
|
||||||
|
- name: Check formatting
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: fmt
|
command: fmt
|
||||||
args: --all -- --check
|
args: --all -- --check
|
||||||
|
|
||||||
clippy:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- uses: actions-rs/toolchain@v1
|
|
||||||
with:
|
|
||||||
profile: minimal
|
|
||||||
toolchain: nightly-2022-05-06
|
|
||||||
override: true
|
|
||||||
components: clippy
|
|
||||||
|
|
||||||
- name: clippy
|
|
||||||
uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: clippy
|
|
||||||
args: --all-targets --all-features -- -D warnings
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
|
name: Test
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
|
@ -65,48 +82,119 @@ jobs:
|
||||||
toolchain: beta
|
toolchain: beta
|
||||||
features: "--features full"
|
features: "--features full"
|
||||||
- rust: nightly
|
- rust: nightly
|
||||||
toolchain: nightly-2022-05-06
|
toolchain: nightly-2022-07-01
|
||||||
features: "--all-features"
|
features: "--all-features"
|
||||||
- rust: msrv
|
- rust: msrv
|
||||||
toolchain: "1.58.0"
|
toolchain: 1.58.0
|
||||||
features: "--features full"
|
features: "--features full"
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
- uses: actions-rs/toolchain@v1
|
|
||||||
|
- name: Install Rust ${{ matrix.toolchain }}
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
profile: minimal
|
||||||
toolchain: ${{ matrix.toolchain }}
|
toolchain: ${{ matrix.toolchain }}
|
||||||
override: true
|
override: true
|
||||||
|
|
||||||
- name: build
|
- name: Cache Dependencies
|
||||||
|
uses: Swatinem/rust-cache@v1
|
||||||
|
|
||||||
|
- name: Compile
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: build
|
command: test
|
||||||
args: --verbose ${{ matrix.features }}
|
args: --no-run --verbose ${{ matrix.features }}
|
||||||
|
|
||||||
- name: Setup redis
|
- name: Setup redis
|
||||||
run: |
|
run: |
|
||||||
sudo apt install redis-server
|
sudo apt install redis-server
|
||||||
redis-server --port 7777 > /dev/null &
|
redis-server --port 7777 > /dev/null &
|
||||||
redis-server --port 7778 > /dev/null &
|
redis-server --port 7778 > /dev/null &
|
||||||
redis-server --port 7779 > /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
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: test
|
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 }}
|
||||||
|
|
||||||
build-example:
|
check-examples:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- name: Checkout
|
||||||
- uses: actions-rs/toolchain@v1
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install Rust stable
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
profile: minimal
|
||||||
toolchain: stable
|
toolchain: stable
|
||||||
override: true
|
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
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "nightly-2022-05-06"
|
channel = "nightly-2022-07-01"
|
||||||
components = ["rustfmt", "clippy"]
|
components = ["rustfmt", "clippy"]
|
||||||
profile = "minimal"
|
profile = "minimal"
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
//! // TODO: examples/purchase.rs
|
//! // TODO: examples/purchase.rs
|
||||||
|
//! fn main() {}
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! 1. First, we create the bot: `let bot = Bot::from_env().auto_send()`.
|
//! 1. First, we create the bot: `let bot = Bot::from_env().auto_send()`.
|
||||||
|
|
|
@ -44,15 +44,11 @@
|
||||||
html_logo_url = "https://github.com/teloxide/teloxide/raw/master/ICON.png",
|
html_logo_url = "https://github.com/teloxide/teloxide/raw/master/ICON.png",
|
||||||
html_favicon_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
|
// To properly build docs of this crate run
|
||||||
// ```console
|
// ```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))]
|
#![cfg_attr(all(docsrs, feature = "nightly"), feature(doc_cfg, doc_auto_cfg))]
|
||||||
#![forbid(unsafe_code)]
|
#![forbid(unsafe_code)]
|
||||||
#![warn(rustdoc::broken_intra_doc_links)]
|
#![warn(rustdoc::broken_intra_doc_links)]
|
||||||
|
|
Loading…
Add table
Reference in a new issue