2020-07-02 15:01:45 +02:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: [ master ]
|
|
|
|
pull_request:
|
2023-01-17 17:37:17 +01:00
|
|
|
branches: [ master ]
|
2023-02-13 08:55:16 +01:00
|
|
|
merge_group:
|
2019-11-27 15:30:33 +01:00
|
|
|
|
|
|
|
name: Continuous integration
|
|
|
|
|
2022-03-14 16:28:20 +01:00
|
|
|
env:
|
2024-01-21 11:28:01 +01:00
|
|
|
RUSTFLAGS: "--cfg CI_REDIS --cfg CI_POSTGRES -Dwarnings"
|
2024-01-21 17:58:13 +01:00
|
|
|
RUSTDOCFLAGS: "--cfg docsrs -Dwarnings"
|
2022-07-03 12:35:56 +02:00
|
|
|
RUST_BACKTRACE: short
|
|
|
|
|
|
|
|
CARGO_INCREMENTAL: 0
|
|
|
|
CARGO_NET_RETRY: 10
|
|
|
|
RUSTUP_MAX_RETRIES: 10
|
|
|
|
|
|
|
|
# When updating this, also update:
|
2022-11-28 13:50:26 +01:00
|
|
|
# - crates/teloxide-core/src/codegen.rs
|
|
|
|
# - rust-toolchain.toml
|
2024-03-21 12:24:07 +01:00
|
|
|
# - below in the test matrix
|
2024-06-25 17:19:38 +02:00
|
|
|
rust_nightly: nightly-2024-07-03
|
2022-11-28 13:50:26 +01:00
|
|
|
# When updating this, also update:
|
|
|
|
# - **/README.md
|
|
|
|
# - **/src/lib.rs
|
2022-07-03 12:35:56 +02:00
|
|
|
# - down below in a matrix
|
2023-10-04 18:01:46 +02:00
|
|
|
# - `Cargo.toml`
|
|
|
|
# - **/CHANGELOG.md
|
2024-01-21 14:09:07 +01:00
|
|
|
rust_msrv: 1.70.0
|
2022-03-14 16:28:20 +01:00
|
|
|
|
2022-11-28 13:50:26 +01:00
|
|
|
CI: 1
|
|
|
|
|
2019-11-27 15:30:33 +01:00
|
|
|
jobs:
|
2022-07-03 12:35:56 +02:00
|
|
|
# Depends on all action that are required for a "successful" CI run.
|
|
|
|
ci-pass:
|
|
|
|
name: CI succeeded
|
2019-11-27 15:30:33 +01:00
|
|
|
runs-on: ubuntu-latest
|
2023-10-05 18:14:18 +02:00
|
|
|
if: always()
|
2021-03-21 13:34:23 +01:00
|
|
|
|
2022-07-03 12:35:56 +02:00
|
|
|
needs:
|
|
|
|
- fmt
|
|
|
|
- test
|
|
|
|
- check-examples
|
|
|
|
- clippy
|
|
|
|
- doc
|
2021-03-21 13:34:23 +01:00
|
|
|
|
2022-07-03 12:35:56 +02:00
|
|
|
steps:
|
2023-10-05 18:14:18 +02:00
|
|
|
- name: Check whether the needed jobs succeeded or failed
|
|
|
|
uses: re-actors/alls-green@release/v1
|
|
|
|
with:
|
|
|
|
jobs: ${{ toJSON(needs) }}
|
2021-03-21 13:34:23 +01:00
|
|
|
|
2022-07-03 12:35:56 +02:00
|
|
|
fmt:
|
|
|
|
name: fmt
|
2021-03-21 13:34:23 +01:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
2022-07-03 12:35:56 +02:00
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
2021-03-21 13:34:23 +01:00
|
|
|
|
2022-07-03 12:35:56 +02:00
|
|
|
- name: Install Rust ${{ env.rust_nightly }}
|
2023-05-26 08:23:52 +02:00
|
|
|
uses: dtolnay/rust-toolchain@master
|
2019-11-27 15:30:33 +01:00
|
|
|
with:
|
2022-07-03 12:35:56 +02:00
|
|
|
toolchain: ${{ env.rust_nightly }}
|
|
|
|
components: rustfmt
|
2021-03-21 13:34:23 +01:00
|
|
|
|
2022-07-03 12:35:56 +02:00
|
|
|
- name: Cache Dependencies
|
2023-05-26 08:23:52 +02:00
|
|
|
uses: Swatinem/rust-cache@v2
|
2022-07-03 12:35:56 +02:00
|
|
|
|
|
|
|
- name: Check formatting
|
2023-05-26 08:23:52 +02:00
|
|
|
run: |
|
|
|
|
cargo fmt --all -- --check
|
2020-08-12 22:53:58 +02:00
|
|
|
|
|
|
|
test:
|
2022-07-03 12:35:56 +02:00
|
|
|
name: Test
|
2020-07-02 14:48:37 +02:00
|
|
|
runs-on: ubuntu-latest
|
2024-01-26 12:36:33 +01:00
|
|
|
services:
|
|
|
|
# Setup Postgres for testing PostgresStorage
|
|
|
|
postgres:
|
|
|
|
image: postgres
|
|
|
|
env:
|
|
|
|
POSTGRES_USER: teloxide
|
|
|
|
POSTGRES_PASSWORD: rewrite_it_in_rust
|
|
|
|
options: >-
|
|
|
|
--health-cmd pg_isready
|
|
|
|
--health-interval 10s
|
|
|
|
--health-timeout 5s
|
|
|
|
--health-retries 5
|
|
|
|
ports:
|
|
|
|
- 5432:5432
|
2020-08-12 22:53:58 +02:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2023-05-26 08:23:52 +02:00
|
|
|
rust:
|
2020-08-12 22:53:58 +02:00
|
|
|
- stable
|
|
|
|
- beta
|
2022-03-25 10:19:57 +01:00
|
|
|
- nightly
|
2022-04-20 21:33:44 +02:00
|
|
|
- msrv
|
2023-05-26 08:23:52 +02:00
|
|
|
|
2020-08-12 22:53:58 +02:00
|
|
|
include:
|
|
|
|
- rust: stable
|
2022-03-25 10:19:57 +01:00
|
|
|
toolchain: stable
|
2021-03-21 13:34:23 +01:00
|
|
|
features: "--features full"
|
2020-08-12 22:53:58 +02:00
|
|
|
- rust: beta
|
2022-03-25 10:19:57 +01:00
|
|
|
toolchain: beta
|
2021-03-21 13:34:23 +01:00
|
|
|
features: "--features full"
|
2022-03-25 10:19:57 +01:00
|
|
|
- rust: nightly
|
2024-06-25 17:19:38 +02:00
|
|
|
toolchain: nightly-2024-07-03
|
2023-02-13 08:49:56 +01:00
|
|
|
features: "--features full nightly"
|
2022-04-20 21:33:44 +02:00
|
|
|
- rust: msrv
|
2024-01-21 14:09:07 +01:00
|
|
|
toolchain: 1.70.0
|
2022-04-21 10:52:01 +02:00
|
|
|
features: "--features full"
|
2020-08-12 22:53:58 +02:00
|
|
|
|
2023-05-26 08:23:52 +02:00
|
|
|
steps:
|
2022-07-03 12:35:56 +02:00
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Install Rust ${{ matrix.toolchain }}
|
2023-05-26 08:23:52 +02:00
|
|
|
uses: dtolnay/rust-toolchain@master
|
2019-11-27 15:30:33 +01:00
|
|
|
with:
|
2022-03-25 10:19:57 +01:00
|
|
|
toolchain: ${{ matrix.toolchain }}
|
2022-07-03 12:35:56 +02:00
|
|
|
|
|
|
|
- name: Cache Dependencies
|
2023-05-26 08:23:52 +02:00
|
|
|
uses: Swatinem/rust-cache@v2
|
2022-07-03 12:35:56 +02:00
|
|
|
|
2024-03-02 23:30:15 +01:00
|
|
|
# Generally MSRV dump is not considered a breaking change in by the Rust community.
|
|
|
|
# Thus a minor or a patch version dump of a dependency of ours, can bump MSRV.
|
|
|
|
# (remember that `cargo` uses newest semver compatible versions by default)
|
|
|
|
#
|
|
|
|
# It's silly to bump MSRV every time minor dependency update does (note that this update can
|
|
|
|
# happen even after our crate is published; so users may need to downgrade crates in
|
|
|
|
# `Cargo.lock` independently of how we test our crates), so we downgrade their versions in
|
|
|
|
# MSRV CI specifically instead. This allows as to
|
|
|
|
# 1. Not update MSRV unless we really need to
|
|
|
|
# 2. Test newest (or at least newer) versions of crates in CI
|
2024-03-15 17:25:11 +01:00
|
|
|
#
|
|
|
|
# Example command: `cargo update -p atomic-write-file@0.1.3 --precise 0.1.2`
|
2024-03-02 23:30:15 +01:00
|
|
|
- name: Downgrade deps for MSRV
|
|
|
|
if: ${{ matrix.rust == 'msrv' }}
|
|
|
|
run: |
|
2024-03-21 15:52:57 +01:00
|
|
|
cargo update -p sqlx --precise 0.7.3
|
|
|
|
cargo update -p atomic-write-file --precise 0.1.2
|
2024-03-15 17:25:11 +01:00
|
|
|
exit 0
|
2024-03-02 23:30:15 +01:00
|
|
|
|
|
|
|
|
2022-07-04 17:34:11 +02:00
|
|
|
# NB. Don't test (build) examples so we can use non-msrv features in them (--tests/--doc)
|
2023-05-26 08:23:52 +02:00
|
|
|
- name: Compile
|
|
|
|
run: |
|
|
|
|
cargo +${{ matrix.toolchain }} test --tests --no-run --verbose ${{ matrix.features }}
|
2022-07-03 12:35:56 +02:00
|
|
|
|
2020-08-12 23:07:16 +02:00
|
|
|
- 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 &
|
2024-01-26 12:36:33 +01:00
|
|
|
- name: Install psql
|
2024-01-26 11:52:55 +01:00
|
|
|
run: |
|
2024-01-26 12:40:06 +01:00
|
|
|
sudo apt install postgresql-client -y
|
2024-01-26 12:36:33 +01:00
|
|
|
- name: Create PostgreSQL databases
|
|
|
|
run: |
|
|
|
|
psql -h localhost -U teloxide -c "CREATE DATABASE test_postgres_json;"
|
|
|
|
psql -h localhost -U teloxide -c "CREATE DATABASE test_postgres_bincode;"
|
|
|
|
psql -h localhost -U teloxide -c "CREATE DATABASE test_postgres_cbor;"
|
|
|
|
env:
|
|
|
|
PGPASSWORD: rewrite_it_in_rust
|
2023-05-26 08:23:52 +02:00
|
|
|
- name: Test unit & integration tests
|
|
|
|
run: |
|
|
|
|
cargo +${{ matrix.toolchain }} test --tests --verbose ${{ matrix.features }}
|
|
|
|
|
2022-07-03 12:38:14 +02:00
|
|
|
- name: Test documentation tests
|
2022-07-19 16:12:45 +02:00
|
|
|
if: ${{ matrix.rust != 'msrv' }}
|
2023-05-26 08:23:52 +02:00
|
|
|
run: |
|
|
|
|
cargo +${{ matrix.toolchain }} test --doc --verbose ${{ matrix.features }}
|
2020-08-12 22:53:58 +02:00
|
|
|
|
2022-07-03 12:35:56 +02:00
|
|
|
check-examples:
|
2020-07-02 14:48:37 +02:00
|
|
|
runs-on: ubuntu-latest
|
2022-07-03 12:35:56 +02:00
|
|
|
|
2020-07-02 14:52:42 +02:00
|
|
|
steps:
|
2022-07-03 12:35:56 +02:00
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Install Rust stable
|
2023-05-26 08:23:52 +02:00
|
|
|
uses: dtolnay/rust-toolchain@master
|
2020-03-27 13:54:06 +01:00
|
|
|
with:
|
2020-07-03 14:50:28 +02:00
|
|
|
toolchain: stable
|
2022-07-03 12:35:56 +02:00
|
|
|
|
|
|
|
- name: Cache Dependencies
|
2023-05-26 08:23:52 +02:00
|
|
|
uses: Swatinem/rust-cache@v2
|
2022-07-03 12:35:56 +02:00
|
|
|
|
|
|
|
- name: Check examples
|
2023-05-26 08:23:52 +02:00
|
|
|
run: |
|
2023-06-01 12:24:43 +02:00
|
|
|
cargo +stable check --examples --features full
|
2022-07-03 12:35:56 +02:00
|
|
|
|
2022-11-25 11:38:34 +01:00
|
|
|
# TODO: prolly move it to a separate step?
|
|
|
|
- name: Check with no default features
|
2023-05-26 08:23:52 +02:00
|
|
|
run: |
|
2023-06-01 12:24:43 +02:00
|
|
|
cargo +stable check --no-default-features
|
2022-11-25 11:38:34 +01:00
|
|
|
|
2022-07-03 12:35:56 +02:00
|
|
|
clippy:
|
|
|
|
name: Run linter
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Install Rust ${{ env.rust_nightly }}
|
2023-05-26 08:23:52 +02:00
|
|
|
uses: dtolnay/rust-toolchain@master
|
2022-07-03 12:35:56 +02:00
|
|
|
with:
|
|
|
|
toolchain: ${{ env.rust_nightly }}
|
|
|
|
components: clippy
|
|
|
|
|
|
|
|
- name: Cache Dependencies
|
2023-05-26 08:23:52 +02:00
|
|
|
uses: Swatinem/rust-cache@v2
|
2022-07-03 12:35:56 +02:00
|
|
|
|
|
|
|
- name: clippy
|
2023-05-26 08:23:52 +02:00
|
|
|
run: |
|
|
|
|
cargo clippy --all-targets --features "full nightly"
|
2022-07-03 12:35:56 +02:00
|
|
|
|
|
|
|
doc:
|
|
|
|
name: check docs
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Install Rust ${{ env.rust_nightly }}
|
2023-05-26 08:23:52 +02:00
|
|
|
uses: dtolnay/rust-toolchain@master
|
2022-07-03 12:35:56 +02:00
|
|
|
with:
|
|
|
|
toolchain: ${{ env.rust_nightly }}
|
|
|
|
|
|
|
|
- name: Cache Dependencies
|
2023-05-26 08:23:52 +02:00
|
|
|
uses: Swatinem/rust-cache@v2
|
2022-07-03 12:35:56 +02:00
|
|
|
|
|
|
|
- name: rustdoc
|
2023-05-26 08:23:52 +02:00
|
|
|
run: |
|
|
|
|
cargo docs # from .cargo/config.toml
|