teloxide/.github/workflows/ci.yml

238 lines
6.3 KiB
YAML
Raw Permalink Normal View History

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
2023-02-13 08:55:16 +01:00
merge_group:
2019-11-27 15:30:33 +01:00
name: Continuous integration
env:
2024-01-21 11:28:01 +01:00
RUSTFLAGS: "--cfg CI_REDIS --cfg CI_POSTGRES -Dwarnings"
RUSTDOCFLAGS: "--cfg docsrs -Dwarnings"
RUST_BACKTRACE: short
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
# When updating this, also update:
# - 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
# When updating this, also update:
# - **/README.md
# - **/src/lib.rs
# - down below in a matrix
2023-10-04 18:01:46 +02:00
# - `Cargo.toml`
# - **/CHANGELOG.md
2024-08-24 16:07:33 +02:00
rust_msrv: 1.80.0
CI: 1
2019-11-27 15:30:33 +01:00
jobs:
# 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
if: always()
needs:
- fmt
- test
- check-examples
- clippy
- doc
steps:
- name: Check whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
fmt:
name: fmt
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust ${{ env.rust_nightly }}
uses: dtolnay/rust-toolchain@master
2019-11-27 15:30:33 +01:00
with:
toolchain: ${{ env.rust_nightly }}
components: rustfmt
- name: Cache Dependencies
uses: Swatinem/rust-cache@v2
- name: Check formatting
run: |
cargo fmt --all -- --check
test:
name: Test
2020-07-02 14:48:37 +02:00
runs-on: ubuntu-latest
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
strategy:
matrix:
rust:
- stable
- beta
2022-03-25 10:19:57 +01:00
- nightly
2022-04-20 21:33:44 +02:00
- msrv
include:
- rust: stable
2022-03-25 10:19:57 +01:00
toolchain: stable
features: "--features full"
- rust: beta
2022-03-25 10:19:57 +01:00
toolchain: beta
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-08-24 16:07:33 +02:00
toolchain: 1.80.0
2022-04-21 10:52:01 +02:00
features: "--features full"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust ${{ matrix.toolchain }}
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 }}
- name: Cache Dependencies
uses: Swatinem/rust-cache@v2
# 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
#
# Example command: `cargo update -p atomic-write-file@0.1.3 --precise 0.1.2`
- name: Downgrade deps for MSRV
if: ${{ matrix.rust == 'msrv' }}
run: |
exit 0
# NB. Don't test (build) examples so we can use non-msrv features in them (--tests/--doc)
- name: Compile
run: |
cargo +${{ matrix.toolchain }} test --tests --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: Install psql
run: |
2024-01-26 12:40:06 +01:00
sudo apt install postgresql-client -y
- 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
- name: Test unit & integration tests
run: |
cargo +${{ matrix.toolchain }} test --tests --verbose ${{ matrix.features }}
- name: Test documentation tests
if: ${{ matrix.rust != 'msrv' }}
run: |
cargo +${{ matrix.toolchain }} test --doc --verbose ${{ matrix.features }}
check-examples:
2020-07-02 14:48:37 +02:00
runs-on: ubuntu-latest
2020-07-02 14:52:42 +02:00
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust stable
uses: dtolnay/rust-toolchain@master
2020-03-27 13:54:06 +01:00
with:
2020-07-03 14:50:28 +02:00
toolchain: stable
- name: Cache Dependencies
uses: Swatinem/rust-cache@v2
- name: Check examples
run: |
2023-06-01 12:24:43 +02:00
cargo +stable check --examples --features full
2022-11-25 11:38:34 +01:00
# TODO: prolly move it to a separate step?
- name: Check with no default features
run: |
2023-06-01 12:24:43 +02:00
cargo +stable check --no-default-features
2022-11-25 11:38:34 +01:00
clippy:
name: Run linter
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust ${{ env.rust_nightly }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.rust_nightly }}
components: clippy
- name: Cache Dependencies
uses: Swatinem/rust-cache@v2
- name: clippy
run: |
cargo clippy --all-targets --features "full nightly"
doc:
name: check docs
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust ${{ env.rust_nightly }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.rust_nightly }}
- name: Cache Dependencies
uses: Swatinem/rust-cache@v2
- name: rustdoc
run: |
cargo docs # from .cargo/config.toml